u/BareMetalBard

Two weeks ago, I posted v1 of my air quality Pi HAT. The top piece of feedback: the Pi 4 runs hot and require significant compensation. I tried to account for it in the design with an extra-tall stacking header and milled isolation islands under the sensors away from the SoC.

The boards came back from JLCPCB - time to find out how well that worked!

https://preview.redd.it/2bf3tw0k4zyg1.jpg?width=2677&format=pjpg&auto=webp&s=7edc86b9db3704ce736af41f3394d8f6cee778b5

How bad Is the self-heating?

Worse than I had assumed.

  • At Idle, the TMP119 reads 28.4°C against an ambient of ~24.2°C, a ~4°C offset.
  • At 4-core load, the SoC heats to ~84°C and heats the TMP119 to 38°C, a ~14°C offset.

Calculating the correction

The Enviro+ project, similar to mine, provides a recommended temperature compensation approach:

T_corrected = T_sensor - (T_cpu - T-sensor) / FACTOR

I determined FACTOR with stress-ng at six load levels (idle, 1 core at 50%, 1c, 2c, 3c, 4c). I let temps settle for ~15 minutes, then averaged over the last 5 minutes.

Example Chart at 1 Core, 50% load

Linear regression of (T_cpu - T_sensor) vs. T_sensor gives the corrected ambient as the intercept, and FACTOR as 1/slope:

https://preview.redd.it/23e55jzryyyg1.png?width=1065&format=png&auto=webp&s=871110d8591d217c9907d10e2480c65c9b769693

Ambient was held roughly stable (no wind ~24°C as measured by my low-precision ThermoPro sensor from Amazon) over a few hours.

  • TMP119: slope = 0.3013, FACTOR = 3.32, intercept 24.2°C
  • SHT45: FACTOR = 2.90 by the same method

I calculate corrected temps on each poll. Since CPU temperature jitter several C, I run it through a single-pole EWMA (alpha = 0.05) as a lowpass filter to smooth the CPU temp.

Compensating Relative Humidity

Since RH measurement is temperature dependent, the raw and corrected SHT45 temperatures are fed into the Magnus formula:

RH_ambient = RH_sensor x e_s(T_sensor) / e_s(T_ambient)

e_s(T) = 6.112 x exp(17.62 x T / (243.12 + T))

At idle, the SHT45 29.5°C, with a corrected ambient of 24.3°C. Therefore e_s(29.5) = 41.1 hPa and e_s(24.3) = 30.3 hPa results in a correction of 41.1/30.3 = 1.36. A reading of 45% RH would correct to 61%.

Pipeline and dashboard

The Pi uses Mosquitto to MQTT publish raw and compensated temps.

I subscribe to these on my desktop, and publish the output on a Qt dashboard:

https://preview.redd.it/dfki4ste3zyg1.png?width=1906&format=png&auto=webp&s=7765ea212d4047b70fcb2ef513b034938dd35b19

The VOC index is calculated using Sensirion's gas index algorithm, which is a relative measurement that takes about 30 minutes to settle to a baseline of 100.

Takeaways

The Pi 4 does indeed run hot, and requires even more compensation than I had assumed. I'm surprised how ineffective the tall header and isolated islands were to thermally isolate the sensors from the Pi. The corrected outputs seem to track the ThermoPro closely, but the high precision of my sensors is overwhelmed by the error introduced by my compensation.

Next Steps:

  • I may continue to tune the compensation with a more reliable truth source
  • If I were to iterate on the design, I would run a flex or QT cable off to a separate board that housed the sensors
reddit.com
u/BareMetalBard — 10 days ago