Implement soil humidity logging to serial console
This commit is contained in:
parent
043753df16
commit
89b3ec1889
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
|
int fc28_pin = A0;
|
||||||
|
int soil_threshold = 40;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
dht.begin();
|
dht.begin();
|
||||||
|
@ -13,8 +16,10 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
sprintf(buffer, "Temperature: %.2f °C Humidity: %.2f %%",
|
int analog_val = analogRead(fc28_pin);
|
||||||
dht.readTemperature(), dht.readHumidity());
|
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);
|
Serial.println(buffer);
|
||||||
delay(60000);
|
delay(60000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue