daily pastebin goal
33%
SHARE
TWEET

LCD (no I2C) con DHT22 + LDR + WS + PPE

mpmcws Aug 10th, 2018 (edited) 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //LCD (no I2C) con DHT22 + LDR livello oscutità + sensore bagnatura foglia + rendimento pannello fotovoltaico
  2. //temperature, humidity, darkness level, wet sensor, photovoltaic panel efficiency
  3. //Cerani Marco - MPMC Workshop agosto 2018
  4. //V1.0
  5. #include <LiquidCrystal.h>
  6. #include <DHT.h>
  7. #include <Adafruit_Sensor.h>
  8. #define DHTTYPE DHT22
  9. #define DHTPIN 8
  10. DHT dht(DHTPIN, DHTTYPE);
  11. float celsius;
  12. float humidity;
  13. int analogInPin = A0;//livello oscurità - darkness level
  14. int sensorValue = 0;
  15. int analogInPin1 = A1;//bagnatura foglia - wet sensor
  16. int sensorValue1 = 0;
  17. int analogInPin2 = A2;//rendimento pannello fotovoltaico - photovoltaic panel efficiency
  18. int sensorValue2 = 0;
  19. const int rs = 12, en = 11, d4 = 4, d5 = 3, d6 = 2, d7 = 1;
  20. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  21. void setup() {
  22.   dht.begin();
  23.   lcd.begin(16, 2);
  24.   pinMode( analogInPin, INPUT);
  25.   pinMode( analogInPin1, INPUT);
  26.   pinMode( analogInPin2, INPUT);
  27. }
  28. void loop() {
  29.   humidity = dht.readHumidity();
  30.   celsius = dht.readTemperature();
  31.   sensorValue = analogRead(analogInPin);
  32.   char lcd_buffer[16];
  33.  
  34.   lcd.setCursor(0, 0);
  35.   sprintf(lcd_buffer, "%02d.%01d %cC ", (int)celsius, (int)(celsius * 10.0) % 100, (char)223);
  36.   lcd.print(lcd_buffer);
  37.   sprintf(lcd_buffer, "%02d.%01d %c", (int)humidity, (int)(humidity * 10.0) % 100, (char)37);
  38.   lcd.print(lcd_buffer);
  39.   lcd.setCursor(0, 1);
  40.   lcd.print ("D");
  41.   sensorValue = (sensorValue * 2 / 100);
  42.   lcd.print (sensorValue);
  43.   lcd.print (" ");
  44.   delay (3000);
  45.   lcd.print ("w");
  46.   lcd.print (sensorValue1);
  47.   lcd.print (" ");
  48.   delay (3000);
  49.   lcd.print ("P");
  50.   lcd.print (sensorValue2);
  51.   lcd.print (" ");
  52.   delay (3000);
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top