Reference for the CST Temp Module's LTC2983 front end: how it is wired, how it is configured, why each choice was made, and what the diagnostic entities mean.
Implementation lives in ltc2983_handler.h; entities are declared in
LTC2983_Temp_Module.yaml.
This is the validated bench configuration: all ten sensors installed and individually heat-tested. Treat it as the reference.
Chip: Analog Devices LTC2983 — 20-channel direct-to-digital temperature measurement IC with a 24-bit delta-sigma ADC, per-channel sensor configuration, built-in linearization for standard sensor types, and per-conversion fault reporting.
Host: ESP32-S3 (N16R8), ESP-IDF framework, ESPHome.
| Signal | GPIO |
|---|---|
| CS | 2 |
| SCK | 9 |
| MOSI | 5 |
| MISO | 4 |
Host is SPI2_HOST, mode 0, DMA disabled, input_delay_ns = 200.
Chip select is driven manually rather than by the SPI peripheral
(spics_io_num = -1), so a whole multi-byte register transaction stays inside
one CS assertion.
| Channel | Sensor | Notes |
|---|---|---|
| CH1–CH2 | 2 kΩ 1% RSENSE | Shared reference resistor for all five RTDs |
| CH4, CH6, CH8, CH10, CH12 | PT1000 RTD ×5 | 2-wire |
| CH13–CH17 | Type-K thermocouple ×5 | Single-ended, TC− → COM |
| CH20 | 2N3906 diode | Cold junction compensation for all TCs |
RTD return legs land on the odd channel below each RTD (CH3/5/7/9/11), all tied to CH2 — the top of the shared RSENSE.
CH1 is left floating, and must stay that way. Grounding CHRSENSE−1 is only correct when RSENSE is not shared. Because sharing is enabled (B18 = 1 in the RTD assignment), grounding CH1 would break every RTD measurement. This was tested and confirmed.
TC− leads and the CJC diode's base/collector both return to COM, and COM is tied to board ground.
Values below are the exact 32-bit words written to 0x0200 + (ch-1)*4, and are
what the firmware verifies on every scan.
| Channel | Word | Meaning |
|---|---|---|
| CH2 (RSENSE) | 0xE81F4000 |
Type 0x1D, 2000.000 Ω (B26:B0 at 1/1024 Ω) |
| RTDs | 0x78858000 |
PT1000, RSENSE on CH2, 2-wire, shared RSENSE, 250 µA, European curve |
| TCs | 0x15300000 |
Type-K, CJC on CH20, single-ended, open-circuit detect on, 10 µA test current |
| CH20 (CJC) | 0xE7C00000 |
Diode, single-ended, 3 conversion cycles, averaging on, 80 µA |
RSENSE tolerance lands directly on every RTD reading. The 2000.000 Ω constant
assumes an ideal resistor. Measuring the installed part with a DMM and writing
that value into CFG_RSENSE removes its tolerance error from all five RTDs.
RTD excitation is 250 µA, raised from the original 100 µA. More current means more signal across the RTD for the same noise floor. Self-heating in a PT1000 at 250 µA is negligible (62.5 µW at 0 °C).
Diode ideality factor is left at zero. Datasheet Table 20: all zeros selects the factory default of 1.003, which is correct for the 2N3906.
Thermocouples use open-circuit detection. The chip pushes 10 µA through the junction and flags a break, which is why an unwired TC channel reports a fault rather than a plausible-looking room temperature.
| Register | Value | Why |
|---|---|---|
0x00F0 global config |
0x01 |
120 dB rejection at 60 Hz. The default 0x00 is simultaneous 50/60 Hz at only 75 dB. This board runs on US mains near motor and igniter loads, so trading unused 50 Hz rejection for 45 dB more at 60 Hz is free accuracy. |
0x00FF MUX settle |
0x00 |
No extra settling. Inputs carry only ~100 pF, well inside the chip's internal 2 ms. |
Conversions are started one channel at a time (0x80 | ch) rather than as a
multi-channel batch. Batch conversions were tried and proved unreliable on this
board; per-channel keeps each SPI transaction short and independent.
Every conversion result carries a fault byte in D31:D24. The original firmware decoded these incorrectly — it invented "Open Circuit" and "Short to VDD" codes that do not exist in the datasheet, and never examined three of the bits at all. Decoding now follows datasheet Table 10 exactly.
| Bit | Meaning | Severity |
|---|---|---|
| D31 | Sensor hard fault — open, shorted, or backwards sensor | Hard |
| D30 | ADC hard fault | Hard |
| D29 | Cold junction hard fault | Hard for TCs only |
| D28 | Cold junction soft fault | Soft |
| D27 | Sensor over range | Soft |
| D26 | Sensor under range | Soft |
| D25 | ADC out of range (|Vin| > 1.125 × VREF/2) | Soft |
| D24 | Result valid — cleared means the whole word is meaningless | Hard |
There is no dedicated open-circuit bit. An open sensor appears as sensor hard fault plus over range.
Hard vs soft matters. A hard fault means the chip returned −999 °C and the value must be discarded. A soft fault means the number is usable but its accuracy is degraded — it is published and logged as degraded, rather than thrown away.
D29 is hard for thermocouples only. Every TC result depends on the cold junction, so a CJC hard fault invalidates all five; it does not affect RTDs.
This fix has already caught real events. A transient reading of 1853 °C — past Type-K's 1372 °C ceiling — was correctly rejected as over range. Under the old decoder that would have been published to Home Assistant as 3367 °F.
A second gate on top of fault decoding, in case a fault-free but nonsensical value appears:
| Kind | Accepted range |
|---|---|
| RTD | −50 °C to 300 °C |
| Thermocouple | −200 °C to 1370 °C |
| CJC diode | −40 °C to 125 °C |
The LTC2983's SPI has no framing, parity, or checksum. It acts on whatever it decodes. When a contact bounces mid-transaction, clock edges are added or dropped and the byte stream shifts — a corrupted write then lands at the wrong address with the wrong payload. Because the channel assignment registers occupy a large contiguous block, a garbled write has a good chance of landing in one and zeroing it.
An unassigned channel returns −999.5 °C (0xF06400) with every fault bit set. It
does not time out and SPI keeps working, so nothing else flags it. The channel
simply reports a hard fault forever until someone rewrites the register.
This was observed repeatedly on the bench with a temporary SPI connector: at
least six chip-state corruption events in a single session, plus one case where
the chip stopped responding entirely (status = 0x00).
Reads are verified by agreement. Every register read this way holds still between conversions, so two consecutive reads must return identical bytes. A disagreement means the bus corrupted one of them and neither can be trusted — up to 3 attempts, then the channel is blanked rather than publishing one of the disagreeing samples. This is the direct defence against corrupted reads that happen to land in a plausible temperature range, which were previously indistinguishable from real data.
Writes are read back and retried. Nothing is assumed to have stuck until the chip confirms it holds the value we sent. Up to 3 attempts.
All twelve assignment registers are verified, continuously. The channel about to be converted has its assignment checked immediately beforehand, so a full scan covers every register. RTD channels additionally verify the shared RSENSE they all depend on. (The earlier version checked only CH4, so corruption on any other channel would have gone unnoticed indefinitely.)
Transfer errors are no longer silent. spi_device_polling_transmit return
values are checked, and a null device handle is guarded rather than dereferenced.
A floating bus cannot impersonate a status byte. 0x00 and 0xFF are both
impossible for a live chip and are exactly what a disconnected MISO returns, so
they are rejected explicitly.
A failed reconfigure stays offline. If the bus is too corrupt to write a verified configuration, everything blanks rather than running against unknown chip state.
One extra register read per conversion. A full 11-channel scan spends roughly 15 ms transferring data out of about 5.5 s wall time — under 1% duty cycle.
250 kHz, deliberately slow. The chip handles 2 MHz on a clean board, but this one reaches the LTC2983 over unshielded leads with no ground plane between them, and slow edges buy noise margin.
Raising the clock buys nothing measurable. Every transaction is 4–7 bytes; a full scan is ~15 ms of wire time inside a 5.5 s cycle. Going to 2 MHz would save about 13 ms out of 5.5 s while making edges eight times faster in exactly the conditions that produce corruption.
The refresh rate is set by the tick interval, not the clock. The state machine advances one step per 250 ms tick and each channel needs about two ticks. The chip's own conversion is ~82 ms with 60 Hz-only rejection, so most of each tick is spent waiting. If faster updates are ever needed, lower the interval in the YAML — 100 ms would still clear the conversion and bring a full scan to ~2.2 s, with no effect on signal integrity.
The scan is a tick-driven state machine (ST_SPI_SETUP → ST_WAIT_READY →
ST_START_CONV → ST_WAIT_CONV), advanced one step per 250 ms interval from the
YAML.
The earlier implementation ran all 11 conversions inline and stalled the ESPHome main loop for ~2.9 s per scan, which starved the API and WiFi components. Each tick now costs only a few SPI byte transfers.
Recovery behaviour:
- Conversion timeout — channel publishes unknown with
Timeout; three consecutive timeouts force a full SPI re-init. - Chip not ready past ~10 s — all channels blank with
Chip Offline, bus is torn down and rebuilt. - Assignment corruption — chip is reconfigured, counter increments.
Channels are blanked as a group on an outage so the dashboard shows a consistent unknown state rather than a mix of frozen readings and stale faults.
RTD CH4, RTD CH6, RTD CH8, RTD CH10, RTD CH12,
TC1–TC5, Cold Junction.
The five RTD and five TC slots are permanent and must never be trimmed, even if a channel is unused — an unwired channel reports a fault and publishes no value, which is the intended behaviour.
Cold Junction is exposed because it feeds every thermocouple result. If it
drifts or faults, all five TCs are wrong with it.
Fault RTD CH4…Fault RTD CH12, Fault TC1…Fault TC5,
Fault Cold Junction.
Values: OK, Sensor Hard Fault, ADC Hard Fault, CJ Hard Fault,
CJ Soft Fault, Over Range, Under Range, ADC Out of Range, Timeout,
Invalid, Chip Offline.
| Entity | Type | Meaning |
|---|---|---|
LTC2983 SPI Errors |
counter | Failed or disagreeing SPI transfers since boot |
LTC2983 Config Reloads |
counter | Times chip state was found corrupt and rewritten |
LTC2983 Link |
text | Online / Online (degraded) / Fault / Offline |
These exist because a degrading connection is invisible until it starts costing readings. The counters climb while temperatures still look perfectly fine, which gives warning that a connector or solder joint is going before data starts dropping out.
Recommended alerting:
LTC2983 Linkanything other thanOnline— investigate.LTC2983 SPI Errorsrising during normal operation — the wiring is degrading. Flat is the expected steady state.LTC2983 Config Reloadsnon-zero — chip state is being corrupted. Should be zero on a healthy installation.
Verified on the bench: unplugging and reseating the SPI connector produced 33 SPI errors, 2 config reloads, 1 rejected reading, and zero false temperatures published.
All ten sensors installed, each heated individually with a heat gun.
| Channel | Idle | Peak | Rise |
|---|---|---|---|
| CH4 | 89.6 °F | 272.3 °F | +183 |
| CH6 | 85.8 °F | 260.9 °F | +175 |
| CH8 | 81.4 °F | 209.6 °F | +128 |
| CH10 | 81.1 °F | 224.8 °F | +144 |
| CH12 | 84.3 °F | 257.2 °F | +173 |
While each channel was at 200–270 °F, every other channel stayed within its noise floor. Idle noise is 0.06–0.20 °F per channel.
Thermocouple isolation was specifically tested, because all probes are grounded-junction types bonded to a common steel structure. Heating one TC by 197 °F moved three of the other four by less than 1 °F. The fourth moved 3.9 °F, and the ratio climbed as the heated probe cooled — the signature of lagging thermal mass, not electrical coupling, which would be instantaneous. The cold junction diode, whose only possible response path is electrical, moved 0.2 °F.
Conclusion: the junctions behave as electrically isolated. Ungrounded probes are not required. An earlier suspicion of a ground loop was traced to a multimeter's own test current being injected into the shared TC− return during a resistance measurement; the steel enclosure measures 0.0 mV to board ground.
Resolved:
- CH17 dead — defective LTC2983. Replaced. Not a configuration problem; the same firmware worked on a dev board.
- CH12 unstable / bogus readings — resolved by correct fault decoding, 60 Hz rejection, raised excitation current, and a reliable SPI connection.
- Main loop stalls of ~2.9 s — replaced blocking scan with the state machine.
- Chip losing configuration — root-caused to SPI corruption from a bad connector; now detected and repaired automatically, and counted.
Open:
- The bench SPI connector is temporary and bounce-prone. Production hardware uses a solid connection. Watch the SPI error counter after installation to confirm.
vl53l0xpellet level sensor fails I²C setup (setup timeout). Unrelated to the temperature path.
# Flash over OTA, debug over USB-C.
esphome run LTC2983_Temp_Module.yaml --device cst-temp-module.local
esphome logs LTC2983_Temp_Module.yaml --device /dev/cu.wchusbserial*Build cache is /tmp/esphome-build/cst-temp-module. Do not delete it —
incremental compiles depend on it. A secrets.yaml is required at the repo
root; it is gitignored.
There is no BLE on this device. It is an IO module; WiFi/API is the transport and USB-C is for logs.