Avatar

WiFi2MQTT

Feb 03rd, 2020 | by: Paul Enright
Views 178
Create a Zigbee like network using the ESP-Now protocol.
The sensors will use the ESP-Now to talk to a gateway that will then publish MQTT messages that Home Automations can consume. My Home Automation of choice is HomeAssistant. I don't think that should affect any design decessions, but I wanted to be full disclosure.

After searching, the best way to lengthen battery life is by using deep sleep, removing led indicators, and using a more direct route of the WiFi (ESP-Now). To every rule there are exceptions. The first device to make is a button. The button has 3 signals. They are 1-press, 2-press, and long-press. If I understand the ESP deep sleep, the wake is by pulsing the reset to ground. This would not for the double press. To get the double press we need a "Soft-Switch" so on the first press the device can wake up, then look for a certain amount of time for a second press or see it the button is still being pressed and is, therefore, a long press.

While I am waiting for parts to do the soft-switch, I am creating a branch to experiment with the gateway detecting the second press. Since the node is powered only when the button it press (currently) then maybe if the node is still running after a second, then it sends a second message. The gateway would then send a long-press MQTT message.


PHOTO GALLERY

The first two pictures show my current testing ESP-12. 
I have hack up a perfboard with an ESP-12F. 
While doing the first one I missed the pull-up/down resistors. SO I had to hack some resistors on to my hack.
The second one was a little more thought out with lessons learned from the first try.

The video shows how fast you boot, send a message. 
The screen in the background is showing what and when the gateway receives a message.
You can look at the led on the node board (one shown in video) for how long the button is pressed. 
It is tied to power and is independent of the ESP.

The 4th picture is of the board I was making to test in real life. 
The ESP-12F module that on it was one that I tried to wire up as the second one, but I mess up and had solder splashes.
I can it to load the sketch, and according to the serial debug monitor, it is sending the message via ESP-Now. 
But I am not seeing it arrive at the gateway. I may have messed up the antenna or I have it too close to the perfboard.
I saw where someone said they had an issue when the ESP is too close to the battery. The said you have to be away from metal the distance of the length of the antenna.
I have ordered some ESP developer boards and more ESP-12F. So this is on hold for now, but you can get an idea of where I am heading.
I will do some custom PCB for the final design.


GateWay, Node, and cable (Power/Programmer)
First Button board with battery

0 Comments

Login or Sign Up to post comments on this project.