An Arduino-based relay control server and Android client
Note: This project may go long periods of time without being updated, however it is actively used and maintained. Bug reports and pull requests are welcome.
RelayRemote is an Arduino-based server for remotely controlling electrical relays which in turn turn on/off devices run from a standard 120V AC circuit. The project includes three clients, an Android application, a desktop client for control from Linux systems, and an Arduino-based wall switch.
The Android app supports multiple relay servers, relay groups, homescreen widgets, and NFC tags.
A demo video and brief description of how it works is available at: https://shanetully.com/2012/12/controlling-a-relay-via-an-arduino-from-an-android-client-with-nfc/
The original version of this project used an Arduino Uno and Arduino ethernet shield. See the legacy documentation for instructions on using the legacy hardware.
RelayRemote was built and tested on an Adafruit Feather M0 WiFi. A PowerSwitch Tail II is the recommended relay.
- Adafruit Feather M0 WiFi
- Adafruit Feather Female Headers
- PowerSwitch Tail II
- 5V 1A (1000mA) USB port power supply
- A micro-usb cable
An optional piece of hardware is a wall switch for turning on/off relays more like a traditional light switch.
- Adafruit Feather M0 WiFi
- Short Feather Headers Kit
- FeatherWing Proto
- Illuminated Pushbutton Switch
- 5V 1A (1000mA) USB port power supply
- 330 Ohm resistor (or similar)
- A micro-usb cable
- Connect a wire from the positive terminal of the relay to a pin between 2 and 9 (inclusive) on the Feather. Keep note of the pin you choose. Multiple relays can be connected to the same Feather by connecting them to different pins.
- Connect a wire from the negative terminal of the relay to a ground pin on the Feather.
These instructions are for Linux (x86_64).
- Download and extract the Adafruit SAMD library to
~/.arduino15/packages/adafruit/hardware/samd/1.0.9
- Download and extract the ARM compiler to
~/.arduino15/packages/adafruit/tools/arm-none-eabi-gcc/4.8.3-2014q1
- Download and extract Bossac to
~/.arduino15/packages/adafruit/tools/bossac/1.6.1-arduino
. - Download and extract CMSIS to
~/.arduino15/packages/adafruit/tools/CMSIS/4.0.0-atmel
.
Note: The archives above can be extracted whenever you'd like, but the paths at the top of the Makefile must be adjusted accordingly.
- Create
arm/src/secrets.h
with the following content:#define _SSID "your_ssid" #define _PASSPHRASE "passphrase"
- Change the network settings (IP, DNS, netmask, and gateway) for the Feather by editing the server header (
arm/server.h
) in thearm
directory of this repo. - Then:
$ cd arm $ make WIFI_SERVER $ make upload
- Install the APK provided on the Releases page
Alternatively, the Android app can be compiled by:
- Install the Android SDK (http://developer.android.com/sdk/index.html).
- Create
local.properties
in theandroid/
directory with the following contents:sdk.dir=/path/to/android/sdk
. - From the
android
directory, run:$ ./gradlew assembleDebug $ ./gradlew installDebug
- If desired, build the desktop client in the
desktop
directory of this repo on a Linux system by runningmake
from that directory. - The desktop client is fairly straightforward. Run it with
--help
for more info.
- Wire the circuit as follows: On the switch VDD is pin 1 (left most) and LED- is pin 4 (right most).
- Then follow the instructions in the "Setting up the software dependencies" and "Compiling & Uploading" sections above.
- Use
make WIFI_CLIENT
to build.
The default port is 2424. Don't forget to add rules to allow communication on this port on any firewalls or gateways between the client and the server.
Copyright (C) 2012 Shane Tully
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.