Try It: Sampling Rate vs Sensor Limits

Try It: Sampling Rate vs Sensor Limits

animation
sensors
Try Choose Sensor type DHT22 (0.5 Hz) and start with Code polling interval at 500 ms. Lengthen the interval and compare fresh readings with duplicate polls.
Observe The initial 2.0 Hz polling produces 20 attempted polls in ten seconds: 5 fresh and 15 stale or duplicate. The bar reports 25% fresh readings.
Explain Code polling interval is compared with the selected sensor interval; poll counts divide the fixed ten-second window by the polling or fresh-reading interval and round down.

Technical boundaries. The example assumes fixed sensor update intervals and labels excess polls as stale or duplicate. Custom uses a fixed one-second interval, while the DS18B20 option represents a polling policy rather than a hardware maximum; conversion timing and bus failures are not simulated.

Try It: Sampling Rate vs Sensor Limits. Polling faster than a sensor updates can return stale readings. Compare polling and conversion rates.

Note

Different sensors have different maximum sampling rates. Explore what happens when your code polls faster than the sensor can respond, and see how many valid vs stale readings you get.

Back to the chapter