homeostasis/src/main.cpp

26 lines
533 B
C++
Raw Normal View History

2023-03-15 01:53:25 +01:00
#include <Arduino.h>
#include <DHT.h>
#define DHTTYPE DHT11
#define DHTPIN 4
DHT dht(DHTPIN, DHTTYPE);
int fc28_pin = A0;
int soil_threshold = 40;
void setup() {
Serial.begin(9600);
dht.begin();
}
2023-03-15 01:53:25 +01:00
void loop() {
2023-03-15 04:20:59 +01:00
char buffer[200];
int analog_val = analogRead(fc28_pin);
int soil_percentage = map(analog_val, 0, 1023, 0, 100);
2023-03-15 04:20:59 +01:00
sprintf(buffer, "Temperature: %.2f°C Humidity: %.2f%% Soil humidity: %i%%",
dht.readTemperature(), dht.readHumidity(), soil_percentage);
Serial.println(buffer);
2023-03-15 04:20:59 +01:00
delay(30000);
2023-03-15 01:53:25 +01:00
}