For an index to all my stories click this text.
Introduction
ESPEasy is a software package for the ESP8266 and ESP32 that brings IOT functionality where no programming knowledge for is needed. The previous story in this series showed how to install ESPEasy and how to build a button in Domoticz that controls a led attached to an ESP8266 that runs ESPEasy. Indeed no programming was involved !!!
Please read or re-read that story first before continuing here because all the necessary background information is in that story. You can re-read it here http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
This story tells how to send data from an ESP8266 with ESPEasy to another ESP8266 also with ESPEasy. Again: no programming required !!!! You could use this as a doorbell, movement alarm, door alarm, setting a lamp on etc. etc. etc.
As we will be sending data from one ESP8266 to another ESP8266 no home automation system or cloud service is needed. This is pure communication between two ESP's.
What you'll need.
To reproduce this project you will need two ESP8266's. I used two Wemos D1 Mini's but any version will do. The first ESP8266 will have a led attached. The second ESP8266 has a button attached.
So start with flashing ESPEasy on both ESP8266's as described in the previous story in this series : http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
Breadboard setup
We need two breadboards. The first one has an ESP8266 with a led and is the receiver. It will get a command from the other ESP8266 to set the led on or off.
The setup is as simple as it gets. An ESP8266 (Wemos D1) with a led, connected to D7. As usual there is a current delimiting resistor of 220 ohm connected to the led. Actually this is the same setup as used in the previous story.
The second breadboard has an ESP8266 with a button. No pull-up resistor needed. We are going to use the internal pull-up resistor in the ESP8266 for that. This is the transmitter.
So this setup is equally simple. The button is at one side connected to GND and the other side to D3.
Setting up the receiver
Actually there is nothing to set up. As you might know from the previous story in this series ESPEasy reacts on simple HTTP commands to set an IO pin high or low.
The receiver has in this example the IP-number 192.168.1.82 Please alter this to your own settings.
Setting up the transmitter
First step is to tell ESPEasy to which pin the button is attached.
At the top of the screen click on Devices.
As the picture shows we can add 12 devices (Tasks) to the ESP8266. A device can be a button or a sensor.
The list of sensors that direct can be used in ESPEasy can be found here:
https://www.letscontrolit.com/wiki/index.php?title=Devices As you can see there are more as 100 sensors that direct can be used as the drivers are build into ESPEasy !!!
We want to add a switch. So first press on the Add button for Task1
Click on the - None - label and a drop down menu appears with all the available sensors. Scroll down till you see Switch input - Switch and click on that.
The screen changes in the settings screen for switches. Lets first look at the upper part of that page.
Now give the button a name. I named it sw1 but choose anything you like. As said before you can add multiple tasks so also multiple buttons. Therefore choose a logical name.
Make sure the button is enabled by checking enabled so it turns blue with the V sign in it.
In the sensor section check Internal Pullup. That way we do not have to use an external pull-up resistor on the ESP8266. Clicking it will turn it blue with the V sign.
The button is on the breadboard attached to D3 of the ESP8266 so make sure to choose GPIO-0 (D3) from the drop down menu.
Choose Switch as the switch type.
And choose Push Button Active Low as the button type.
Leave all other settings as they are.
At the bottom of the page make sure you check Send to Controller 1. ESPEasy can work with 3 Controllers. In this example we are going to use a single one. We will get to the meaning and purpose of the Controllers in a moment.
The IDX and interval value stay as they are: 0
And the last line allows you to name a variable in which the value of the button is stored. Just like coding with the Arduino IDE the value will be 1 if the button is NOT pressed, because of the pull-up function. The value will become 0 if the button is pressed. As with the button name choose the variables name wise as you can have multiple switches attached to the same ESP8266.
When done click Submit and the settings are stored in ESPEasy. Then click Close.
ESPEasy quircks
Well in the first part of this series I told you that in my opinion ESPEasy has some quircks. Well here is the first one.
This is now how your Devices screen should look. Task 1 is activated. The attached device is a Switch with the name sw1. The task communicates with CTR (Controller) 1 (more on that later). The button is attached to GPIO-0 (D3). And the variables name is sw1val and the value is 1 (in green).
The value is 1 as the button is not pressed and uses the internal pull-up resistor of the ESP8266. Now press the button on the ESP8266 and ........ nothing happens. Press it again a few times and still nothing happens.
When I started working with ESPEasy I thought something was wrong and I started searching for the error. I switched back to the Edit screen and fiddled with the settings and then sometimes the sw1val changed into a 0 and later back again into a 1. But it did not works as I expected it to work like I was used from a button in the Arduino IDE.
But ESPEasy works different !!!
First thing to know is that the button works as a latching button. If you press the button the value of sw1val changes to 0 and stays 0 till you press the button again.
Second thing to know is that the pages are not live updated.
So press the button on the breadboard and refresh the page. Now you will see that the 1 has changed into a 0 or the other way round.
Would be a good thing if that was explained more in the documents.
The Controller.
The switch is setup. Now we need a way to send it's state (0 or 1) to the other ESPEasy (the receiver). For that we need a Controller. So click on the Controllers tab at the top of the page.
As you can see we have room for setting up 3 Controllers. The name Controllers was a bit confusing to me. The manual defines it as follows: A controller is a component to enable a plugin to send data elsewhere. Well that mystified it only more for me. What the hell is a plugin and what is data elsewhere.
But of course I figured it out. A plugin is a sensor or a button etc. And data elsewhere is another ESP, your home automation system, a cloud based service like Thingspeak etc etc etc. Well that clears it up.
Click on the Add button in front of the 1 to setup the first (and for this story only) Controller.
As you can see the protocol for the Controllers is set as Standalone. Not what we want. We want to send commands over HTTP.
Click on Standalone in the drop-down menu. Dont hesitate to have a look at all the options. As you can see there are several communication protocols build in. For now we stick to Generic HTTP.
Use the same settings as you can see in the above picture. Only make sure that you replace the Controller IP with the IP number of your own receiver IP. The Controller port is 80 as we will send commands over HTTP. Leave the rest of the settings unchanged for now. Just make sure that Enabled (at the bottom) is checked. If Enabled is not checked the Controller will not work. This is an easy way to switch between multiple Controllers.
What needs a closer look is Controller Publish. That is the second last line in the Controller Setup.
Controller Publish
This line does exactly what it says. In here we need to compose the command which we are going to send over HTTP.
The previous story showed that for sending a command over HTTP to control an IO pin the command structure is:
http://<ESPEasy IP Adress>/control?cmd=GPIO,number,value
We know the receiver's IP adress in this example is 192.168.1.82. We also know that the led is attached to D7. ESPEasy however uses the real IO pin numbers and that is GPIO 13. So the command for setting the led on is:
http://192.168.1.82/control?cmd=GPIO,13,1
And setting the led off is done by:
http://192.168.1.82/control?cmd=GPIO,13,0
You might check the previous story for a detailed explanation on this. Re-read it here: http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
The IP adress is filled in at the top of the page. So we only need to fill in the rest of this line. Leave away the first /. So we need to send: control?cmd=GPIO,13,1 to switch the led on, or a 0 at the end to switch the led off.
What we really want to do is to use the variable sw1val for that. So there needs to be a way to incorporate that into the command.
Well it took me a while to figure that out. This is also a quirck that is not explained in the documentation. But after a lot of experimenting I found it.
A variable in ESPEasy can be referred to by the name of the unit followed by # and then followed by the name of the variable. All packed between square brackets.
Our switch has the name sw1 and the variable has the name sw1val. That makes the reference to the variable: [sw1#sw1val]
So the total command shall be: control?cmd=GPIO,13,[sw1#sw1val]
And now we have the setup for the Controller complete. Exchange the names sw1 and sw1val for the ones you used in your Device setup and we are done. Press Submit at the bottom of the page and then press Close.
Indeed we are done.
This project is completed. To get things working just press the button on the transmitter ESP and the led on the receiver ESP will go on. Press the button again and the led will go off. All done without 1 line of coding and no cloud service needed !!!
That is all. It looks complicated but it really is not. Just get used to working with ESPEasy and you will enjoy it's simplicity in the end.
I was going to add how to send data from ESPEasy to Domoticz in this story. But there is already a lot of information in here so I save that for a future story.
Conclusion for now.
ESPEasy is fun to work with. It is indeed possible to get things done like sending data from one ESP to another without 1 line of code, as this story shows.
This story and the previous have not even scratched the surface of what is possible with ESPEasy. So I urge you to dive into it and start experimenting.
But it is not completly easy as the name suggests. The documentation is a bit crummy. You will need some experience with ESP8266 to attach buttons and sensors. And you need some insight about IP-Adresses, HTTP code etc. So the easy part of the name is only justified for those that are not total layman.
Still I urge you to experiment with ESPEasy and if you get the hang of it, it is possible to set up some IOT projects in a very short time.
Till next time
have fun
Luc Volders