A humidity sensor with a heater can produce a perfectly valid digital reply that is unsuitable for reporting room humidity. This experiment deliberately makes that distinction visible. An original Raspberry Pi Pico asks one exact SHT45 module for a short, low-power heating pulse, records diagnostic readings, and refuses to label them as ambient measurements. Recovery means returning near an earlier observed baseline under an explicit policy. It does not mean proving that the sensor has regained its specified accuracy.
The exact sensor and the question
Use Adafruit product 5665, the SHT45 breakout without the additional protective filter, populated with Sensirion SHT45-AD1B-R2. The bare sensor is a four-contact dual-flat-no-leads (DFN) device: contact 1 is serial data SDA, 2 serial clock SCL, 3 supply VDD and 4 ground VSS. Its supported supply is 1.08–3.6 V. The breakout adds a regulator, bus level shifting, pull-up resistors and decoupling; those additions explain why its VIN input accepts a different supply range. Never infer bare-chip limits from a module connector.
The controller here is the original RP2040 Pico running MicroPython 1.26.0. This is complete raw Inter-Integrated Circuit (I²C) code, without an external sensor library. The address is seven-bit 0x44. No address selection is needed for this exact SHT45. An acknowledged address alone does not authenticate a sensor, and a returned serial number is identification data rather than proof of authenticity. Record the actual board marking and serial in your worksheet.
The current primary datasheet is Sensirion SHT4x version 7.3, June 2026. In particular, use its command table rather than copying a heater command from a different humidity family. This lesson is a controlled thermal-response and data-validity experiment. It is not a cleaning recipe, condensation test or validation of a home climate monitor.
Four wires, one supply choice

| Pico connection | Adafruit 5665 connection | Purpose |
|---|---|---|
| 3V3 OUT, physical pin 36 | VIN | 3.3 V module supply and bus pull-up reference |
| Ground, physical pin 38 | GND | Shared return |
| GP0, physical pin 1 | SDA | I²C0 data |
| GP1, physical pin 2 | SCL | I²C0 clock |
Use the Pico’s Universal Serial Bus (USB) connector as its only power source. Leave the breakout’s regulated 3V output unconnected: it is an output, not a second required input. Keep leads short, around 10 cm for this bench arrangement. The module already has 10 kΩ pull-ups on its clock and data connections. Adding another pair is unnecessary for this one-module 100 kHz bus. Do not connect this arrangement to a separately powered five-volt bus.
No extra heater transistor or heater supply is required. The heating element and its control are inside the sensor. Place the module on a dry, nonconductive support in still indoor air, away from the Pico regulator, breath, fingers and direct sunlight. A warm processor or hand can change the experiment before software ever enables the heater. Learn how supply, ground and pull-up paths work in the electronics lessons before debugging bus errors by changing unrelated components.
What a six-byte reply actually guarantees
Command 0xFD requests a high-precision ordinary measurement. The program waits 10 milliseconds, then reads exactly six bytes: a temperature word, its cyclic redundancy check (CRC), a humidity word, and its CRC. A word contains two bytes in high-byte-first order. The CRC polynomial is 0x31, with starting value 0xFF. Both words must pass; a correct temperature checksum cannot rescue an invalid humidity checksum. The published hexadecimal test vector BEEF → 92 checks the implementation against the manufacturer convention.
The conversions use raw unsigned 16-bit counts: T = −45 + 175 × raw_T / 65535 in degrees Celsius, and RH = −6 + 125 × raw_RH / 65535 in percent relative humidity. The mathematical humidity range extends beyond 0–100%. Preserve that uncropped value in diagnostics so that a boundary condition is visible. The preheat room baseline, however, must contain readings inside 0–100%. Raw conversion endpoints are not a promise of specified sensor operation outside its operating temperature range.
The sensor does not stretch the clock to hold the controller until conversion finishes. Reading too early can fail; a short reply or bus exception ends the session. This program does not reuse an old successful value after a failure. Successful CRC validation detects certain corrupted transfers, but cannot establish that the air sample is representative, that the device is correctly mounted, or that heating has ceased to affect it.
A small heater pulse with a large interpretation problem
Command 0x15 selects the nominal 20 mW, 0.1-second heater setting. The returned measurement is made while the heater is still active. The code waits 120 milliseconds to include the heater interval and conversion allowance. Its result is explicitly labelled HEATER_DIAGNOSTIC_ONLY. It must not enter a room-humidity dashboard as an ordinary observation.
The simple nominal energy calculation is E ≈ P × t = 0.020 W × 0.1 s = 0.002 J, or 2 mJ, excluding additional measurement energy. This does not determine temperature rise: package, board, airflow and heat paths affect the result. A low-power pulse may yield only a small observable change in your fixture. Do not invent a large response, and do not keep increasing power until a graph looks dramatic.
Relative humidity compares water-vapour pressure with the saturation pressure at the sensing temperature. Warming the sensing element can lower its relative-humidity reading while the room’s moisture content remains almost unchanged. The sensor has not established that the room became drier. The manufacturer’s ordinary accuracy figures do not apply to a heated measurement. Recovery after thermal stress is a separate question from whether the six bytes are correctly formatted.
The manufacturer constrains heater duration, duty cycle and operating temperature. This experiment narrows the conditions further: a dry indoor baseline between 0 and 40 °C, exactly one low-power pulse in a run, and at least 60 seconds between trials. The one-run lock is held in memory; resetting the Pico does not maintain a persistent duty-cycle record. Do not repeatedly restart the program to bypass the wait. The 60-second exclusion is an application policy, not a manufacturer guarantee that the sensor is accurate after precisely one minute.
Observe a return; do not automatically re-zero

First collect ten ordinary samples, approximately one second apart. Reject a baseline with temperature span above 0.2 °C or humidity span above one percentage point. A stable observed span is a useful prerequisite, but ten readings do not establish absolute calibration. Save their mean as the reference. Never overwrite it with a later warm value merely to make a recovery test pass.
After heating, keep a ten-observation moving window. Before age 60,000 milliseconds, every result remains THERMALLY_EXCLUDED. After that point, require temperature span no greater than 0.2 °C and humidity span no greater than one percentage point. In addition, every value must lie within ±0.3 °C and ±2 percentage points of the original baseline. Only then return BASELINE_RETURN_CANDIDATE. These thresholds are explicit experiment choices, not copied sensor-accuracy specifications.
Even the candidate retains ambient_temperature_C = None and ambient_RH_percent = None. The program records evidence for an operator; it does not silently promote the candidate into a climate reading. Real room conditions may have changed during the wait. If a door opens and humidity settles at a different level, a stable window may correctly fail the old-baseline comparison. Automatic re-zeroing would conceal this ambiguity.
Recovery has a 180-second age deadline and an independent 181-iteration cap. A backwards clock, invalid observation or exceeded deadline latches a policy failure. The iteration cap bounds a frozen-clock test on the host; it does not repair a malfunctioning physical clock. MicroPython’s wrap-safe ticks_diff handles ordinary counter wrap. The code also locks the heater before sending its command, so a failed read cannot trigger an automatic second pulse.
Complete experiment program
Download the six-article reader archive (ZIP). In tricky-circuit-batch007-campaigns63-68/, the SHT45 files are code/pico-sht45-heater-recovery.py (complete program), code/pico-sht45-heater-recovery-observations-blank.csv (blank observation sheet), images/pico-sht45-heater-recovery.svg (editable wiring) and images/pico-sht45-heater-recovery-recovery.svg (editable recovery plot). The PNG figures are included too.
Save the following as main.py after checking the exact module and wiring. The complete source is included here, including CRC, transfer, conversion, baseline and recovery logic. The returned diagnostic dictionaries can be copied from the read–evaluate–print loop (REPL), the interactive serial console. No network service or hidden library is needed.
"""One low-power SHT45 heater pulse; original Pico / MicroPython1.26.0.
Recovered baseline is a policy candidate, not an ambient-accuracy certificate.
"""
def crc8(data):
crc=0xff
for byte in data:
crc ^= byte
for _ in range(8):
crc=((crc << 1)^0x31)&0xff if crc&0x80 else (crc << 1)&0xff
return crc
def words(frame):
if not isinstance(frame,(bytes,bytearray)) or len(frame)!=6:
raise ValueError('Need exactly 6 bytes')
if crc8(frame[:2])!=frame[2] or crc8(frame[3:5])!=frame[5]:
raise ValueError('Temperature or humidity/serial checksum failed')
return (frame[0] << 8)|frame[1],(frame[3] << 8)|frame[4]
def converted(frame):
t,rh=words(frame)
return -45+175*t/65535,-6+125*rh/65535
class SHT45:
def __init__(self,bus,sleep_ms):
self.bus,self.sleep=bus,sleep_ms
self.heated=False
def transfer(self,command,wait_ms):
if self.bus.writeto(0x44,bytes([command]))!=1:
raise OSError('Command not fully accepted')
self.sleep(wait_ms)
return self.bus.readfrom(0x44,6)
def serial(self):
a,b=words(self.transfer(0x89,10))
return (a << 16)|b
def sample(self):
return converted(self.transfer(0xfd,10))
def heat_once(self,baseline_t):
if self.heated or type(baseline_t) not in (int,float) or not 0 <= baseline_t <= 40:
raise ValueError('Only one pulse in this run, with a 0..40 C baseline')
self.heated=True # Keep locked even if the command or read fails.
return converted(self.transfer(0x15,120)) #20mW/.1s plus conversion allowance.
def stable_reference(samples):
if len(samples)!=10 or any(type(x) not in (int,float) or not 0 <= x <= 40
for t,rh in samples for x in [t]) or any(
type(rh) not in (int,float) or not 0 <= rh <= 100 for t,rh in samples):
raise ValueError('Need 10 valid room-condition pairs')
ts=[t for t,rh in samples];rhs=[rh for t,rh in samples]
if max(ts)-min(ts)>.2 or max(rhs)-min(rhs)>1:
raise ValueError('Baseline observed span too large')
return sum(ts)/10,sum(rhs)/10
class Recovery:
def __init__(self,reference):
self.reference=reference
self.window=[]
self.last=-1
self.failed=False
def feed(self,t,rh,age_ms):
if self.failed:
raise ValueError('Recovery already faulted')
if (type(age_ms) is not int or age_ms<self.last or not 0 <= age_ms <= 180000
or type(t) not in (int,float) or not -40 <= t <= 125
or type(rh) not in (int,float) or not -6 <= rh <= 119):
self.failed=True
raise ValueError('Invalid observation, clock or 180 s recovery deadline')
self.last=age_ms
self.window=(self.window+[(t,rh)])[-10:]
result={'state':'THERMALLY_EXCLUDED','ambient_temperature_C':None,
'ambient_RH_percent':None,'diagnostic_temperature_C':t,
'diagnostic_RH_uncropped':rh,'age_ms':age_ms}
if age_ms<60000 or len(self.window)<10:
return result
ts=[p[0]for p in self.window];rhs=[p[1]for p in self.window]
rt,rrh=self.reference
if (max(ts)-min(ts)<=.2 and max(rhs)-min(rhs)<=1 and
all(abs(x-rt)<=.3 for x in ts) and all(abs(x-rrh)<=2 for x in rhs)):
result['state']='BASELINE_RETURN_CANDIDATE'
return result
def experiment(sensor,ticks_ms,ticks_diff,sleep_ms,emit=print):
serial=sensor.serial()
base=[]
for _ in range(10):
base.append(sensor.sample());sleep_ms(1000)
ref=stable_reference(base)
emit({'state':'PREHEAT_REFERENCE','serial':serial,'reference':ref,
'serial_authentication':False})
start=ticks_ms()
heated=sensor.heat_once(ref[0])
emit({'state':'HEATER_DIAGNOSTIC_ONLY','diagnostic_temperature_C':heated[0],
'diagnostic_RH_uncropped':heated[1],'ambient_RH_percent':None})
policy=Recovery(ref)
for _ in range(181):
sleep_ms(1000)
t,rh=sensor.sample()
row=policy.feed(t,rh,ticks_diff(ticks_ms(),start))
emit(row)
if row['state']=='BASELINE_RETURN_CANDIDATE':
return row
raise OSError('Recovery iteration cap; ambient result unknown')
def main():
from machine import Pin,I2C
from time import sleep_ms,ticks_ms,ticks_diff
bus=I2C(0,sda=Pin(0),scl=Pin(1),freq=100000)
try:
experiment(SHT45(bus,sleep_ms),ticks_ms,ticks_diff,sleep_ms)
except (OSError,ValueError) as error:
print({'state':'SESSION_FAULT','ambient_RH_percent':None,'error':str(error)})
if __name__=='__main__':main()
A reproducible observation procedure
- With power disconnected, check the four connections and leave the module’s 3V output open. Record module identity, firmware version, position, approximate room conditions and any independent reference instrument.
- Start with the heater off and the module dry. Let the fixture stop changing after handling. Run the program once. It must gather the ten-value preheat baseline before emitting a reference and serial number.
- Copy the diagnostic heater reply and every recovery row into the blank worksheet. Use a stopwatch if comparing with an independent sensor; the software age is elapsed controller time, not a calibrated timing measurement.
- Record whether the run produced a baseline-return candidate, a stable but shifted environment, a timeout or another fault. Do not fill missing ambient fields with the last baseline value.
- Wait at least 60 seconds before a later trial, and longer if ordinary readings have not settled. Repositioning the sensor is a separate trial with a new baseline, not a way to repair the current run.
Do not spray water, breathe directly onto the sensing opening, touch the package or use solvents for this exercise. Those introduce uncontrolled moisture, contamination and heat. If the response is smaller than the observed baseline variation, record that limitation. The supplied figure is a constructed illustration, not a measured trace or a prediction that this 20 mW setting will produce those temperatures.
Challenge: sixty seconds after heating, ten readings are stable at 25.8 °C and 54%, while the original baseline was 25.0 °C and 50%. Should the application re-zero and accept them? Answer: no. Both differences exceed the selected reference bands. The warm sensor, altered room air and mounting changes remain possible explanations. The result stays excluded; there is no automatic second heating pulse and no fabricated ambient estimate.
Local checks exercise the actual supplied code: both word checksums, conversion boundaries, exact commands and waits, failed-write and heater-lock behaviour, baseline thresholds, changed-air counterexample, age faults, frozen-clock bound and wrapped-clock acquisition. They run with injected bus and clock objects on a desktop Python interpreter. They are not a MicroPython target run, firmware build, thermal measurement or humidity calibration. The physical bench log is deliberately empty until actual observations are supplied.
Primary sources and version limits
- Sensirion SHT4x datasheet, version 7.3, June 2026: exact device, operating conditions, commands, conversion and heater limitations.
- Adafruit product 5665 and its module pinout guide: regulator, level shifting and pull-ups.
- Sensirion heater application note: context for heater operation, not a claim that this experiment cleans a sensor.
- MicroPython 1.26 I²C interface and original Pico pinout.
No separate applicable erratum was located in the manufacturer’s current product documentation during this review; that does not establish that none can exist. Check the exact module and current primary documentation again before a physical build. This lesson adds a validity experiment to the learning path; it does not replace a calibrated humidity reference.



