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