In this tutorial we will show how to create ESP8266 WiFi relay switch with ESP8266 module and Arduino. You can use relay switch to remotly control more than one device (as many as you have free Arduino digital ports). You can also combine relay switch with other sensors. We will use ESP8266 EasyIoT library.

Materials

See buying guide at the end of tutorial.

-ESP8266 WiFi module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.11
$17.00
ESP8266 ESP-03 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-03 Serial WIFI Wireless Transceiver Module
$2.07
$2.15
ESP8266 ESP-12 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-12 Serial WIFI Wireless Transceiver Module
$2.06
$1.75
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.88

 

-Arduino Pro Mini 8Mhz, 3.3V

3.3V 8Mhz Arduino Pro Mini3.3V 8Mhz Arduino Pro Mini
$2.05
$1.78

 

-5V Relay module

1 Channel Isolated 5V Relay Module1 Channel Isolated 5V Relay Module
$1.34
$1.12

 

-5V power supplay

5V 2A Charger Micro USB5V 2A Charger Micro USB
$2.43
$3.40

 

-3.3V power supply (see datasheet)

10Pcs AMS1117-3.3 LM1117 3.3V 1A SOT-223 Voltage Regulator10Pcs AMS1117-3.3 LM1117 3.3V 1A SOT-223 Voltage Regulator
$0.99
$1.22

 

-EasyIoT server on Raspberry Pi (see download page)

RASPBERRY PI 3 - Model B. 1GB RAMRASPBERRY PI 3 - Model B. 1GB RAM
$41.99
$39.96

 

-WiFi network (WiFi router)

Connect wires

Connect Arduino Pro Mini and ESP8266 module. See conenct ESP8266 and Arduino tutorial how to do this. Then we need to connect relay module. Relay module has 5V power supply so we connect VCC to 5V power supply and GND is common to 5V and 3.3V. Next we connect relay module to IN to digital pin on Arduin board. Because relay module is powered by 5V and Arduino on 3.3V we will add transistor transistor 2N2222 and 10K resistor between modules. In our case we will use Arduino pin 13. You can select other pin or connect more relays to more Arduino pins. Don't forget to correct Arduino program if you use different pins. 

Arduino relay module connection

After we connect wires we will program Arduino. Arduino ESP8266 WiFi Relay switch is available at GitHub. Don't forget to set correct access point and password and EasyIoT server IP address in Esp8266EasyIoTConfig.h.

Add relay node to EasyIoT server

Go to in Web browser and enter EasyIoT server IP address. After logging in go to Configuration->Drivers->ESP8266 EasyIoT driver and enable driver. Then click "Add node" and switch on relay node.

After 15s you should see newly added module(no timeout message).

Now add new module to group to see it on front page.

Name module.

If you done everything correctly you should see relay node on front page.

Click on switch control in web browser and test ESP8266 WiFi relay module.

 

Check also ESP8266 Cloud relay tutorial.

 

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

Buying guide

 

To support this site and EasyIoT framework development please buy in our store.

 

Arduino Mega 2560

For bigger Arduino projects.

5V 16Mhz Arduino Pro Mini

Small but powerful suitable for most DIY Arduino projects.

3.3V 8Mhz Arduino Pro Mini

3.3V Arduino version. No need for shift leveler when using ESP8266.

400X 0.25w 1/4w Metal Film Resistor Pack Kit 1% 20 Value Each 20 Pcs 10 ~ 1M ohm

100Pcs NPN Transistor TO-92 2N2222

All purpose NPN transistor.

1 Channel Isolated 5V Relay Module

Be able to control various appliances, and other equipments with large current.

2 Channel 5V Relay Module With optocoupler

Be able to control various appliances, and other equipments with large current. 2 channel.

4 Channel 5V Relay Module With optocoupler

Be able to control various appliances, and other equipments with large current. 4 channel.

8 Channel 5V Relay Module With optocoupler

Be able to control various appliances, and other equipments with large current. 8 channel.

5V 2A Charger Micro USB

For Raspberry Pi or sensor modules, cheap and easy power solution.

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module

ESP8266 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module

ESP8266 serial WIFI model ESP-03

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module

ESP8266 serial Port WIFI wireless module ESP-12

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

 


Comments   

#7 profile 2018-10-31 18:29
Need cheap hosting? Try webhosting1st, just $10 for an year.

#6 MvincM 2017-01-10 08:52
Hello.

Nice project... almost all clear but I'm new in electronic subject... I don't understand this:

"Then we need to connect relay module. Relay module has 5V power supply so we connect VCC to 5V power supply and GND is common to 5V and 3.3V. Next we connect relay module to IN to digital pin on Arduin board. Because relay module is powered by 5V and Arduino on 3.3V we will add transistor transistor 2N2222 and 10K resistor between modules"

Could you explain it... You know "for dummies"... My realy bord couldn't be controled by 3V3 GPIO...

Please help ;)
+1 #5 Super User 2015-09-20 12:15
Quoting eliobou:
Is it possible to use only the ESP8266 without arduino since it is a microcontroler as well ?


yes, see http://iot-playground.com/build for more details...
+1 #4 eliobou 2015-08-28 22:05
Is it possible to use only the ESP8266 without arduino since it is a microcontroler as well ?
+2 #3 UC 2015-04-11 05:21
Large number of Lua programs for standalone ESP8266 are appearing these days but for all of them the SSID and password are firmware coded.Therefore while one moves away from the tested network it does not work. I have seen only one ,very lengthy that provides the entry of SSID & password to be written in a webpage first while ESP is in own access mode and thereafter it goes to wifi mode so that one can use it any network.A simple Lua program with above features to switch on and off GPIO0 is required.
#2 Super User 2015-02-22 13:10
Quoting Saran:
To which network our windows pc should be connected.

Am getting error...:(

Awaiting with anticipation...


Computer is usually on the same network as ESP8266.
#1 Saran 2015-02-21 13:32
To which network our windows pc should be connected.

Am getting error...:(

Awaiting with anticipation...

You have no rights to post comments

Forum latest

  • No posts to display.