//#include <iostream>
#include "DHT.h"
class Sensor {
public:
virtual void begin() = 0;
virtual float readValue() = 0;
};
class AnalogSensor : public Sensor {
int pin;
public:
AnalogSensor(int pin) : pin(pin) {}
void begin() {
}
float readValue() {
//std::cout << "Analog Sensor Value: " << readValue() << std::endl;
return 0;
}
};
class DigitalSensor : public Sensor {
int pin;
DHT dht;
public:
DigitalSensor(int pin) : pin(pin), dht(pin, DHT22) {}
void begin() {
dht.begin();
}
float readValue() {
//std::cout << "Analog Sensor Value: " << readValue() << std::endl;
return 0;}
float readhumidity() {
dht.read();
float humidity = dht.readHumidity();
//std::cout << "DHT22 Humidity: " << humidity << "%" << std::endl;
return 0;
}
float readTemperatureCelsius() {
dht.read();
float temperatureC = dht.readTemperature();
//std::cout << "DHT22 Temperature (Celsius): " << temperatureC << "°C" << std::endl;
return 0;
}
};
void setup(){
AnalogSensor analogSensor(0);
DigitalSensor dht22(15);
pinMode(13, OUTPUT);
analogSensor.begin();
dht22.begin();
}
void loop(){
AnalogSensor analogSensor(0);
DigitalSensor dht22(15);
analogSensor.readValue();
dht22.readhumidity();
if(dht22.readhumidity()>50)
digitalWrite(13,HIGH);
delay(2000);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
dht1:VCC
dht1:SDA
dht1:NC
dht1:GND
led1:A
led1:C
r1:1
r1:2