No dashboard, just added everything on the same standard Lovelace page. I went to the integration page under Configuration → Integrations. Opened the ESP-boards and added everything were it says “Add to lovelace”.
On the page were everything is added (I mostly use Glance or just Entities-cards) I added a new card with buttons for the script that is in my post above. This way I can then activate the OTA-scripts on and off and see most of the ESP-boards in the same view.
When I need to change something in the ESP code or just update the little things I first go and edit that under the ESPHome dashboard. I then activate the script to send the persistent message for OTA ON. Then we just have to wait for the ESPs that are on battery to wake up, recieve the OTA on that pervent the deept sleep and stay on. From there we just issue the update over the air (OTA) through the ESPHome dashboard, when the compilation is done and the ESP has recied the update I usually check some of the logs, and then activate the other script for OTA Off. After that all the ESPs have to reboot in order to be able to go back to sleep again. I guess you could also active the OTA off script before doing the update through the ESPHome dashboard but I usually wan’t to see that ewverything runs as it should before I let the things go to sleep again. There is of course some battery drain when doing this since the ESP will stay on until you reboot the device again but it’s not that often a new firmware is required.
Ah, the scripts are just as it says scripts, not to be added directly on a lovelace card… that needs to be added under Scripts in Configuration, you need to add two scripts, one for on and one for off.
I am using two old 18650 from an old laptop battery I butchered a long time ago. Holds up quite well together with a small solar panel, I never recharge them. My design springs from this one (link) if we are talking about the temperature-station. But I built mine in a blocked off bird house with two 3D-printed Stevenson Screens (Thingiverse) on either side of it. On of the screens have a DS18B20 and the other one houses a BME280.
i use a voltage divider (680 and 300 ohm) as the ADC on 8266 only goes to 1V
when i messure with voltmeter i get 3.2 before the divider and about 0.95 after
2.266666666666667 is of course the theoretical value to multiply with,
my problem is that i only get 0.73V, i assume i do something to wrong but cant figure out what
for some reason mqtt do not work, i use the chrome app lens to check topics and nothing happens when i execute the scripts
my broker Mosquitto is setup to allow anonymous posting as its not exposed to the outside world anyway
EDIT EDIT:
so it do work, i guess the access from outside my raspberry pi (but STILL on local network) is not allowed, its also the first time my local devices need access to home assistant
This will depens on what kind of voltage divider you set up. If you have a Lolin (Wemos) board or something similar (and I believe the NodeMCU also has this) there is a voltage divider already built in so that the A0 accepts 3.3V input at max. Your setup needs to be configured to account for this and your resistors might need to change. You should be fine with having for example R1=300 and R2=1000 to get roughly 3.2V from a max 4.2V battery.
If you are using the VCC on a ESP8266 board you must first remove all connections to A0. There is some useful information here: Analog To Digital Sensor — ESPHome
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.