Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Biotope V1.1 DHT22 + serial monitor + LCD I2C

mc_workshop Mar 12th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //BIOTOPE
  2. //MCWORKSHOP
  3. //DHT22 + serial monitor + LCD I2C
  4. //Humidity, temperature C anf F, Heat index C and F
  5. //marzo 2019 V1.1
  6. //This example code is in the public domain.
  7.  
  8. #include "DHT.h"
  9. #define DHTPIN A0
  10. #define DHTTYPE DHT22
  11. DHT dht(DHTPIN, DHTTYPE);
  12. #include <LiquidCrystal_I2C.h>
  13. LiquidCrystal_I2C lcd(0x27, 16, 2);
  14. void setup() {
  15.   Serial.begin(9600);
  16.   lcd.init();
  17.   lcd.backlight();
  18.   dht.begin();
  19. }
  20. void loop() {
  21.   float hum = dht.readHumidity();
  22.   float temp = dht.readTemperature();
  23.   float fah = dht.readTemperature(true);
  24.   if (isnan(hum) || isnan(temp) || isnan(fah)) {
  25.     Serial.println("Failed to read from DHT sensor!");
  26.     lcd.print ("Read failed");
  27.     lcd.clear();
  28.     delay (10000);
  29.     lcd.print ("reset");
  30.  __asm__ (" jmp 0 ");//assembler
  31.     return;
  32.   }
  33.   float heat_index = dht.computeHeatIndex(fah, hum);
  34.   float heat_indexC = dht.convertFtoC(heat_index);
  35.   lcd.setCursor(0, 0);
  36.   Serial.print("Humidity: ");
  37.   lcd.print ("UR: ");
  38.   Serial.print(hum);
  39.   lcd.print (hum);
  40.   Serial.print(" %\t");
  41.   lcd.print (" %");
  42.   //
  43.   lcd.setCursor(0, 1);
  44.   Serial.print("Temperature: ");
  45.   lcd.print ("t: ");
  46.   Serial.print(temp);
  47.   lcd.print (temp);
  48.   Serial.print(" C ");
  49.   lcd.print (" C DHT22");
  50.   //
  51.   Serial.print(fah);
  52.   Serial.print(" F\t");
  53.   Serial.print("Heat index: ");
  54.   Serial.print(heat_indexC);
  55.   Serial.print(" C ");
  56.   Serial.print(heat_index);
  57.   Serial.println(" F ");
  58.   delay(10000);
  59. }
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