Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Michelangelo Guarise
Published

Umeteo

2.0 Weather Station with UDOO

Full instructions provided2,621
Umeteo

Things used in this project

Hardware components

UDOO DUAL
UDOO DUAL
Dual or Quad is the same
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Colored LEDs
×2
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Code

file_6874.txt

C/C++
#include <dht11.h>
 
void setup() {
}
 
void loop() {
}

file_6875.txt

C/C++
dht11 DHT11;
 
#define DHT11PIN 13
int led_hum = 12;
int led_temp = 11;

file_6876.txt

C/C++
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);
 
}

file_6877.txt

C/C++
DHT11.read(DHT11PIN);

file_6878.txt

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

file_6879.txt

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

file_6880.txt

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

file_6881.txt

C/C++
delay(2000);

file_6882.txt

C/C++
#include <dht11.h>

dht11 DHT11;

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

void setup() {
  // put your setup code here, to run once:
  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);
  
}

void loop() {
  // put your main code here, to run repeatedly: 
  DHT11.read(DHT11PIN);
  Serial.print(DHT11.humidity);
  Serial.print("\t\t");
  Serial.print(DHT11.temperature);
  Serial.print("\t\t");
  if(DHT11.humidity>45)
  {
    digitalWrite(led_hum,HIGH);
    Serial.print("ON\t\t");
  }
  else
  {
    digitalWrite(led_hum,LOW);
    Serial.print("OFF\t\t");
  }
  if(DHT11.temperature>23)
  {
    digitalWrite(led_temp,HIGH);
    Serial.println("ON");
  }
  else
  {
    digitalWrite(led_temp,LOW);
    Serial.println("OFF");
  }
  delay(2000);
}

file_6883.txt

C/C++
#include <dht11.h>
char oldval='y',val='0';
dht11 DHT11;
 
#define DHT11PIN 13
int led_hum = 11;
int led_temp = 9;
 
void setup() {
  Serial.begin(9600);
  pinMode(led_hum,OUTPUT);
  pinMode(led_temp,OUTPUT);
}
 
void loop() {
  val = Serial.read();
  if(val=='y')
  {
    DHT11.read(DHT11PIN);
    Serial.print(DHT11.humidity);
    Serial.print('#');
    Serial.println(DHT11.temperature);
    if(DHT11.humidity>45)
    {
      digitalWrite(led_hum,HIGH);
    }
    else
    {
      digitalWrite(led_hum,LOW);
    }
    if(DHT11.temperature>23)
    {
      digitalWrite(led_temp,HIGH);
    }
    else
    {
      digitalWrite(led_temp,LOW);
    }
  }
  if(val==oldval)
    val='0';
}

Credits

Michelangelo Guarise

Michelangelo Guarise

7 projects • 57 followers
Founder @ volumio.org , passionate maker, unpredictable developer, misunderstood creative. I do stuff, I build things.

Comments