ESP ZeroCode AI · Community

Wiring diagram for Soil Temp Probe Using Zigbee

Soil Temp Probe Using Zigbee

a sensor using Zigbee to measure soil temperature

ESP32-C6 zigbee
Download the firmware Open-source licences Fork it in the studio

What it does

Manual

Device Type
A battery-powered Zigbee soil temperature probe. It sits buried in a bed or planter, wakes on its own every 15 minutes to read a PT100 RTD element through a MAX31865 front-end, and reports to a Zigbee coordinator only when the soil temperature has actually moved, plus an hourly heartbeat. Purpose: give a garden, greenhouse or planter a reliable soil-temperature number in whatever Zigbee dashboard the user already has, on one battery charge for a season.

Hardware
chip: esp32c6 — board: Seeed XIAO ESP32C6 (xiao-esp32-c6) — gpios: gpio: 22 — role: MAX31865 front-end power gate (load-switch / P-MOSFET enable) — net: signal · gpio: 18 — role: MAX31865 SDO (SPI MISO) — net: spi · gpio: 19 — role: MAX31865 SCK (SPI clock) — net: spi · gpio: 20 — role: MAX31865 SDI (SPI MOSI) — net: spi · gpio: 21 — role: MAX31865 CS — net: spi · gpio: 0 — role: Battery voltage sense — on-board 1:2 divider from BAT to A0; ADC read only, no external part — net: analog · gpio: 9 — role: On-board BOOT button — long-press factory reset, wake source — net: signal · gpio: 15 — role: On-board user LED — status indication — net: signal — peripherals: name: PT100 waterproof soil temperature probe — part: PT100 RTD, 3-wire, stainless sheath, cable potted into the enclosure — interface: Analog resistive element, read through the MAX31865 (not the MCU ADC) — notes: Buried at a fixed depth (typically 10 cm) in the root zone. The probe's three leads land on the MAX31865 screw terminals: two common leads plus the compensation lead. The module must carry the PT100 reference resistor (430 ohms), and the firmware uses 100 ohms nominal with the PT100 Callendar–Van Dusen coefficients. · name: MAX31865 RTD front-end module — part: Adafruit / generic MAX31865 breakout with the PT100 reference resistor fitted (430 ohms), 3.3 V supply — interface: SPI, mode 1, up to 5 MHz — notes: Set to 3-wire mode by the firmware (configuration register). A reading of ~138.5 ohms corresponds to 100 °C at 100 ohms nominal. NOTE: most MAX31865 breakouts ship with the 4.3 kΩ resistor fitted for PT1000 — that resistor must be swapped for 430 ohms (or the PT100 variant bought) or every reading will be off by a factor of ten. The module's VIN is best fed from a GPIO used as a power gate and driven high only during a reading, since its idle draw of about 2 mA would otherwise dominate the battery budget. · name: LiPo cell — part: 3.7 V single-cell LiPo, 1000–2000 mAh, plugged into the XIAO's BAT pads — interface: BAT pads; on-board charge management via USB-C — notes: No fuel gauge. State of charge is derived from the BAT pad voltage through the board's 1:2 divider on A0, using a LiPo discharge curve. This is coarse (a few percent), which is what the Power Configuration cluster needs. — enclosureNotes: Sealed indoor/outdoor housing with a cable gland for the probe lead, mounted above the soil line; the probe cable runs down into the bed. Keep the SPI leads from the front-end to the XIAO under about 10 cm and away from the battery leads.

Inputs
kind: sensor — label: Soil temperature — hardware: PT100 RTD probe through MAX31865 on SPI (CS GPIO21, SCK GPIO19, SDI GPIO20, SDO GPIO18) — behaviour: Sampled once per 15-minute wake. The firmware powers the front-end, discards the first conversion after power-up, then reads one fault-checked conversion, converts resistance to °C with the PT100 (Callendar–Van Dusen) coefficients, and rounds to 0.01 °C. A front-end fault bit (open/short lead) is treated as an invalid sample and no report is made; the fault is logged and the next wake retries. · kind: sensor — label: Battery level — hardware: On-board divider from the BAT pad to A0 (GPIO0), read with the ADC — behaviour: Multi-sampled and averaged at each wake; converted to a percentage via a LiPo curve. Reported at commissioning, then only every 6 hours or when the percentage moves by 1 point. Below 20 % the device sets the battery-low flag on the Power Configuration cluster; below 3.4 V it stretches the wake interval to 30 minutes to extend runtime. · kind: button — label: BOOT button (GPIO9) — hardware: On-board user button, active low, also an RTC/GPIO deep-sleep wake source — behaviour: Held 5 s → factory reset (leave network, clear Zigbee NV state, restart network steering). Held 1 s and released while unpaired → restart a join attempt immediately instead of waiting for the next wake. Everyday presses of under a second do nothing.

Outputs
kind: indicator — label: Status LED (GPIO15, on-board user LED) — hardware: Single-colour on-board LED, active low on this board — behaviour: Off in normal operation (an LED left on would dominate the power budget). While unpaired: a short double-blink at each join attempt. On a successful join: solid on for 2 s. On an RTD front-end fault: three fast blinks at the wake where the fault was seen. During the 5 s reset hold: blinks at 2 Hz so the user gets feedback that the press is registering. · kind: actuator — label: RTD front-end power gate — hardware: MAX31865 VIN fed from GPIO22 through a small P-MOSFET / load switch (or the module's own enable pin) — behaviour: Driven high a few milliseconds before a conversion and off immediately after, so the front-end's ~2 mA idle current does not run between wakes. GPIO22 was picked because it is a plain free IO pad on the XIAO ESP32C6 — no strapping or boot role — and nothing else in this design needs it.

Connectivity
stack: zigbee — transport: 802.15.4, 2.4 GHz — purpose: Sleepy end device on an existing Zigbee network. Implements the HA Temperature Sensor device type (0x0302) with the Temperature Measurement cluster (0x0402) and the Power Configuration cluster (0x0001) on the same endpoint, plus the Basic cluster reporting manufacturer/model. MeasuredValue is int16 in 0.01 °C; the same value is also served through the Analog Input-style Min/Max/Tolerance attributes only where the coordinator's profile needs them. Configured reporting: minimum interval 900 s, maximum interval 3600 s, reportable change 50 (0.50 °C). Battery attributes: minimum 21600 s, maximum 43200 s, reportable change 1. Poll control: the device does not fast-poll; it is polled by its parent and answers on wake.

Commissioning
method: zigbee network steering (permit-join onboarding) — payload: none — no per-device data to flash; the user provides nothing but the network — instructions: 1) Power the probe (insert the charged LiPo, then plug USB-C once to wake it, or press BOOT briefly). 2) In the Zigbee hub's app, start pairing / permit join. 3) Within the 3-minute permit-join window the probe joins by itself; the user does nothing on the device. 4) The hub discovers it as a temperature sensor with a battery level. 5) Give it a name in the hub and place the probe in the soil — readings appear at the hub within 5 minutes, and no later than the hourly heartbeat. If it does not appear, re-open permit join and press BOOT for 1 s to retry, or hold BOOT 5 s for a clean slate.

Business Logic
powerOnBehavior: On power-up the firmware checks Zigbee NV storage for a previous network. If it finds one, it rejoins its parent network and goes straight into the sleep/sample loop — no button press needed. If it finds none, it enters network steering: LED double-blinks at each attempt and it retries roughly every 5 minutes (with backoff up to 30 minutes) while it has battery, until the network accepts it. The first reading is transmitted immediately after a successful join rather than waiting for the first 15-minute cycle, so the user sees a number right away. — automationRules: Every 15 minutes: wake, read battery, power the RTD front-end, read soil temperature, compare with the last reported value. · If |temperature − last reported| ≥ 0.50 °C → transmit a Temperature Measurement report and store the new value. · If 60 minutes have passed since the last report → transmit regardless of change (heartbeat). · Every 6 hours, or when battery percentage changes by ≥ 1 → transmit a battery report. · If the temperature is unchanged and the heartbeat hour has not elapsed → transmit nothing and return to deep sleep as fast as possible. · If the PT100 read carries a fault bit → do not report a temperature; blink the LED three times and retry at the next wake. · If the battery is under 3.4 V → stretch the wake interval to 30 minutes (heartbeat stays hourly). — dayToDayOperation: The user pairs it once, buries the probe, and then never touches it. In their dashboard the soil temperature appears as an ordinary temperature sensor; it updates within about 15 minutes of any meaningful change in the soil and refreshes at least hourly. The battery percentage shows next to it and drains slowly. A whole season on a mid-size LiPo is the expectation; recharge by USB-C when the hub shows the low-battery flag.

Factory Reset
trigger: Hold the on-board BOOT button for 5 s (LED blinks at 2 Hz while held). — effect: The device leaves the Zigbee network, clears its Zigbee NV state (network key, PAN, short address, coordinator link), reports nothing further until re-paired, and restarts network steering with LED double-blinks. The stored last-reported temperature is cleared, so the first reading after the next join transmits unconditionally. No damage if done by accident — it simply needs pairing again.

Failure Modes
scenario: No Zigbee network present, or nobody opened permit-join — behavior: The device stays unpaired, double-blinking at each attempt and retrying with backoff (5 min up to 30 min). Nothing is reported anywhere. Because each attempt is a short radio burst between deep sleeps, this is survivable for weeks rather than hours, but it is the biggest avoidable battery drain — the spec deliberately sleeps the radio instead of fast-polling. · scenario: Network disappears or the coordinator is off (device already paired) — behavior: The sample-and-report cycle keeps running; the sleep interval is unchanged. Reports fail, so on the next wake the device re-searches for its parent and, if the network is gone, falls back to network steering after a few consecutive failures. It does not clear its NV network state — when the coordinator comes back the device rejoins and resumes without user action, and the next successful report carries the current temperature. · scenario: Probe lead broken, unplugged, or the front-end reports a fault bit — behavior: No temperature is reported for that wake (the last good value stands at the hub, and the hourly heartbeat is skipped rather than reporting a stale number as fresh). The LED blinks three times at that wake so a technician at the enclosure can see it, and each wake retries the read. A persistent open lead shows up at the hub as the sensor going quiet rather than as a wild temperature. · scenario: Battery low or dying — behavior: Under 3.4 V the wake interval stretches to 30 minutes and the battery-low flag is set; under about 3.2 V the device stops reporting entirely rather than browning out mid-transmission. On this board the cell protection circuit and the USB charge path handle the low end, so a depleted probe comes back by plugging in USB-C — it does not need re-pairing, it rejoins its old network on power-up. · scenario: Power blip / brownout during a radio transmission — behavior: Zigbee NV state is committed before the report is sent, so a reset mid-transmission costs one report, not the pairing. The device restarts, rejoins the stored network, and transmits the current reading on the next wake. · scenario: USB-C plugged in for charging while installed — behavior: Charging works independently of the firmware; the device keeps sampling and reporting while charging, and the board's charge path does not require the soil reading to stop. Remove USB when done — the firmware does not need to know the difference.

Power Management
batteryPowered: true — sleepMode: ESP32-C6 deep sleep between readings, with the radio and the RTD front-end both off. Each wake is a few seconds long: ADC battery sample, front-end power-up plus a discarded conversion, one RTD conversion, optional radio transaction, then straight back to deep sleep. Expected average draw is dominated by the 2.4 GHz radio bursts, which the report-on-change plus hourly heartbeat pattern keeps to a handful per hour; a 1000–2000 mAh cell should give months of runtime, and the 15-minute sample interval (rather than a 15-minute report interval) keeps the sampling cost small. — wakeSources: RTC deep-sleep timer — every 900 s (stretched to 1800 s when the battery is under 3.4 V) · GPIO wake on the BOOT button (GPIO9) going low — used for the 5 s factory-reset hold and the 1 s retry-join press

Custom Behavior
Report-on-change rather than report-on-timer: the radio is only powered when the soil actually moved 0.50 °C, with a 60-minute heartbeat to keep the device 'available' at the hub. The threshold and the heartbeat both live on the device, so the hub sees normal Zigbee reporting semantics while the probe's battery spends almost all of its life with no radio at all. The RTD front-end is power-gated per reading for the same reason. The on-board BAT-to-A0 divider is used rather than a fuel gauge, so battery percentage is deliberately coarse (a few points) and should not be treated as a coulomb counter.

Published 18 Nov 2026
Firmware and source licensed Apache-2.0; photos and text CC-BY-4.0.
The firmware includes open-source software — open-source licences and notices; some components may be used only with Espressif chips.
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy