Using the ESP8266 module for the Internet of Things

Relay control from a web-page

For controlling the relay board from a web-page, open the esp8266-relay sketch with the Arduino-IDE and select “Tools->Wemos D1 R2 and Mini” in the boards-manager. Set “Flash Size” to 4M, “Upload Serial”, “80 MHz” CPU frequency and “921600” upload speed. The device connects to port “/dev/ttyUSB0” under Linux.

Next, enter your SSID and WLAN password to connect to your WLAN router.

// WiFi parameters
const char* ssid = "SSID";
const char* password = "password";

For each relay channel, create an on/off switch for the UI. Remember that the ESP8266 pin numbering does not correspond to the labels printed on the WeMos board.

// Create UI
 rest.title("WeMos D1 Relay Control");
 rest.button(5); // GPIO5 on ESP8266 is D1
 rest.button(4); // GPIO4 on ESP8266 is D2

After uploading the sketch, push the reset button and open the serial monitor. It should display the IP address. Now you can disconnect the WeMos Mini from the USB port and connect the circuit using the breadboard power supply. (The circuit might draw more current than the allowed max. 500 mA on USB).

Now you can navigate with your browser to the WeMos Relay Webserver (just enter the IP address). You should see a web page containing four buttons for controlling the relay – nice!

relay_control

Subscribe
Notify of
7 Comments
Inline Feedbacks
View all comments
8 years ago

Here is better Fritzing part for WeMos D1 mini:
https://github.com/mcauser/Fritzing-Part-WeMos-D1-Mini

8 years ago

Yep Fritzing is a nice software but UI is not so clear… (and also it’s not really stable). However it’s the only one I know that can make breadboard/stripboard schematic…

I manage to create some parts following the Sparkfun tutorial :
https://learn.sparkfun.com/tutorials/make-your-own-fritzing-parts
Using inkscape for svg creation.

8 years ago

Thanks for this post !

I’m looking for a fritzing part for Wemos D1. I guess your schema http://luetzels.raspiblog.com/wordpress/wp-content/uploads/2016/01/WeMos_D1_Relay.png is made with fritzing.

Can you indicate me where do you find the WeMos D1 part ? or if you made it, can you share it ?

Thanks !

8 years ago
Reply to  luetzel

Ok thanks for your answer,
I also ask here: forum.wemos.cc/topic/14/fritzing-part-for-d1-mini

I think I will open inkscape and try to build it. I’ll post a link to github as soon as it is done.

8 years ago
Reply to  Emmanuel N.

I just create a quick&dirty part.
It is here : https://github.com/enavarro222/MyFritzingParts/blob/master/WeMos_D1_Mini.fzpz

For my use (== stripboard design and documentation) it should do the job… However feel free to improve it ! there is to do 😉