

#Mqtt enter deepsleep code#
The code is verry simple: After a reset it connects to wifi and an MQTT server where it publishes a message. By varying the value of the capacitor you can also change the pulse length: The code The signal at the resetpin, when the reedswitch opens looks like that. To get this result I used the following FINAL schematic: I needed to create a pulse trigger singal, when the mailbox gets opened and if it stays opend, the reedswitch-signal doesn´t stay low, and goes high again after a short period of time. So I needed to get rid of this problem to: Third idea – IT Works!! This leads to a realetively high current draw, wich would drain the battery quiet fast. This caues, that the resetpin is pulled low continously. This way the power consumption was verry low.īut there was one problem: Sometimes the post man doesn´t throw the newspaper all the way in to the mailbox, wich causes a opened mail slot and consequently an always opened reedswitch. After the reset it boots up, sends out the data and goes to deep sleep, when finished. If the reedswitch opens the resetpin is pulled low, which resets the ESP. I simply connected the normally high singal of the transistors directly to the resetpin of the ESP. However this idea didn´t work out, because the transistor was not able to keep the ESP powered on as long as it sends the data, so i came up with another idea: Second idea – Better, but still not good I needed to assing two transistor in the following configuration to create a normally high singal: However there was another probem because the reedswitch in my configuration was normally closed.
#Mqtt enter deepsleep how to#
He explains in this video how to do just that.

I was inspired by Andreas Spiess´s video.
#Mqtt enter deepsleep series#
To do this I used a Transistor in series with the ESP which can be bypassed by the switch. My fist idea was to cut off the power of the ESP while the Mailbox is closed so it doesn´t draw any power. The Sensor is powered by a LiFePo4 Battery and therefor it must draw verry little Power while doing nothing to guarantee a long battery lifetime.įor those two problems I came up with two ideas: First Idea – FAIL If we now want to get notified when the mailbox opens we need to use the opening reedswitch as a trigger to send the message. This was the first problem because when the mailbox is closed (which is the case for the most time) the reedswitch is also closed. Node-Red however “converts” it into a Telegram message, which is then posted to my phone via a Telegram-bot.Īs a switch I used a magentic REED-switch, which CLOSES if a magnet gets close to it. If the mailbox opens the ESP wakes up from deep-sleep, connects to Wifi and the MQTT-server and sents out a MQTT message, which is then processed by Node-Red. Februar 2021Ī MQTT Door- or Mailboxsensor using an ESP8266 Wifi Module, which notifies you if you receive a Letter or someone opens the Door
