ESP32-C5 battery environment sensor with MQTT and deep sleep
Wake on a timer, read an SHT45, publish one MQTT message over Wi-Fi and return to deep sleep. ESP-IDF v6.1.1 firmware, a Python logger and a battery budget with every assumption named.
| Board | Seeed Studio XIAO ESP32C5 |
|---|---|
| Time | about 4 hours |
| Stack | esp-idf, mqtt, python, home-assistant |
| Extra parts | Seeed Studio XIAO ESP32C5, SHT45 breakout (Sensirion SHT45-AD1B) for 3.3 V, 1S Li-ion or Li-polymer cell with a built-in protection circuit, Computer or Raspberry Pi running Mosquitto 2 |
This project is a battery-powered temperature and humidity sensor that spends almost all of its life asleep. Every five minutes it wakes, reads a Sensirion SHT45, joins Wi-Fi, publishes one MQTT message, waits for the broker to confirm it, and goes back to deep sleep. It is for makers who want a sensor that runs for months on one cell, and for product teams who want a small, reviewed reference for the wake-measure-publish-sleep cycle on the ESP32-C5 with ESP-IDF v6.1.1.
What you will build
- Firmware in ESP-IDF v6.1.1 for the ESP32-C5 that reads the SHT45 over I²C (Inter-Integrated Circuit), publishes a JSON (JavaScript Object Notation) message with QoS 1 (quality of service level 1, “at least once”) and sleeps.
- A Mosquitto broker configuration with a password file.
- A Python logger that subscribes to every sensor, writes a CSV (comma-separated values) file and flags missed messages from a sequence counter.
- A Home Assistant configuration that turns the same messages into three sensors.
- A power budget, computed by
tools/calc/power_budget.py, that shows which part of the cycle uses the battery and which numbers you still have to measure.
The sensor publishes to fieldguide/env/<id>, where <id> is the board’s Wi-Fi MAC address without colons. A message has this shape (the values are from the test fixture in host/logger_test.py):
{"id":"aabbccddeeff","seq":7,"t_c":21.53,"rh":44.2,"vbat_mv":3950,"rssi":-58,"awake_ms":1210}
awake_ms is measured by the firmware itself with esp_timer_get_time(). The timer starts during application start-up, so the ROM and bootloader time before it is left out and the real awake time is longer. It is the first number to feed into the power budget.
What you need
| Part | Why | Reference |
|---|---|---|
| Seeed Studio XIAO ESP32C5 | ESP32-C5 with 8 MB flash, 8 MB PSRAM and a lithium charger on the board | Seeed wiki |
| SHT45 breakout for 3.3 V (Sensirion SHT45-AD1B) | ±1.0 %RH and ±0.1 °C accuracy, fixed I²C address 0x44 | SHT4x datasheet v7.3 |
| 1S Li-ion or Li-polymer cell with a built-in protection circuit | The XIAO’s charger is built for a 3.7 V lithium cell | Seeed wiki, battery section |
| A computer or Raspberry Pi on the same LAN | Runs Mosquitto 2 and the logger | mosquitto.conf |
| Optional: ESP32-C5-DevKitC-1 v1.2 | Bench development over USB, and the board the bench run uses | User guide |
The ESP32-C5 has 2.4 and 5 GHz Wi-Fi 6, Bluetooth LE 5 and an IEEE 802.15.4 radio for Thread and Zigbee (ESP32-C5 datasheet v1.5). ESP-IDF v6.1 lists the ESP32-C5 among chips in mass production. The firmware in this project uses only the Wi-Fi radio.
Pick a breakout without a 5 V regulator or level shifter, so the SHT45 runs straight from the board’s 3.3 V rail. The sensor accepts 1.08 V to 3.6 V. Most breakouts fit their own I²C pull-up resistors. The firmware also turns on the ESP32-C5’s internal pull-ups, which are weak but harmless alongside external ones.
Wiring on the XIAO ESP32C5 is four wires. The same GPIOs (general-purpose input/output pins) work on the ESP32-C5-DevKitC-1 v1.2, where GPIO24 is header J3 pin 4 and GPIO23 is J3 pin 5.
| SHT45 breakout | XIAO ESP32C5 | ESP32-C5-DevKitC-1 v1.2 |
|---|---|---|
| VDD | 3V3 | 3V3 (J1 pin 1) |
| GND | GND | G |
| SDA | D4 (GPIO23) | GPIO23 (J3 pin 5) |
| SCL | D5 (GPIO24) | GPIO24 (J3 pin 4) |
Design
Each wake runs the same steps. The order matters for both accuracy and battery life.
- Measure first. The firmware reads the SHT45 before it starts the radio, so the heat and supply dip of a Wi-Fi transmission cannot reach the reading. A high-repeatability measurement (command 0xFD) takes 6.9 ms typical and 8.3 ms at most, so the firmware waits 10 ms before reading the six reply bytes.
- Check the CRC. The reply carries a CRC-8 (cyclic redundancy check, polynomial 0x31, start value 0xFF) after each 16-bit value. A failed check is published as an error instead of a wrong number.
- Join Wi-Fi quickly. The access point’s BSSID (its MAC address) and channel are kept in LP (low-power) memory, which survives deep sleep. On the next wake the station looks only on that channel for that access point instead of scanning every channel. Any disconnect clears the cache, so the next wake scans again.
- Publish once, at QoS 1. The firmware waits for the broker’s acknowledgement (
MQTT_EVENT_PUBLISHED) before it turns the radio off, so a message is not lost because the radio was switched off too early. - Give up on a deadline. Wi-Fi has 10 s and MQTT has 5 s by default (
menuconfig, “Field Guide environment sensor”). If either fails, the board sleeps and tries again next period. A sensor that keeps retrying a dead access point empties its battery. - Sleep.
esp_deep_sleep_start()with a timer wake-up. The sequence counter survives in LP memory, and the logger uses it to count missed messages.
Power budget
The ESP32-C5 datasheet gives 0.012 mA typical in deep sleep with the RTC timer and LP memory on, and 87 mA while receiving on 2.4 GHz Wi-Fi (802.11b/g/n HT20), both at 3.3 V and 25 °C. Transmit peaks reach 320 mA (802.11b, 1 Mbps, 20 dBm). The SHT45 idles at 0.08 µA typical at 25 °C. The awake time is not in any datasheet. It depends on your access point, your broker and the distance, so the budget below assumes 2 s at the receive current. That assumption is optimistic for current, because it ignores transmit bursts.
The profile lives in examples/c5-battery-environment-sensor/power/chip-only.toml. Run it with:
python tools/calc/power_budget.py --profile examples/c5-battery-environment-sensor/power/chip-only.toml --sweep 60,300,900,3600
The script’s output for a 2,000 mAh cell with 80 % usable (an assumption, as is the absence of self-discharge):
| Report period | Average current | Estimated life |
|---|---|---|
| 60 s | 2,911.7 µA | 23 days |
| 300 s | 592.0 µA | 113 days |
| 900 s | 205.4 µA | 325 days |
| 3,600 s | 60.4 µA | 1,104 days |
At a 300 s period the awake phase is 98.0 % of the charge used per period, according to the same output. Two lessons follow. First, the awake time is the number to measure, not the sleep current. Second, these figures exclude the board: the XIAO’s charger, regulator and LEDs add current that the chip datasheet does not cover. Seeed says the board’s charge LED lights while it runs from the battery. Whether it stays lit during deep sleep is something to measure, and if it does, it will dominate the sleep current. Treat the table as an upper bound on life until the Lab measures the whole board with the current measurement method.
Firmware
The firmware is in examples/c5-battery-environment-sensor/firmware/. The MQTT client is not part of the ESP-IDF tree in v6.1. It comes from the component manager as espressif/mqtt, pinned to 1.1.0 in main/idf_component.yml, and the resolved versions are recorded in dependencies.lock.
The SHT45 helpers are plain C with no ESP-IDF calls, so the host test compiles the same file:
// target: esp32c5,esp32h2,host sdk: esp-idf tier: 2
#include "sht4x.h"
uint8_t sht4x_crc8(const uint8_t *data, int len)
{
uint8_t crc = 0xFF;
for (int i = 0; i < len; i++) {
crc ^= data[i];
for (int b = 0; b < 8; b++) {
crc = (crc & 0x80) ? (uint8_t)((crc << 1) ^ 0x31) : (uint8_t)(crc << 1);
}
}
return crc;
}
bool sht4x_decode(const uint8_t raw[6], float *t_degc, float *rh_pct)
{
if (sht4x_crc8(&raw[0], 2) != raw[2] || sht4x_crc8(&raw[3], 2) != raw[5]) {
return false;
}
uint16_t t_ticks = (uint16_t)((raw[0] << 8) | raw[1]);
uint16_t rh_ticks = (uint16_t)((raw[3] << 8) | raw[4]);
float t = -45.0f + 175.0f * (float)t_ticks / 65535.0f;
float rh = -6.0f + 125.0f * (float)rh_ticks / 65535.0f;
if (rh > 100.0f) rh = 100.0f;
if (rh < 0.0f) rh = 0.0f;
*t_degc = t;
*rh_pct = rh;
return true;
}
The I²C read uses the ESP-IDF v6 master driver. The bus is created and deleted on every wake, so nothing is left half-configured before sleep:
// target: esp32c5 sdk: esp-idf tier: 1
// ...
static esp_err_t read_sht45(float *t, float *rh)
{
i2c_master_bus_config_t bus_cfg = {
.i2c_port = -1,
.sda_io_num = CONFIG_FG_I2C_SDA_GPIO,
.scl_io_num = CONFIG_FG_I2C_SCL_GPIO,
.clk_source = I2C_CLK_SRC_DEFAULT,
.glitch_ignore_cnt = 7,
.flags.enable_internal_pullup = true, // breakouts normally fit their own pull-ups as well
};
i2c_master_bus_handle_t bus;
ESP_ERROR_CHECK(i2c_new_master_bus(&bus_cfg, &bus));
i2c_device_config_t dev_cfg = {
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.device_address = SHT4X_ADDR,
.scl_speed_hz = 100000,
};
i2c_master_dev_handle_t dev;
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus, &dev_cfg, &dev));
uint8_t cmd = SHT4X_CMD_MEASURE_HI;
uint8_t raw[6] = {0};
esp_err_t err = i2c_master_transmit(dev, &cmd, 1, 50);
if (err == ESP_OK) {
vTaskDelay(pdMS_TO_TICKS(SHT4X_MEAS_HI_MAX_MS + 1));
err = i2c_master_receive(dev, raw, sizeof raw, 50);
}
if (err == ESP_OK && !sht4x_decode(raw, t, rh)) {
err = ESP_ERR_INVALID_CRC;
}
i2c_master_bus_rm_device(dev);
i2c_del_master_bus(bus);
return err;
}
The publish step waits for the connection, publishes at QoS 1 and waits for the acknowledgement, each with a deadline:
// target: esp32c5 sdk: esp-idf tier: 1
// ...
static bool mqtt_publish_once(const char *topic, const char *payload)
{
esp_mqtt_client_config_t cfg = {
.broker.address.uri = MQTT_URI,
.credentials.username = MQTT_USER,
.credentials.authentication.password = MQTT_PASS,
.session.keepalive = 30,
};
esp_mqtt_client_handle_t c = esp_mqtt_client_init(&cfg);
esp_mqtt_client_register_event(c, ESP_EVENT_ANY_ID, on_mqtt, NULL);
esp_mqtt_client_start(c);
bool ok = false;
EventBits_t b = xEventGroupWaitBits(s_ev, BIT_MQTT_UP | BIT_MQTT_FAIL, pdFALSE, pdFALSE,
pdMS_TO_TICKS(CONFIG_FG_MQTT_TIMEOUT_MS));
if (b & BIT_MQTT_UP) {
// QoS 1: wait for the broker's PUBACK before switching the radio off.
esp_mqtt_client_publish(c, topic, payload, 0, 1, 0);
b = xEventGroupWaitBits(s_ev, BIT_PUBLISHED | BIT_MQTT_FAIL, pdFALSE, pdFALSE,
pdMS_TO_TICKS(CONFIG_FG_MQTT_TIMEOUT_MS));
ok = (b & BIT_PUBLISHED) != 0;
}
esp_mqtt_client_disconnect(c);
esp_mqtt_client_stop(c);
esp_mqtt_client_destroy(c);
return ok;
}
static void sleep_now(void)
{
esp_wifi_stop();
ESP_LOGI(TAG, "sleeping %d s", CONFIG_FG_SLEEP_SECONDS);
esp_sleep_enable_timer_wakeup((uint64_t)CONFIG_FG_SLEEP_SECONDS * 1000000ULL);
esp_deep_sleep_start();
}
The main function ties the steps together. Note esp_sleep_get_wakeup_causes(): ESP-IDF v6.1.1 marks the older single-cause esp_sleep_get_wakeup_cause() as deprecated.
// target: esp32c5 sdk: esp-idf tier: 1
// ...
void app_main(void)
{
s_ev = xEventGroupCreate();
uint32_t causes = esp_sleep_get_wakeup_causes();
ESP_LOGI(TAG, "boot, seq %lu, timer wake %d", (unsigned long)s_seq,
(causes & BIT(ESP_SLEEP_WAKEUP_TIMER)) != 0);
// Measure before the radio starts, so its heat and supply dip do not reach the reading.
float t = 0, rh = 0;
esp_err_t serr = read_sht45(&t, &rh);
int vbat_mv = -1;
#if CONFIG_FG_VBAT_ADC
vbat_mv = read_vbat_mv();
#endif
esp_err_t nerr = nvs_flash_init(); // Wi-Fi driver needs NVS for calibration data
if (nerr == ESP_ERR_NVS_NO_FREE_PAGES || nerr == ESP_ERR_NVS_NEW_VERSION_FOUND) {
nvs_flash_erase();
nvs_flash_init();
}
if (!wifi_up()) {
ESP_LOGW(TAG, "no Wi-Fi within %d ms", CONFIG_FG_WIFI_TIMEOUT_MS);
sleep_now();
}
uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_WIFI_STA);
char id[13], topic[48], payload[200];
snprintf(id, sizeof id, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
snprintf(topic, sizeof topic, "fieldguide/env/%s", id);
wifi_ap_record_t ap = {0};
esp_wifi_sta_get_ap_info(&ap);
long awake_ms = (long)(esp_timer_get_time() / 1000);
if (serr == ESP_OK) {
snprintf(payload, sizeof payload,
"{\"id\":\"%s\",\"seq\":%lu,\"t_c\":%.2f,\"rh\":%.1f,\"vbat_mv\":%d,\"rssi\":%d,\"awake_ms\":%ld}",
id, (unsigned long)s_seq, t, rh, vbat_mv, ap.rssi, awake_ms);
} else {
snprintf(payload, sizeof payload,
"{\"id\":\"%s\",\"seq\":%lu,\"error\":\"%s\",\"vbat_mv\":%d,\"rssi\":%d,\"awake_ms\":%ld}",
id, (unsigned long)s_seq, esp_err_to_name(serr), vbat_mv, ap.rssi, awake_ms);
}
bool ok = mqtt_publish_once(topic, payload);
ESP_LOGI(TAG, "%s %s -> %s", ok ? "published" : "publish FAILED", topic, payload);
s_seq++;
sleep_now();
}
Credentials live in main/secrets.h, which git ignores. Copy main/secrets.h.example and fill in your Wi-Fi network, broker URI and MQTT user. Without secrets.h the build still succeeds with placeholder values, which is how CI builds it, and prints a compiler message to say so.
On the XIAO you can switch on CONFIG_FG_VBAT_ADC to report the battery voltage. The firmware drives GPIO26 high to connect the board’s 1:2 divider (two 100 kΩ resistors), reads GPIO6 eight times through the calibrated ADC (analogue-to-digital converter) and doubles the result. The divider is disconnected again before sleep so it does not drain the cell. Leave the option off on the DevKitC-1, which has no such divider. When it is off, vbat_mv reads -1.
Back end
Mosquitto 2 refuses anonymous clients once a listener is configured, and this file makes that explicit:
# Mosquitto 2.x broker for the sensors on your LAN. Create the password file first:
# mosquitto_passwd -c /etc/mosquitto/passwd sensor
listener 1883
allow_anonymous false
password_file /etc/mosquitto/passwd
The logger subscribes to fieldguide/env/+, writes one CSV row per message and reports a gap when a sequence number is skipped. A sequence number that goes down means the board lost power and restarted from 0, which is not counted as a gap.
# target: host sdk: python tier: 2
"""Subscribe to the environment sensors and append each reading to a CSV file.
Run from the repo root:
python examples/c5-battery-environment-sensor/host/logger.py --host 192.168.1.10 --csv env.csv
Credentials come from MQTT_USER / MQTT_PASS in the environment (or a .env you source), never from code.
"""
from __future__ import annotations
import argparse
import csv
import json
import os
import time
from pathlib import Path
import paho.mqtt.client as mqtt
TOPIC = "fieldguide/env/+"
FIELDS = ["received_utc", "id", "seq", "t_c", "rh", "vbat_mv", "rssi", "awake_ms", "error", "gap"]
class Logger:
"""Turns MQTT messages into CSV rows and flags gaps in the per-device sequence numbers."""
def __init__(self, csv_path: Path) -> None:
self.csv_path = csv_path
self.last_seq: dict[str, int] = {}
new = not csv_path.exists()
self._fh = csv_path.open("a", newline="")
self._w = csv.DictWriter(self._fh, fieldnames=FIELDS)
if new:
self._w.writeheader()
def handle(self, payload: bytes) -> dict | None:
try:
msg = json.loads(payload)
except ValueError:
return None
if not isinstance(msg, dict) or "id" not in msg or "seq" not in msg:
return None
dev, seq = str(msg["id"]), int(msg["seq"])
prev = self.last_seq.get(dev)
# seq lives in LP memory: it restarts at 0 after a power cut, which is not a gap.
gap = 0 if prev is None or seq <= prev else seq - prev - 1
self.last_seq[dev] = seq
row = {k: msg.get(k, "") for k in FIELDS}
row.update(received_utc=time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), id=dev, seq=seq, gap=gap)
self._w.writerow(row)
self._fh.flush()
return row
def close(self) -> None:
self._fh.close()
def make_client(logger: Logger, client_id: str = "fg-env-logger") -> mqtt.Client:
c = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id=client_id)
if os.environ.get("MQTT_USER"):
c.username_pw_set(os.environ["MQTT_USER"], os.environ.get("MQTT_PASS"))
c.on_connect = lambda cl, ud, flags, rc, props: cl.subscribe(TOPIC, qos=1)
def on_message(cl, ud, m):
row = logger.handle(m.payload)
Run it with MQTT_USER and MQTT_PASS set in the environment:
python examples/c5-battery-environment-sensor/host/logger.py --host 192.168.1.10 --csv env.csv
For Home Assistant, add this to configuration.yaml after setting up the MQTT integration with the same broker. expire_after marks a sensor unavailable when it stops reporting. Home Assistant’s documentation advises against retained messages with expire_after, and the firmware does not retain.
# Home Assistant configuration.yaml entry for one sensor. Replace aabbccddeeff with the id
# the firmware prints (its Wi-Fi MAC address without colons).
# expire_after: the sensor reports every 300 s; mark it unavailable after three missed reports.
mqtt:
sensor:
- name: "Env sensor temperature"
unique_id: fg_env_aabbccddeeff_t
state_topic: "fieldguide/env/aabbccddeeff"
value_template: "{{ value_json.t_c }}"
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
expire_after: 960
- name: "Env sensor humidity"
unique_id: fg_env_aabbccddeeff_rh
state_topic: "fieldguide/env/aabbccddeeff"
value_template: "{{ value_json.rh }}"
unit_of_measurement: "%"
device_class: humidity
state_class: measurement
expire_after: 960
- name: "Env sensor battery"
unique_id: fg_env_aabbccddeeff_vbat
state_topic: "fieldguide/env/aabbccddeeff"
value_template: "{{ value_json.vbat_mv }}"
unit_of_measurement: "mV"
device_class: voltage
state_class: measurement
expire_after: 960
Enclosure
The matching Build is the battery pack enclosure. As designed today it holds a Keystone 2465 holder for three AA cells with wire leads, plus strain relief for the lead to the sensor. It does not take a lithium cell, and three AA cells must not go on the XIAO’s battery pads. So it fits this project only once a supply suitable for three AA cells is chosen (see “Things to try”). For the Li-ion build, keep the cell and the board in a vented housing, keep the SHT45 away from the board’s regulator and the cell, and keep anything metal clear of the antenna. A Li-ion variant of the battery pack is a request to the Build backlog.
Build and flash
With ESP-IDF v6.1.1 installed, or with the same Docker image that CI uses:
cd examples/c5-battery-environment-sensor/firmware
cp main/secrets.h.example main/secrets.h # then edit it
idf.py set-target esp32c5
idf.py menuconfig # optional: Field Guide environment sensor
idf.py build flash monitor
The XIAO’s USB serial port disappears while the board is in deep sleep (Seeed notes this), so a sleeping board cannot be flashed. Put it into download mode with its Boot button as Seeed’s wiki describes. On the DevKitC-1 v1.2, use the USB-to-UART port for monitor: the bridge is a separate chip (a CP2102N by default), so its port stays when the ESP32-C5 sleeps.
Test
What working looks like on the serial console, one cycle every 300 s. The lines follow the firmware’s log format. The values in angle brackets are whatever your board reports:
I (<ms>) fg_env: boot, seq <n>, timer wake 1
I (<ms>) fg_env: published fieldguide/env/<id> -> {"id":"<id>","seq":<n>,"t_c":<t>,"rh":<rh>,"vbat_mv":-1,"rssi":<dBm>,"awake_ms":<ms>}
I (<ms>) fg_env: sleeping 300 s
On the logger side, each wake adds one row to the CSV with gap 0. The tier this page has reached:
- Tier 1 (builds in CI): the firmware builds for
esp32c5inespressif/idf:v6.1.1throughtools/ci/check_example.py. - Tier 2 (runs in CI):
host/sht4x_host_test.pycompilessht4x.con the host and checks the CRC against the datasheet example (CRC of 0xBEEF is 0x92) and both conversion formulas.host/logger_test.pyruns the logger against a throwaway local Mosquitto broker, publishes three device-shaped messages and one malformed one, and checks the rows, the gap count and the error row. - Tier 3 (tested on hardware): waiting for the owner’s bench run on an ESP32-C5-DevKitC-1 v1.2. The commands are:
python tools/bench/bench.py flash --port <port> --example c5-battery-environment-sensor --target esp32c5
python tools/bench/bench.py capture --port <port> --seconds 20 --reset --expect examples/c5-battery-environment-sensor/bench/expect.txt --board-rev "ESP32-C5-DevKitC-1 v1.2" --example c5-battery-environment-sensor --target esp32c5
The expectation file asks for the boot line, a published message with a temperature and humidity, and the sleep line, and fails on a failed publish or a CRC error. Until that run is committed this page shows tier 1, the lowest tier any part has reached.
For makers
Start on the DevKitC-1 over USB, confirm messages arrive in logger.py, then move the firmware to the XIAO and the cell. Look at awake_ms in the CSV after a day: it tells you more about battery life than any datasheet figure. If your access point is far away, a longer report period saves more than any code change.
For product teams
Switch the broker to mqtts:// with a CA certificate and per-device credentials before anything leaves the bench, and plan for the TLS handshake in the awake time. Budget the whole board, not the chip: charger, regulator, LEDs and dividers. Note that ESP-IDF v6.1 disabled ECDSA Secure Boot V2 on the ESP32-C5 because of a vulnerability, so check the chip errata and pick the secure boot scheme before production. The ESP32-C5 datasheet also asks for a supply that can deliver at least 0.6 A, which matters when you choose a regulator for a bare cell.
Things to try
- Measure the real awake time. Plot
awake_msfrom the CSV, then replaceduration_sin the power profile with your median and run the script again. - Lower-energy reading. The SHT45 also has medium and low repeatability commands (0xF6, 0xE0) with shorter measurement times. At one reading every five minutes the sensor’s share of the budget is already tiny, so this matters less than Wi-Fi time.
- Condensation. The SHT4x has an on-chip heater (up to 60 mA typical at its 200 mW setting). A short heater pulse before a reading can dry the sensor in a damp enclosure. Never run it on every wake from a small cell.
- Three AA cells. The battery pack enclosure holds three AA cells in series. Driving an ESP32-C5 from them needs a regulator that delivers 3.0 V to 3.6 V across the whole discharge curve and at least 0.6 A. We have not yet chosen and tested one, so we give no wiring for it here.
- Static IP address. Skipping DHCP (Dynamic Host Configuration Protocol) can shorten each wake. Measure before and after.
Summary
- The sensor wakes on a timer, reads the SHT45 before the radio starts, publishes one QoS 1 message and sleeps, with a deadline on every network step.
- With ESP-IDF v6.1 the MQTT client is the managed component
espressif/mqtt, so pin it inidf_component.yml. - The SHT4x CRC and conversions are tested on the host against the datasheet, and the logger is tested against a local broker.
- The awake phase dominates the energy budget, and the board’s own parts are not in the chip datasheet, so the battery figures here are an upper bound until the Lab measures the board.