Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
810 B
1
Indexable
Never
#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT11 

DHT dht(DHTPIN, DHTTYPE);



int mq2Pin = A1;
int ldrPin = A0;
int irSensorPin = 6; 

void setup() {
  Serial.begin(9600); 
  pinMode(irSensorPin, INPUT);
 

  dht.begin();
}

void loop() {
 
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  float f = dht.readTemperature(true);
  int ldrValue = analogRead(ldrPin);
  int mq2 = analogRead(mq2Pin); 
  int irPresence = digitalRead(irSensorPin); 

  
  String finalValue = "Humidity: " + String(humidity) + " %" + " Temperature: " + String(temperature) + " *C " + String(f) + " *F" + " MQ-2: " + String(mq2) + " LDR: " + String(ldrValue) + " IR Presence: " + String(irPresence);

  Serial.println(finalValue);
 

  delay(1000); 
}
Leave a Comment