Free

Weather Station

A sensor reading is not a fact — it is a measurement, and this one checks before it believes.

  • Arduino
  • C++
  • DHT11
  • LCD

About this project

Temperature and humidity from a DHT11 or DHT22, printed to the serial monitor as CSV and shown on a 16x2 LCD, with min/max tracking and a comfort reading.

The idea it is built around is that a sensor reading is a claim, not a fact. A DHT does not always answer, does not always answer correctly, and does not answer now — it refreshes about once a second, so polling faster returns the same measurement again rather than a new one. Most versions of this project print whatever the library handed back. This one checks: did the sensor answer, did all five bytes arrive, does the checksum match, is the number physically possible. Only a reading that survives all four becomes the current value, and anything else leaves the last good reading in place and starts a clock on it, so the display can say the data is stale rather than showing an old number as though it were current.

There is no library to install: the sensor is read by the sketch itself, against the DHT's documented protocol, and every timing is a named constant with the reason beside it. Set SIMULATE to 1 and it manufactures its own frames — including a bad checksum, a silent spell and an impossible reading — so the whole project runs with nothing wired to the board.

What you will learn

  • Read a DHT sensor from its own single-wire protocol, with no library to install
  • Verify a checksum and reject a frame rather than displaying a corrupted reading
  • Tell the difference between no reading and a reading of zero, on screen and in the data
  • Mark data stale instead of showing an old number as if it were current
  • Schedule with millis() so a button press is never swallowed by delay()

Before you start

  • Arduino basics — setup, loop, and reading a pin
  • The Arduino IDE, or Priodemy Labs if you have no board
  • Optional hardware: an UNO, a DHT11 or DHT22, and a 16x2 LCD

New to Arduino? The free Arduino course covers everything this project assumes.

Academic integrity notice

These projects are provided for learning, experimentation and reference. Understand the code, modify it for your own requirements, and acknowledge external work according to your institution’s academic policies. Priodemy does not supply work to be submitted as your own.