Nothing should happen when you execute the scripts, the script are only “setting the message” on the server, and by the way they need to be Retain: True on both (I think) in order for the ESP to “pick it up” when it is rebooting from sleep and connection to the MQTT server.
The order is this: You set a retained message on the MQTT server, the server does nothing but “holds” this message on this topic. The ESP then wakes up (after your 300s deep sleep), connects to the MQTT server and receives a message (since it is configured to subscribe to that topic), and if a message with the payload ON is received the ESP won’t go back to sleep. You can then issue an update, send a new message with the topic OFF to the server. Reboot the ESP, it will then pick up an OFF payload and initialize sleep again.
This looks correct, assuming that the NodeMCU have a built in voltage divider this is correct… You have 3.2 before your divider, the ESP “sees” 0.95V.
The “raw” value that the ESP is reading is… your output of 0.73 / 2.666667 = 0,27375… that multiplied with the “internal” 3.3V voltage divider (which is probably not that accurate in terms of exact ohm values) gives 3.3 * 0.27375 = 0,903 V which is close enough to your output… I am not an electrical engineer but I think this is correct
Not that I am aware of. And you have the MQTT broker on the raspberry and they are on the same network as the ESP? And the IP-address set for the broker is correct? And no rules on the WiFi like a guest network that the ESP is connected to? This would prevent the ESP to reach any local devices.
yes, i reach HA at 192.168.0.9:8123 so i assume the broker is at 192.168.0.9
from integrations i click configure on the mqtt broker and i have the options to listen to a topic hence i know it works on the pi itself
nope i have not enabled guest networks, those are unsafe and everyone near my house would be able to connect and download illegal stuff and i would get the blame
my esp had the ip 192.168.0.231 and if i enable webinterface on it i can see the temeperature etc on it, i did that on purpose to test that the BME280 sensor was working correctly and that battery voltage was correct
my thought is that the broker only works on localhost on the pi and not on eth0 hence it would not be reachable on the local network… or that there is some kind of firewall but like you i doubt that
There isn’t any real dashboard, it’s just the sensors from the device-view added to standard cards. On one of them there is a added footer graph. I realize my code from april is a bit out of date, it holds for the most part but I have switched to auto discovery: true so changes are handled easier and appears on the integration page. I added some sensors and wanted to simplify some things. So now I have them added through the Integration page and can add the cards from that view.
now i just need to jerryrig a coin cell battery and see how long it will last
do i assume right that is how long it sleeps for before each wake up?
and how do i find out how long it should run if i use dhcp? just connect and see how long it takes before i get the first mqtt? i know it might cost me a bit of battery but it makes life a bit more simple
The run duration is not that important. In my case I set it to one second. In reality the esp take more to boot, connect to wifi, go through the code and then go to sleep again. Normal run times (the run time sensor) are reported as around 4000-5000ms. As long as you don’t need more than one value sent for every sleep cycle you can set the run duration to 1s.
now i just need to jerryrig a coin cell battery and see how long it will last
I recently had a project where I used deep sleep. Intention was to have the device sleep whilst i was asleep and awake when I woke up. The method was successful but my battery setup still not sufficiently sized so abandoned the idea. Perhaps useful for others though. Source: https://tatham.blog/2021/02/06/esphome-batteries-deep-sleep-and-over-the-air-updates/
I used ha booleans and input numbers to control the prevent and duration respectively. No reliance on mqqt as the API functionality was sufficient for me. Please double check indentation when using this. I copied it from plain text.