DIY Weather Station: Arduino Build & Instruments
In this article
Building your own weather station with an Arduino is a rewarding project that lets you measure temperature, humidity, and barometric pressure right from your backyard. You'll learn how sensors work, how to wire them, and how to display live data. This guide covers both the sensor assembly and the Arduino code, so you can have a working station in an afternoon.
What You'll Need
- Arduino board (Uno or Nano recommended)
- DHT22 or DHT11 temperature and humidity sensor
- BMP280 or BME280 barometric pressure sensor
- Breadboard and jumper wires
- USB cable for programming
- Optional: 16x2 LCD display with I2C module
- Optional: Rain gauge or anemometer (if you want wind/rain data)
- Soldering iron and heat shrink (if making a permanent version)
Step-by-Step
- Set up the Arduino IDE – Download and install the Arduino IDE from arduino.cc. Connect your board via USB and select the correct board and port under Tools.
- Install the necessary libraries – Go to Sketch → Include Library → Manage Libraries. Search for and install "DHT sensor library" by Adafruit, "Adafruit Unified Sensor", and "Adafruit BMP280 Library". These libraries make reading the sensors much easier.
- Wire the DHT22 sensor – Connect the DHT22's VCC pin to 5V (or 3.3V if using the 3V version), GND to ground, and the DATA pin to digital pin 2 on the Arduino. Add a 10kΩ pull-up resistor between VCC and DATA.
- Wire the BMP280 sensor – For I2C mode, connect VCC to 3.3V, GND to ground, SDA to A4 (on Uno) or SDA pin, and SCL to A5 (or SCL pin). If your BMP280 module has a CSB pin, leave it unconnected or tie it high.
- Connect the LCD (optional) – If using an I2C LCD, connect VCC to 5V, GND to ground, SDA to A4, and SCL to A5. If your LCD is not I2C, you'll need more wires and a different library.
- Write the code – Open a new sketch. Include the libraries at the top. In
setup(), start serial communication and initialize both sensors. Inloop(), read temperature, humidity, and pressure, then print them to the Serial Monitor and optionally the LCD. - Upload and test – Click the upload button. Open the Serial Monitor (Tools → Serial Monitor) and set the baud rate to 9600. You should see readings updating every few seconds.
- Calibrate the pressure sensor – Compare your pressure reading with a local weather station. Note the difference (offset) and add or subtract it in the code to match your altitude.
- Make it weatherproof – Place the sensors in a ventilated enclosure (like a plastic container with holes) to protect from rain and direct sun. Mount it in a shaded area, away from heat sources.
- Add power and logging (optional) – For a permanent station, use a 5V power adapter. To log data, add an SD card module or use a Wi-Fi module like ESP8266 to send data to an online service.
Common Mistakes
- Using the wrong voltage – DHT22 can run on 3.3V or 5V, but BMP280 must be on 3.3V. Supplying 5V to BMP280 can damage it.
- Forgetting the pull-up resistor on DHT22 – Without it, readings may be erratic or fail entirely.
- Miswiring I2C pins – Swapping SDA and SCL will prevent communication. Double-check the pinout.
- Placing sensors in direct sunlight – This causes high temperature readings. Always shade the sensors.
- Not accounting for altitude in pressure readings – Raw pressure decreases with altitude; you need to adjust for your elevation to compare with sea-level reports.
Tips
- Use a BME280 instead of BMP280 if you want humidity from the same sensor – it's more accurate and saves wiring.
- Add a 10-second delay in the loop to avoid reading too frequently, which can heat the sensors slightly.
- Test each sensor individually before combining them. This makes debugging easier.
- Use female-to-female jumper wires for a cleaner setup on a breadboard.
- If you want to measure wind, consider buying a simple anemometer module – they're easy to interface with the Arduino.
Troubleshooting
- No readings on Serial Monitor – Check that the baud rate matches (9600). Verify the correct board and port are selected. Re-upload the code.
- DHT22 returns NaN or -999 – The sensor is not communicating. Check wiring, pull-up resistor, and that you're using the correct pin number in the code.
- BMP280 not found – Run the I2C scanner sketch to see if the address is detected. The default address is 0x76 or 0x77. If it shows 0x76, set the address in the code.
- LCD shows blocks or nothing – Adjust the contrast potentiometer on the back of the LCD. Also check the I2C address (often 0x27 or 0x3F).
- Readings are wildly off – Ensure the sensors are not near heat sources like the Arduino itself. Move them away and allow time to stabilize.
- Code compiles but no output – Add
delay(2000)afterSerial.begin()to give time for the sensors to initialize.
Frequently Asked Questions
Can I use a DHT11 instead of DHT22?
Yes, but DHT11 is less accurate and has a narrower range. It's fine for basic projects, but DHT22 is recommended for better data.
How do I get sea-level pressure?
Use the barometric formula: sea-level pressure = station pressure / (1 - (altitude/44330))^5.255. Or simply add a fixed offset based on your altitude.
Can I power the station with batteries?
Yes, but the Arduino and sensors will drain AA batteries quickly. Use a 9V battery for short tests, or a rechargeable Li-ion battery with a regulator for longer use.
How often should I take readings?
For weather trends, every 10-15 minutes is enough. For real-time display, every 2-5 seconds is fine. Frequent readings may heat the sensors slightly.
Can I add wind speed and rain?
Yes, you can add an anemometer (wind speed) and a rain gauge. They usually output pulses that you can count with the Arduino's interrupt pins.
Do I need to calibrate the sensors?
Temperature and humidity sensors are usually pre-calibrated. Pressure sensors need a one-time offset adjustment for your altitude, as described above.