In this tutorial we will show how to build ESP8266 WiFi relay switch with Arduino and EasyIoT server. You can use relay switch to remotely (computer or mobile smartphone) control your devices like light, heater, garage door,... You can also combine relay switch with other sensors like temperature, humidity...
EasyIoT server supports secure SSL connection - ESP8266 does not.
There is also EasyIoT Cloud internet controlled switch tutorial:
See more tutorials at http://iot-playground.com/build
Step 1: Materials
ESP8266 WiFi module
Arduino Pro Mini 8Mhz, 3.3V
5V Relay module
NPN transistor 2N2222
AMS1117 3.3V regulator
EasyIoT server ( Raspberry Pi or Windows machine)
WiFi network (WiFi router)
Buying guide for materials:
Step 2: Build ESP8266 WiFI relay node
Be sure to use ESP8266 V0.9.9.2 firmvare available here.
Connect Arduino Pro Mini 8Mhz 3.3V and ESP8266 module.
VCC 3.3 V to Arduino pro mini
VCC 3.3V to ESP8266 VCC module
VCC 3.3V to CH_PHD pin on ESP8266 module
connect GND on Arduino, ESP8266 and power supply GND
connect pin 3 on Arduino to pin RST pin on ESP8266
connect pin 10 on Arduino to pin UTXD pin on ESP8266
connect pin 11 on Arduino to pin URXD pin on ESP8266
Connect relay module to Arduino
Because relay module uses 5V we must connect relay VCC to 5V power supply. Between Arduino pin and relay IN we add resistor and 2N2222 tranzistor. In our example code we use Arduino pin 13, but you can use any free digital Arduino pin or more pins if you are using more relays. See datasheet for details.
After connecting wires program Arduino with ESP8266 WiFi relay switch example available on GitHub. Don't forget to set correct access point and password and EasyIoT server IP address in Esp8266EasyIoTConfig.h.
Step 3: Build EasyIoT server
Raspberry Pi EasyIoT server: Download latest version of EasyIoT serverimage and write it to SD card. Put SD card in Raspberry Pi and switch it on. Windows users can write EasyIoT server image to SD card with Win32 Disk Imager.
Or if you are using Windows machine: just download latest release ofEasyIoT server win release and unzip it to Windows machine. Run EasyIoT.exe under administrator privileges.
Step 4: Add ESP8266 relay switch to EasyIoT server
On computer enter Raspberry Pi IP address in browser. After login with username admin and password test go to Configuration->Drivers->ESP8266 EasyIoT Driver and enable driver. Press button Add node and switch on ESP8266 relay node. After 15s you should see newly added node (no timeout message). Then add new module to groups and modules to see it on front page.
Step 5: Control ESP8266 WiFi switch
In web browser go to front page and find newly added module. Click on module and test relay switch.