Firmware for a Wemos D1 mini (ESP8266) with an Adafruit SHT40 and up to three DS18B20 temperature probes. Its MQTT and Home Assistant conventions follow the feather-esp32s3-solar-wx-station project: retained status and device inventory, non-retained JSON state, and retained Home Assistant discovery.
Initial release: v0.1.0
| SHT40 | Wemos D1 mini | ESP8266 GPIO |
|---|---|---|
| VIN | 3V3 | — |
| GND | G | — |
| SDA | D2 | GPIO4 |
| SCL | D1 | GPIO5 |
STEMMA QT and Qwiic both carry I2C, but verify the cable's wire order if mixing connector brands. Power this sensor from 3.3 V.
| DS18B20 wire | Wemos D1 mini |
|---|---|
| VDD, normally red | 3V3 |
| GND, normally black | G |
| DATA, normally yellow/white | D5 / GPIO14 |
Connect all three probes in parallel. Add one 4.7 kΩ pull-up resistor between DATA and 3V3 near the Wemos. Use normal three-wire powered mode rather than parasite power. Probe cable colors are not standardized, so confirm them from the probe vendor.
The Wemos D1 mini uses 3.3 V logic. Do not put 5 V on D1, D2, or D5.
- Install PlatformIO in VS Code or use PlatformIO Core.
- Copy
include/secrets.example.htoinclude/secrets.h. - Enter the Wi-Fi and MQTT settings in
include/secrets.h. - Optionally change
MQTT_BASE_TOPIC, reporting interval, or probe names ininclude/config.h. - Connect the Wemos by USB and run
pio run --target upload. - View startup and readings with
pio device monitor.
Home Assistant MQTT discovery must be enabled. The device uses these topics:
| Purpose | Topic | Retained |
|---|---|---|
| State | sensors/attic01/environment/state |
No |
| Availability/LWT | sensors/attic01/environment/status |
Yes |
| Device inventory | sensors/attic01/environment/device_info |
Yes |
| Device inventory status | sensors/attic01/environment/device/availability |
Yes |
| Discovery | homeassistant/sensor/attic01_environment_*/config |
Yes |
On startup, the serial monitor prints each probe's unique 16-character ROM address. The firmware sorts these addresses so Air Handler Probe 1, 2, and 3 remain stable across restarts. Before permanently mounting them:
- Connect all probes and note the three serial addresses.
- Warm one probe by hand while watching MQTT or Home Assistant.
- Label that physical probe with its entity number.
- Repeat for the other two probes.
If a probe is replaced with a different ROM address, re-identify the physical ordering. To use location-specific names such as “Return Air” or “Supply Air,” edit DS18B20_NAMES in include/config.h before uploading.
{
"attic_temperature": 31.42,
"attic_humidity": 58.17,
"air_handler_1": 19.31,
"air_handler_2": 14.88,
"air_handler_3": 24.56,
"rssi": -57,
"uptime_seconds": 3600
}Temperatures are reported in Celsius; Home Assistant can display them in the unit configured for the system.