Desi o statie meteo ofera mai multe date decat temperatura si umiditatea, am considerat ca si aceste date sunt “bune” pentru o “ministatie meteo”…
Totul se bazeaza pe un senzor dedicat DHT11, care nu are o precize uimitoare, dar pentru aplicatii casnice este acceptabil (domeniu de temperatura 0..50oC cu precizie de +2oC, respectiv umiditate 20..90%RH cu o precizie de +5%RH).
Prima proba s-a facut cu senzorul DHT11 avand pinul conectat la A2 (analog 2) de la Arduino, iar afisajul cu cristale lichide cu 16 coloane si 2 randuri LCD1602 conectat ca in exemplele de pe site-ul Arduino, sketck-ul fiind:
// LCD1602A
// * LCD RS pin to digital pin 12
// * LCD Enable pin to digital pin 11
// * LCD D4 pin to digital pin 5
// * LCD D5 pin to digital pin 4
// * LCD D6 pin to digital pin 3
// * LCD D7 pin to digital pin 2
// * LCD R/W pin to ground
// * 10K resistor:
// * ends to +5V and ground
// * wiper to LCD VO pin (pin 3)
//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}double Kelvin(double celsius)
{
return celsius + 273.15;
}double dewPoint(double celsius, double humidity)
{
double RATIO = 373.15 / (273.15 + celsius); // RATIO was originally named A0, possibly confusing in Arduino context
double SUM = -7.90298 * (RATIO – 1);
SUM += 5.02808 * log10(RATIO);
SUM += -1.3816e-7 * (pow(10, (11.344 * (1 – 1/RATIO ))) – 1) ;
SUM += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO – 1))) – 1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM – 3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558 – T);
}// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a – temp);
return Td;
}#include
dht11 DHT11;
#define DHT11PIN A2 // sensor pin is at A2
// include the library code:
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);void setup()
{
Serial.begin(9600);
Serial.println(“DHT11 TEST PROGRAM “);
Serial.print(“LIBRARY VERSION: “);
Serial.println(DHT11LIB_VERSION);
Serial.println();
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“ministatie meteo”);
}void loop()
{
Serial.println(“n”);int chk = DHT11.read(DHT11PIN);
Serial.print(“Read sensor: “);
switch (chk)
{
case DHTLIB_OK:
Serial.println(“OK”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.println(“Checksum error”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.println(“Time out error”);
break;
default:
Serial.println(“Unknown error”);
break;
}Serial.print(“Humidity (%): “);
Serial.println((float)DHT11.humidity, 2);Serial.print(“Temperature (oC): “);
Serial.println((float)DHT11.temperature, 2);Serial.print(“Temperature (oF): “);
Serial.println(Fahrenheit(DHT11.temperature), 2);Serial.print(“Temperature (K): “);
Serial.println(Kelvin(DHT11.temperature), 2);Serial.print(“Dew Point (oC): “);
Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));Serial.print(“Dew PointFast (oC): “);
Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));delay(2000);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(1, 1);
// print the number of seconds since reset:
lcd.print((float)DHT11.temperature, 1);
lcd.write(0b11011111);
lcd.print(“C H=”);lcd.print((float)DHT11.humidity, 1);
lcd.print(“%”);
}
– http://www.hobbyist.co.nz/?q=taxonomy/term/10
– http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor
– http://playground.arduino.cc/main/DHT11Lib
– http://stigern.net/blog/?p=373
– http://arduino-info.wikispaces.com/PROJECT-Temp-Humidity-Display
– http://dalxxdht11.blogspot.ro/2012/12/dht11-library-for-arduino-uno.html
Am facut si un filmulet numit ministatie meteo cu DHT11, LCD1602 si Arduino (I):
[yframe url=’http://www.youtube.com/watch?v=U_jQRzSSceM’]Am conectat apoi afisajul LCD 1602A cu interfata i2c cu sketch-ul gasit la http://blog.gotencool.com/2012_03_01_archive.html modificand adresa de la 0x27 la 0x20
#include#include <liquidcrystal_i2c .h>LiquidCrystal_I2C lcd(0x20,16,2); // 0x27 es la direccion del LCD 16×2void setup(){lcd.init();lcd.backlight(); //enciende la iluminacionlcd.setCursor(0, 0);lcd.print(“Probando i2c”);}void loop(){delay(1000);}
#include#include <liquidcrystal_i2c .h>LiquidCrystal_I2C lcd(0x20,16,2); // 0x27 es la direccion del LCD 16×2//Celsius to Fahrenheit conversiondouble Fahrenheit(double celsius){return 1.8 * celsius + 32;}double Kelvin(double celsius){return celsius + 273.15;}double dewPoint(double celsius, double humidity){double RATIO = 373.15 / (273.15 + celsius); // RATIO was originally named A0, possibly confusing in Arduino contextdouble SUM = -7.90298 * (RATIO – 1);SUM += 5.02808 * log10(RATIO);SUM += -1.3816e-7 * (pow(10, (11.344 * (1 – 1/RATIO ))) – 1) ;SUM += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO – 1))) – 1) ;SUM += log10(1013.246);double VP = pow(10, SUM – 3) * humidity;double T = log(VP/0.61078); // temp varreturn (241.88 * T) / (17.558 – T);}// delta max = 0.6544 wrt dewPoint()// 5x faster than dewPoint()// reference: http://en.wikipedia.org/wiki/Dew_pointdouble dewPointFast(double celsius, double humidity){double a = 17.271;double b = 237.7;double temp = (a * celsius) / (b + celsius) + log(humidity/100);double Td = (b * temp) / (a – temp);return Td;}#includedht11 DHT11;#define DHT11PIN A2 // sensor pin is at A2void setup(){Serial.begin(9600);Serial.println(“DHT11 TEST PROGRAM “);Serial.print(“LIBRARY VERSION: “);Serial.println(DHT11LIB_VERSION);}void loop(){Serial.println(“n”);int chk = DHT11.read(DHT11PIN);Serial.print(“Read sensor: “);switch (chk){case DHTLIB_OK:Serial.println(“OK”);break;case DHTLIB_ERROR_CHECKSUM:Serial.println(“Checksum error”);break;case DHTLIB_ERROR_TIMEOUT:Serial.println(“Time out error”);break;default:Serial.println(“Unknown error”);break;}Serial.print(“Humidity (%): “);Serial.println((float)DHT11.humidity, 2);Serial.print(“Temperature (oC): “);Serial.println((float)DHT11.temperature, 2);Serial.print(“Temperature (oF): “);Serial.println(Fahrenheit(DHT11.temperature), 2);Serial.print(“Temperature (K): “);Serial.println(Kelvin(DHT11.temperature), 2);Serial.print(“Dew Point (oC): “);Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));Serial.print(“Dew PointFast (oC): “);Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));delay(2000);//LCD16x2 with i2c control – see http://www.tehnic.go.rolcd.init();lcd.backlight(); //voi aprinde si led-ul de fundal// set up the LCD’s number of columns and rows://lcd.begin(16, 2);// Print a message to the LCD.lcd.print(“ministatie meteo”);lcd.setCursor(1, 1);// print the number of seconds since reset:lcd.print((float)DHT11.temperature, 1);lcd.write(0b11011111);lcd.print(“C H=”);lcd.print((float)DHT11.humidity, 1);lcd.print(“%”);delay(2000);}
Am schimbat un pic aranjamentul din sketch:
#include
#include <liquidcrystal_i2c .h>
LiquidCrystal_I2C lcd(0x20,16,2); // 0x27 es la direccion del LCD 16×2//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}double Kelvin(double celsius)
{
return celsius + 273.15;
}double dewPoint(double celsius, double humidity)
{
double RATIO = 373.15 / (273.15 + celsius); // RATIO was originally named A0, possibly confusing in Arduino context
double SUM = -7.90298 * (RATIO – 1);
SUM += 5.02808 * log10(RATIO);
SUM += -1.3816e-7 * (pow(10, (11.344 * (1 – 1/RATIO ))) – 1) ;
SUM += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO – 1))) – 1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM – 3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558 – T);
}// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a – temp);
return Td;
}#include
dht11 DHT11;
#define DHT11PIN A2 // sensor pin is at A2void setup()
{
Serial.begin(9600);
Serial.println(“DHT11 TEST PROGRAM “);
Serial.print(“LIBRARY VERSION: “);
Serial.println(DHT11LIB_VERSION);lcd.init();
lcd.backlight(); //voi aprinde si led-ul de fundal
// set up the LCD’s number of columns and rows:
//lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“ministatie meteo”);
}
void loop()
{
Serial.println(“n”);
int chk = DHT11.read(DHT11PIN);
Serial.print(“Read sensor: “);
switch (chk)
{
case DHTLIB_OK:
Serial.println(“OK”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.println(“Checksum error”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.println(“Time out error”);
break;
default:
Serial.println(“Unknown error”);
break;
}Serial.print(“Humidity (%): “);
Serial.println((float)DHT11.humidity, 2);Serial.print(“Temperature (oC): “);
Serial.println((float)DHT11.temperature, 2);Serial.print(“Temperature (oF): “);
Serial.println(Fahrenheit(DHT11.temperature), 2);Serial.print(“Temperature (K): “);
Serial.println(Kelvin(DHT11.temperature), 2);Serial.print(“Dew Point (oC): “);
Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));Serial.print(“Dew PointFast (oC): “);
Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));
delay(2000);//LCD16x2 with i2c control – see http://www.tehnic.go.ro
lcd.setCursor(0, 1);
lcd.print(“t=”);
lcd.print((float)DHT11.temperature, 1);
lcd.write(0b11011111);
lcd.print(“C H=”);
lcd.print((float)DHT11.humidity, 1);
lcd.print(“%”);
delay(2000);
}
#include <liquidcrystal_i2c .h>LiquidCrystal_I2C lcd(0x20,16,2); // 0x20 is adress my I2C adapter#includedht11 DHT11;#define DHT11PIN A2 // sensor pin is at A2void setup(){Serial.begin(9600);Serial.println(“DHT11 TEST PROGRAM “);Serial.print(“LIBRARY VERSION: “);Serial.println(DHT11LIB_VERSION);lcd.init();lcd.backlight(); //voi aprinde si led-ul de fundal// set up the LCD’s number of columns and rows:lcd.begin(16, 2);// Print a logo message to the LCD.lcd.print(“www.tehnic.go.ro”);lcd.setCursor(0, 1);lcd.print(“creat de niq_ro”);delay (2500);lcd.clear();// Print a permanent message to the LCD.lcd.print(“ministatie meteo”);lcd.setCursor(2, 1);lcd.print(“versiunea 1m1”);delay (2500);}void loop(){Serial.println(“n”);int chk = DHT11.read(DHT11PIN);Serial.print(“Read sensor: “);switch (chk){case DHTLIB_OK:Serial.println(“OK”);break;case DHTLIB_ERROR_CHECKSUM:Serial.println(“Checksum error”);break;case DHTLIB_ERROR_TIMEOUT:Serial.println(“Time out error”);break;default:Serial.println(“Unknown error”);break;}Serial.print(“Humidity (%): “);Serial.println((float)DHT11.humidity, 2);Serial.print(“Temperature (oC): “);Serial.println((float)DHT11.temperature, 2);//LCD16x2 with i2c control – see http://www.tehnic.go.rolcd.setCursor(0, 1);lcd.print(“t=”);lcd.print((float)DHT11.temperature, 1);lcd.write(0b11011111);lcd.print(“C H=”);lcd.print((float)DHT11.humidity, 1);lcd.print(“%”);delay(2000);}
Sursă: Nicu FLORICA
buna ziua, ma intereseaza daca pot cumpara de la dumneavoastra acest proiect. ma refer la partea hardware gata facuta + software . Multumesc
Interesant. Asa ceva doresc.
Dar eu nu am asemenea cunostinte si nici macar speranta ca as putea invata asa ceva .
Eu doresc sa citesc pe ceva.. umiditatea .
Temperatura o pot citi pe termometru . As dori sa stiu temperatura din exteriorul apartamentului .
indicele termic probabil este o impartire intre temperatura exterioara si umiditatea exterioara .
Buna seara, doresc sa contruiesc un timer electronic cu display led 7 segmente 4 digiti. va rog o mana de ajutor
Multumesc
Eu ți-am dat odată adresa mea,etc și totuxși nu ai șters datele mele așa cum scrie mai sus.Te rog un lucru și anume dacă mi e valabil acest sait ,DE CE NU SÎNTEȚI CORECȚI S-AU SÎNTEȚI ȘMECHERI?