ESP8266 WiFi Relay Switch
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
Materials
ESP8266 WiFi module
Arduino Pro Mini 8Mhz, 3.3V
5V Relay module
NPN transistor 2N2222
resistor 5K1
AMS1117 3.3V regulator
1000uF capacitor
EasyIoT server ( Raspberry Pi or Windows machine)
WiFi network (WiFi router)
Buying guide for materials:
http://iot-playground.com/blog/2-uncategorised/16-esp8266-wifi-relay-switch
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.
Build EasyIoT Server
Raspberry Pi EasyIoT server: Download latest version of EasyIoT server image 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 of EasyIoT server win release and unzip it to Windows machine. Run EasyIoT.exe under administrator privileges.
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.
Control ESP8266 WiFi Switch
In web browser go to front page and find newly added module. Click on module and test relay switch.
Check also ESP8266 only internet connected switch:
https://www.instructables.com/id/ESP8266-5-internet...
See also other ESP8266 tutorials.