homeostasis/src/main.cpp

30 lines
643 B
C++

#include "wlan.h"
#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();
wlan_connection();
}
void loop() {
unsigned long start_time = millis();
int analog_val = analogRead(fc28_pin);
int soil_percentage = map(analog_val, 0, 1023, 0, 100);
char buffer[200];
sprintf(buffer, "Temperature: %.2f°C Humidity: %.2f%% Soil humidity: %i%%",
dht.readTemperature(), dht.readHumidity(), soil_percentage);
Serial.println(buffer);
delay(30000);
enter_deep_sleep(start_time);
}