Remote Meteorological Station with UDOO – pt 1: Sensors and LEDs


Hello guys, this is the first part of a project which will help you to create a remote meteorological station that monitors humidity, temperature and pressure. We are dividing the projects in few parts in order to allow you to better understand the logics and components behind the project. All the data collected by the meteorological station could be remotely accessed via web thanks to a UDOO’s self hosted server made with apache and MySQL, this means that we will browse our meteorological data from anywhere with our favorite devices: smartphone, tablets or directly on UDOO.

In this first tutorial we are going to connect DHT11, a temperature and humidity sensor, with UDOO through the Arduino IDE.

For this tutorial you need:

Let’s start

First you need to insert the micro SD in your UDOO, connect the HDMI, the keyboard and mouse then power it up.

Ok, you are now ready to download the DHT11 library by clicking here
The library has two file: one header and one file .cpp, so copy the code of dht11.h in a new file with the same name and do the same with dht11.cpp.
Create a new folder with the name “DHT11” and put the files into, then move the folder in /Home/Arduino/libraries

Now go to Arduino IDE and add the library at the sketch, then you will see:

#include 

void setup() {
}

void loop() {
}

Create a new object of type DHT11 and define the pins for the sensor and for the alert LEDs.

dht11 DHT11;

#define DHT11PIN 13
int led_hum = 12;
int led_temp = 11;

In void setup() initialize the serial monitor with 9600 baud, then insert two strings of text for the physical aspect of the sketch and set in output the pinmode of the two alert led

void setup() {
  delay(5000);
  Serial.begin(9600);
  Serial.println("UDOO & DHT11 - TEST PROGRAM By Alessandro Paghi");
  Serial.println("Humidity (%)\tTemperature (C)\tLed_Hum\t\tLed_Temp");
  pinMode(led_hum, OUTPUT);
  pinMode(led_temp, OUTPUT);

}

In void loop() call the function read() with the parameter DHT11pin

  DHT11.read(DHT11PIN);

Then print in the serial monitor the value of humidity and temperature

 Serial.print(DHT11.humidity);
 Serial.print("\t\t");
 Serial.print(DHT11.temperature);
 Serial.print("\t\t");

Execute a control on a value of humidity. If it has a value greater than 45%, turn on the green alert led, else turn off.

  if(DHT11.humidity>45)
  {
    digitalWrite(led_hum, HIGH);
    Serial.print("ON\t\t");
  }
  else
  {
    digitalWrite(led_hum, LOW);
    Serial.print("OFF\t\t");
  }

Execute a control on a value oh temperature. If it has a value greater than 23°C, turn one the white alert led, else turno off.

  if(DHT11.temperature>23)
  {
    digitalWrite(led_temp, HIGH);
    Serial.println("ON");
  }
  else
  {
    digitalWrite(led_temp, LOW);
    Serial.println("OFF");
  }

Insert a deley of two seconds

delay(2000);

Okay guys, now connect physically the component and compile and run the sketch.
When humidity is greter than 45% led green turn on and when temperature in greater than 23°C led white turn on.

For download the Arduino sketch click here

By:

Submit a comment