Can any more experienced types with IoT confirm my understanding. I am very new to esphome.
The project (my very first) is to measure 5x12v Flooded Battery voltages and send these to HA. This all works completely fine.
The next step is:
deep_sleep mode would save pointless recharge cycles occurring from powering the esp32 and the buck convertor.
The context:
The batteries are remote and “alone” for 6 months or more and hold charge enough for starts when the time comes. This is purely an assurance project.
A solution:
I would like to use long deep_sleep cycles of 7 days or more followed by just enough up time to communicate a single update and then sleep again. This desire generates the firmware update problem.
What I have read up on:
I have read that an MQTT message can be used to prevent deep sleep, so I have started to read up on and configure MQTT.
I have installed MQTT mosquito and the HA integration and all seems to be fine. I have yet to get the board to connect to MQTT broker, I keep getting unauthorised which is something I have not yet fixed. Same password and username in the device.yaml as in the mosquito config. Integration restarted. etc. no dice. Secondary issue at the moment.
Primary issue:
What I have noticed though on my test board, is that all OTA logging stops once the MQTT config block is written into the config and flashed to the device. Also my voltage sensor goes offline.
I think what is going on is that I can’t have MQTT and the API running on the same device at the same time. So what we are then saying is that it’s EITHER native API or MQTT not both?
For test purposes I rely on the API logging feature which gives me allot of useful info really quickly. Once MQTT is enabled all that seems to disappear. Am I missing something obvious with regards to that logging “swapping” over to MQTT if this is the route I am required to go?
I am including the test config yaml in case something in that helps the answers I need.
esphome:
name: tractor-battery
friendly_name: "Tractor Battery"
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
# Voltage Sensor - short for testing
sensor:
- platform: adc
pin: GPIO1
name: "Tractor Battery Voltage"
attenuation: auto
update_interval: 5s
# Sleep Settings - short for testing
deep_sleep:
run_duration: 2min
sleep_duration: 10s
id: deep_sleep_1
# Sleep Prevention - logging for testing
#mqtt:
# broker: Ip_address
# username: the_user
# password: the_password
# port: 1883
# on_message:
# - topic: tractor-battery/deep_sleep
# payload: 'DISABLED'
# then:
# - deep_sleep.prevent: deep_sleep_1
# - logger.log: "deepSleep is OFF"
# - topic: tractor-battery/deep_sleep
# payload: 'ENABLED'
# then:
# - deep_sleep.allow: deep_sleep_1
# - logger.log: "deepSleep is ON"
# Reboot Switch
switch:
- platform: restart
name: "Tractor Battery restart switch"
# Presence Sensor
binary_sensor:
- platform: status
name: "Tractor Battery Status"
# SNTP Config
time:
- platform: sntp
id: sntp_time
timezone: "Europe/London"
servers: "192.168.1.1"
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s
encryption:
key: "VDMtXkqwakp+kVYaifWTEK/1tH2QivlKqHNa/L/sVBU="
ota:
- platform: esphome
password: "adc2d4dae0efe00a4cb933c5a27b4a7c"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Tractor-Battery Fallback Hotspot"
password: "vDIRZ1R0rOIM"
captive_portal:
Finally, are all the sensors exposed in the same way via MQTT, or is that too vague a question?
- Can you run MQTT and native API simultaneously on an esp32-c3 board?
- Can I get the same friendly logging over MQTT like I get from the API [once I get it to connect]
- Is sensor configuration largely the same in MQTT, if I do have to go MQTT entirely.
Thanks for any pointers.