//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 01_Test_DHT11_and_Switches
// Reference : https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.ino
#include <DHTesp.h>
#define DHTPIN 15
#define DHTTYPE DHT11
const int SOIL_MOISTURE_PIN = 34;
int MOISTURE_THRESHOLD_LOW = 15; // Set Activation threshold in percentage
int MOISTURE_THRESHOLD_HIGH = 85;
//#define Switch_1_PIN 13
//#define Switch_2_PIN 12
DHTesp dht;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
dht.setup(DHTPIN, DHTesp::DHT22);
//pinMode(Switch_1_PIN, INPUT_PULLUP);
//pinMode(Switch_2_PIN, INPUT_PULLUP);
Serial.println(F("DHT11 test!"));
}
void loop() {
// put your main code here, to run repeatedly:
delay(8000);
int soilMoisturePercentage = map(analogRead(SOIL_MOISTURE_PIN), 0, 4095, 0, 100);
Serial.println("-------------");
Serial.print("Soil Moisture Percentage: ");
Serial.print(soilMoisturePercentage);
Serial.println("%");
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.getHumidity();
// Read temperature as Celsius (the default)
float t = dht.getTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity : "));
Serial.print(h);
Serial.print(F("% | Temperature : "));
Serial.println(t);
Serial.print("-------------");
//Serial.print(F("°C | Switch 1 : "));
//Serial.print(digitalRead(Switch_1_PIN));
//Serial.print(F(" | Switch 2 : "));
//Serial.println(digitalRead(Switch_2_PIN));
}