Implement soil humidity logging to serial console

This commit is contained in:
coolneng 2023-03-15 04:03:22 +01:00
parent 77ccf06986
commit c62f482d1d
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,9 @@
DHT dht(DHTPIN, DHTTYPE);
int fc28_pin = A0;
int soil_threshold = 40;
void setup() {
Serial.begin(9600);
dht.begin();
@ -13,8 +16,10 @@ void setup() {
void loop() {
char buffer[100];
sprintf(buffer, "Temperature: %.2f °C Humidity: %.2f %%",
dht.readTemperature(), dht.readHumidity());
int analog_val = analogRead(fc28_pin);
int soil_percentage = map(analog_val, 0, 1023, 0, 100);
sprintf(buffer, "Temperature: %.2f °C Humidity: %.2f %% Soil humidity: %i %%",
dht.readTemperature(), dht.readHumidity(), soil_percentage);
Serial.println(buffer);
delay(60000);
}