EmbeddedEra EmbeddedEra

← Notes from the bench.

Why a humidity sensor reads wrong inside an enclosure

Oct 26, 2026 pcb-designlayoutmanufacturing Drafted with AI assistance, reviewed and edited by our engineer.

The sensor reads fine on the bench. Then the board goes into its enclosure and the temperature runs a few degrees high, the humidity reads low, and the numbers take minutes to follow a real change. The part is not defective. The design around it is warming it, trapping air around it, or both.

This comes up with every digital humidity and pressure sensor, from the Sensirion SHT family to the Bosch BME280. The fix is mostly mechanical and layout work, done before the housing is tooled.

Why the humidity number is wrong when the temperature is wrong

Relative humidity depends on temperature. A sensor that sits a little warmer than the room air will report a lower relative humidity than the room really has, even if its humidity element is working perfectly. Sensirion’s humidity design guide makes this point directly: a temperature deviation causes a humidity deviation. It also warns that a poor housing or PCB layout can cause significant temperature and humidity errors and slower response.

So most “my humidity sensor is inaccurate” problems are temperature problems. Fix the heat path first and the humidity reading usually follows.

Heat reaches the sensor three ways:

  • Conduction through the board. The copper pours and planes that carry heat from a regulator, MCU, radio module, charger or LED driver also carry it to the sensor.
  • Warm air inside the case. A sealed box heats up around its electronics. If the sensor samples that air instead of outdoor air, it measures the box.
  • Radiant heat and self-heating. Nearby hot parts, a display backlight or the sensor’s own measurement current all add a little.

Placement and board layout

Sensirion’s design-in guidance comes down to four rules: give the sensor good access to the surrounding air, keep trapped air out of its compartment, keep the dead volume small, and decouple it from heat sources. Sensirion also says software compensation is a fallback when mechanical measures are not enough.

On the board, that turns into a short checklist:

  1. Put the sensor at an edge or a corner, as far as the design allows from power conversion, the MCU, radio modules and anything that dissipates real power. Do not put it next to the linear regulator because that is where the 3.3 V rail is.
  2. Interrupt the copper path. Sensirion’s guide shows slits milled in the PCB around the sensor to cut conduction through the board. A cutout around the sensor, or a sensor on a small flex or daughter board, serves the same purpose. Check with your fab that the slot is something they can route.
  3. Keep planes and fat traces out from under the sensor unless the vendor’s layout drawing says otherwise. Copper is a heat highway.
  4. Think about the other side of the board. A hot part directly behind the sensor still heats it through the laminate.
  5. Follow the vendor’s land pattern and any keep-out for the vent. Many humidity sensors have an opening on top of the package. Do not cover it with a label, a gasket or a through-hole component.

Pressure sensors are less sensitive to a degree of warmth, but combo parts such as the BME280 measure all three quantities. Their temperature reading feeds the humidity compensation, so the same layout rules apply.

Venting and the enclosure

A closed case makes the sensor read the inside of the case. The mechanical job is to give the sensor a short, direct path to the air you actually care about, and no path to everything else.

  • A real opening, close to the sensor. Sensirion’s guidance is a large opening to the environment. A tiny pinhole at the far end of the case gives slow response and lets inside air dominate.
  • A seal between the sensor and the rest of the box. A small gasket or foam ring from the PCB to the housing wall stops warm internal air from circulating past the sensor. This is the “sealed from entrapped air” rule.
  • Small dead volume. The less air sits between the sensor and the opening, the faster it follows changes.
  • Plan for water. If the product can see splashes or condensation, a membrane or filter cap in front of the sensor is a common answer. Sensirion lists an SF2 filter cap for its SHT2x to SHT4x sensors, but check the cap against your sensor and the response-time cost before you design it in.

For pressure, the requirement is different. The sensor needs to see ambient pressure, so it needs a vent, but it also needs protection from water. Venting and ingress protection pull in opposite directions, and the answer depends on the product. Settle it with the enclosure designer early, because moving a vent after tooling is expensive.

Duty cycle and firmware

Firmware can add heat or avoid it. A sensor measuring continuously dissipates continuously. A sensor that measures once a minute and sleeps does not.

  • Use the single-shot or forced mode if your part has one. Bosch’s BME280 flyer describes forced mode as a single measurement on request, followed by a return to sleep, and recommends it for low sampling rates.
  • Sample at the rate the application needs. Room humidity does not change every second.
  • Do not run the on-chip heater, where one exists, as part of normal operation unless the vendor says to. Sensirion publishes separate application notes for the SHT4x heater, listed on its SHT45 product page, because it is meant for specific purposes and it warms the sensor.
  • Keep the other loads quiet. A radio transmit burst or charger turning on a few millimeters away should not coincide with the temperature read. Log the sensor against the system’s activity during bring-up and you will see the correlation. The same measurement habit that finds sleep current above the datasheet finds these coincidences.

If the housing and layout still leave an offset, a software correction is legitimate. It should be a characterized offset, measured on the real assembled product against a reference, and it should be treated as a last step. A correction tuned on one unit on a desk may be wrong on another unit in a different case.

Check it before you commit

Test the finished mechanical assembly, not the bare board:

  1. Compare to a reference. Put the closed product and a reference instrument in the same stable environment and let both settle. Sensirion’s testing guide recommends coupling the reference and sensor under test thermally, not only through the air, and keeping that coupling away from heat-generating components.
  2. Run it powered and idle, and powered and busy. The error that matters is the one with the radio transmitting and the charger running.
  3. Watch the settling curve. Warming that creeps up over an hour points to heat in the case. A slow response to a step change points to dead volume or a restrictive vent.
  4. Test at both ends of the range. A layout that is fine in a cool room can fail near the product’s maximum rated temperature.
  5. Check the assembly side too. Vendor handling documents cover things such as exposure to flux, coating and cleaning chemicals, which can affect a humidity element. Bosch lists a handling, soldering and mounting document for the BME280 on its product page, and Sensirion lists handling and contamination documents for the SHT4x. Read them before you choose a wash, a coating or a reflow profile. If the board is also coated, mask the sensor opening, as covered in our note on conformal coating.

How we approach it

We treat sensor placement as part of the PCB layout and the enclosure fit, not a footnote, and we review it against the sensor vendor’s own design guide. Send us the schematic, the board outline, a sketch or CAD of the enclosure, and the reading you expect against the one you see.

If your humidity or pressure reading drifts once the case is closed, we would review sensor placement, venting and duty cycle against the vendor's design guide.

ENGINEERING NOTES

One note a week on PCB design, firmware and getting hardware built. No sales email.

Double opt-in. Unsubscribe in one click.