Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
DHT11 Temperature & Humidity Sensor (4 pins)
Rotary Potentiometer, 10 kohm
Alphanumeric LCD, 16 x 2
Project description
Code
untitled
c_cpp
1#include <LiquidCrystal.h> 2#include <dht_nonblocking.h> 3#define DHT_SENSOR_TYPE DHT_TYPE_11 4static const int DHT_SENSOR_PIN = 2; 5DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE); 6LiquidCrystal lcd (7, 8, 9, 10, 11, 12); 7void setup() { 8lcd.begin(16, 2); 9}static bool measure_enviroment(float *temperature, float *humidity) 10{ 11 static unsigned long measurement_timestamp = millis(); 12 if(millis() - measurement_timestamp > 3000ul); 13 { 14 if(dht_sensor.measure(temperature, humidity) == true) 15 { 16 measurement_timestamp = millis(); 17 return(true); 18 } 19 } 20 return(false); 21} 22 23 24void loop() { 25float temperature; 26float humidity; 27if(measure_enviroment(&temperature, &humidity) == true) 28{ 29 lcd.print("T = "); 30 lcd.print(temperature, 1); 31 lcd.print( " deg. C, H = "); 32 lcd.print(humidity, 1); 33 lcd.print("%"); 34} 35 36}
untitled
c_cpp
1#include <LiquidCrystal.h> 2#include <dht_nonblocking.h> 3#define 4 DHT_SENSOR_TYPE DHT_TYPE_11 5static const int DHT_SENSOR_PIN = 2; 6DHT_nonblocking 7 dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE); 8LiquidCrystal lcd (7, 8, 9, 10, 9 11, 12); 10void setup() { 11lcd.begin(16, 2); 12}static bool measure_enviroment(float 13 *temperature, float *humidity) 14{ 15 static unsigned long measurement_timestamp 16 = millis(); 17 if(millis() - measurement_timestamp > 3000ul); 18 { 19 if(dht_sensor.measure(temperature, 20 humidity) == true) 21 { 22 measurement_timestamp = millis(); 23 return(true); 24 25 } 26 } 27 return(false); 28} 29 30 31void loop() { 32float temperature; 33float 34 humidity; 35if(measure_enviroment(&temperature, &humidity) == true) 36{ 37 lcd.print("T 38 = "); 39 lcd.print(temperature, 1); 40 lcd.print( " deg. C, H = "); 41 lcd.print(humidity, 42 1); 43 lcd.print("%"); 44} 45 46}
Downloadable files
Wiring Scheme
Wiring Scheme

Wiring Scheme
Wiring Scheme

Comments
Only logged in users can leave comments