65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
|
|
#include <ESP8266WiFi.h>
|
|
#include "config.h"
|
|
|
|
/**
|
|
* Whishlist:
|
|
* - Push sensor values to influxdb
|
|
* - Webserver for /metrics endpoint (Prometheus)
|
|
* - Show current sensor values over simple webpage
|
|
* - Push sensor values to various 3rd party services
|
|
* - MQTT?
|
|
*
|
|
* - Auto-Reconnect for WIFI
|
|
* - Buffer sensor values if there is no WIFI connection
|
|
* - Configure weather station over http webinterface
|
|
* - If there are now WiFi credentials, open up an access point to configure it
|
|
* - OTA firmware update
|
|
*
|
|
* TODO:
|
|
* - https://sminghub.github.io/Sming/about/
|
|
* - https://github.com/marvinroger/homie-esp8266
|
|
*/
|
|
|
|
float currentSensorData[3] = {0.0, 0.0, 0.0};
|
|
|
|
void connectToWiFi() {
|
|
}
|
|
bool checkWiFiConnection() {
|
|
return true;
|
|
}
|
|
|
|
void setup() {
|
|
#ifdef DEBUG
|
|
Serial.begin(115200);
|
|
#endif
|
|
|
|
pinMode(STATUS_LED, OUTPUT);
|
|
connectToWiFi();
|
|
}
|
|
|
|
void loop() {
|
|
digitalWrite(STATUS_LED, LOW);
|
|
|
|
while (!checkWiFiConnection()) {
|
|
connectToWiFi();
|
|
delay(5000);
|
|
}
|
|
|
|
currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature();
|
|
currentSensorData[SENSOR_HUMIDITY] = fetchHumidity();
|
|
currentSensorData[SENSOR_LIGHT] = fetchLight();
|
|
|
|
#ifdef DEBUG
|
|
Serial.println("");
|
|
Serial.println("Current readings:");
|
|
Serial.println("Temperature: " + String(currentSensorData[SENSOR_TEMPERATURE]));
|
|
Serial.println("Humidity: " + String(currentSensorData[SENSOR_HUMIDITY]));
|
|
Serial.println("Light: " + String(currentSensorData[SENSOR_LIGHT]));
|
|
#endif
|
|
|
|
pushToInfluxDB(currentSensorData);
|
|
|
|
|
|
delay(UPDATE_INTERVAL*1000);
|
|
}
|