미래 농어업을 선도하는 디지털 농어업 인재 육성 대학
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(A0,A1);
byte cmd[9]={0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
byte response[9];
String ppmString=" ";
LiquidCrystal_I2C lcd(0x27,16,2);
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
lcd.init();
lcd.backlight();
}
void loop()
{
delay(1000);
int h = dht.readHumidity();
int t = dht.readTemperature();
mySerial.write(cmd,9);
mySerial.readBytes(response,9);
byte chck = 0;
int ppm = (response[2] << 8)|response[3];
ppmString = String(ppm);
Serial.print("temp:");
Serial.println(t);
lcd.setCursor(0,0);
lcd.print("T:");
lcd.print(t);
lcd.print("C ");
Serial.print("HUMID:");
Serial.println(h);
lcd.print("H:");
lcd.print(h);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("CO2:");
lcd.print(ppm);
lcd.print("PPM");
}