SENSOR SUHU DHT22 ARDUINO

SENSOR SUHU DHT22 ARDUINO


1. ALAT DAN BAHAN :

  a. Kabel Jumper

  b. Bread Board

  c. DHT22

  d. Arduino Mega 2560

  e. Kabel USB Arduino

  f. LCD 16x2 i2c


2. LIBRARY :

  Link Library LCD Di Sini

  

  Link Library DHT22 Di Sini


3. RANKAIAN :

  - LCD 16x2 i2c :

    a. GND -> GND

    b. VCC -> 5V

    c. SDA -> SDA

    d. SCL -> SCL

  - DHT22 :

    a. +5VCC -> VCC

    b. GND -> GND

    c. 26 -> DATA


4. CODING :

  #include <LiquidCrystal_I2C.h>

  #include "DHT.h"

  #define DHTPIN 26     // DHT PIN Analog 1

  #define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

  LiquidCrystal_I2C lcd(0x27, 16, 2);

  DHT dht(DHTPIN, DHTTYPE);


void setup() {

  Serial.begin(9600);

  lcd.begin();

  dht.begin();

  lcd.setCursor(5,0);lcd.print("Arduino");

  lcd.setCursor(3,1);lcd.print("T+H Monitor");

  delay(2000);

  lcd.clear();

}


void loop() {

  delay(1000);

  float h = dht.readHumidity();

  // Read temperature as Celsius (the default)

  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).

  if (isnan(h) || isnan(t) ) {

    Serial.println("Failed to read from DHT sensor!");

    return;

  }

  Serial.print(t); //Temperature data

  Serial.print(",");//Data splitter

  Serial.println(h); //Humidity data 

  lcd.clear();

  lcd.setCursor(0,0);lcd.print("Temp:");lcd.print(t);

  lcd.print(" C");//LCD line 1 print temperature

  lcd.setCursor(0,1);lcd.print("Hum:");lcd.print(h);

  lcd.print(" %");//LCD line 2 print Humidity

}


5. HASIL  FOTO :


6. HASIL VIDEO :



SENSOR SUHU DHT22 ARDUINO SENSOR SUHU DHT22 ARDUINO Reviewed by PKLSMKPTPWS on Oktober 18, 2022 Rating: 5

Tidak ada komentar