108 lines
2.3 KiB
C
108 lines
2.3 KiB
C
/*
|
|
Header file for the SmartGarden project
|
|
*/
|
|
|
|
#define HEADER_H
|
|
|
|
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
#include <SPI.h>
|
|
#include <BH1750.h>
|
|
#include <Adafruit_Sensor.h>
|
|
#include <DHT.h>
|
|
#include <DHT_U.h>
|
|
|
|
#include <WiFi.h>
|
|
#include <WebServer.h>
|
|
#include <AutoConnect.h>
|
|
#include "time.h"
|
|
|
|
// fix for core panic during wifi initialization
|
|
#define configMINIMAL_STACK_SIZE 4096
|
|
#define CONFIG_TIMER_TASK_STACK_SIZE 8192
|
|
|
|
// BH1750 lightsensor
|
|
#define MIN_LIGHT 0
|
|
#define MAX_LIGHT 54612
|
|
|
|
// DHT11
|
|
#define PIN_DHT11 14
|
|
|
|
// MQ-135
|
|
#define PIN_MQ135_A 12
|
|
#define PIN_MQ135_D 13
|
|
|
|
// MOISTURE SENSOR // A7
|
|
#define PIN_MS 35
|
|
#define VALUE_WATER 1650
|
|
#define VALUE_AIR 3500
|
|
|
|
// Ventil
|
|
#define PIN_VALVE 32
|
|
#define MAX_VALVE_TIMEOUT 10000
|
|
|
|
// STATUS LED
|
|
#define PIN_LED_R 2
|
|
#define PIN_LED_G 0
|
|
#define PIN_LED_B 4
|
|
|
|
// LIGHT LED
|
|
#define LIGHT_LED_PIN_R 27
|
|
#define LIGHT_LED_PIN_G 26
|
|
#define LIGHT_LED_PIN_B 25
|
|
#define MAX_LIGHT_TIMEOUT 10000
|
|
|
|
// MQTT
|
|
#define MQTT_HOST "mqtt.timovolkmann.de"
|
|
#define MQTT_PORT 1883
|
|
#define MQTT_DEVICE_ID "esp-sebastian"
|
|
#define MQTT_TOPIC_BASE_SUB "smartgarden/commands"
|
|
#define MQTT_TOPIC_BASE_PUB "smartgarden/updates"
|
|
#define MQTT_PATH_PUB MQTT_TOPIC_BASE_PUB "/" MQTT_DEVICE_ID "/"
|
|
#define MQTT_PATH_SUB MQTT_TOPIC_BASE_SUB "/#"
|
|
// MQTT_DEVICE_ID "/#"
|
|
|
|
// PUBLISH FREQUENCY (MS)
|
|
#define FREQUENCY 5000 //30000
|
|
|
|
// moisture
|
|
extern void setupCapacitiveSoilMoistureSensor();
|
|
extern int readCapacitiveSoilMoistureSensor();
|
|
|
|
// light
|
|
extern void setupLightSensor();
|
|
extern float readLightSensorValue();
|
|
|
|
// temperature & humidity
|
|
extern void setupTemperatureSensor();
|
|
extern float readHumidity();
|
|
extern float readTemperature();
|
|
|
|
// mqtt & wifi
|
|
extern void setupConnections();
|
|
extern void publishMessage(const char *topic, const char *msg);
|
|
|
|
// RGB PWM LED
|
|
extern void setupPWM();
|
|
extern void setValueNM(int NM);
|
|
extern void getColorBasedOnValueNM(int valueNM);
|
|
extern void triggerLight();
|
|
|
|
// NTP Timestamps
|
|
void printTimestamp();
|
|
void setupNTP();
|
|
bool checkForDay();
|
|
int getCurrentHour();
|
|
|
|
// sensors
|
|
void readSensors();
|
|
void toggleValve();
|
|
void setSoilProperties(int FC, int PWP, int SAT);
|
|
void setupStore();
|
|
void setLightProperties(int NM, int minLX);
|
|
void restoreLightProbs();
|
|
void persistLightProps(int NM, int minLX);
|
|
|
|
void takeSemaphore();
|
|
void releaseSemaphore();
|