Arduino: build weather station - how it works
The Arduino is a real all-rounder. In this article, we show how to turn the Raspberry clone into a weather station.
Build the weather station with the Arduino
To build a weather station with your Arduino, of course you need an Arduino, a DHT11 module and some jumper cables.
- Connect the "Data" pin to Pin 2 on the Arduino. Also connect the module to a ground and a 5V pin.
- The module automatically determines the air humidity and the temperature.
- You can use the following code to program the Arduino. Simply copy this into your IDE. However, first make sure that you have installed the SimpleDHT library. You can find an explanation of the code in our picture gallery.
- #include int pinDHT11 = 2; SimpleDHT11 dht11; void setup () {Serial.begin (9600); } void loop () {Serial.println ("================================="); byte temperature = 0; byte humidity = 0; byte data [40] = {0}; if (dht11.read (pinDHT11, & temperature, & humidity, data)) {Serial.print ("ERROR!"); return; } for (int i = 0; i 0 && ((i + 1)% 4) == 0) {Serial.print (''); }} Serial.println (""); Serial.print ((int) temperature); Serial.print ("* C, "); Serial.print ((int) humidity); Serial.println ("%"); delay (1000); }
- Note: When installing your weather station outdoors, be sure to protect the Arduino sufficiently from moisture.
In the next practical tip you will learn how to control a GSM module with the Arduino.