ESP8266 WiFi Relay Switch

by EasyIoT in Circuits > Arduino

227376 Views, 297 Favorites, 0 Comments

ESP8266 WiFi Relay Switch

23-12-2014_0-23-29.png

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:

http://iot-playground.com/blog/2-uncategorised/77-esp8266-internet-controlled-switch-easyiot-cloud-mqtt-api

See more tutorials at http://iot-playground.com/build

Materials

WiFi Serial Transceiver Module.jpg
BK_SRD.jpg
50720-11114-01.jpg

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

23-12-2014_9-25-34.png
AMS1117.png

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.JPG

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

23-12-2014_0-13-20.png
23-12-2014_0-13-53.png
23-12-2014_0-21-04.png
23-12-2014_0-21-29.png
23-12-2014_0-21-38.png
23-12-2014_0-21-57.png
23-12-2014_0-22-18.png
23-12-2014_0-22-37.png

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

23-12-2014_0-23-11.png
23-12-2014_0-23-29.png
20141223_001945.jpg

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.