Frickelt in a sensor status page.
This commit is contained in:
parent
c16d431c89
commit
9dd90841a5
2 changed files with 43 additions and 2 deletions
|
@ -43,6 +43,8 @@ Influxdb influxdb(INFLUXDB_HOST, INFLUXDB_PORT);
|
||||||
Adafruit_APDS9960 apds;
|
Adafruit_APDS9960 apds;
|
||||||
Adafruit_BME280 bme;
|
Adafruit_BME280 bme;
|
||||||
|
|
||||||
|
String localIP = "127.0.0.1";
|
||||||
|
|
||||||
//*************************************************************************//
|
//*************************************************************************//
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -89,6 +91,8 @@ void setup() {
|
||||||
|
|
||||||
setupWebUpdater();
|
setupWebUpdater();
|
||||||
|
|
||||||
|
localIP = WiFi.localIP().toString();
|
||||||
|
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
digitalWrite(STATUS_LED_PIN, LOW);
|
digitalWrite(STATUS_LED_PIN, LOW);
|
||||||
|
@ -115,7 +119,11 @@ void loop() {
|
||||||
currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed();
|
currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed();
|
||||||
currentSensorData[SENSOR_PRESSURE] = fetchPressure();
|
currentSensorData[SENSOR_PRESSURE] = fetchPressure();
|
||||||
currentSensorData[SENSOR_BAT_VOLTAGE] = getBatteryVoltage();
|
currentSensorData[SENSOR_BAT_VOLTAGE] = getBatteryVoltage();
|
||||||
|
|
||||||
|
if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.7)
|
||||||
|
{
|
||||||
|
ESP.deepSleep(4294967295); // battery low, shutting down
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
//Serial.println("Current readings:");
|
//Serial.println("Current readings:");
|
||||||
|
@ -128,9 +136,10 @@ void loop() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pushToInfluxDB(DEVICE_NAME, currentSensorData);
|
pushToInfluxDB(DEVICE_NAME, currentSensorData);
|
||||||
|
setSensorData(DEVICE_NAME, localIP, currentSensorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ESP.deepSleep(UPDATE_INTERVAL * 1000000);
|
//ESP.deepSleep(DELAY_LOOP_MS * 1000); // the ESP.deepSleep requires microseconds as input, after the sleep the system will run into the setup routine
|
||||||
//delay(100);
|
//delay(100);
|
||||||
delay(DELAY_LOOP_MS);
|
delay(DELAY_LOOP_MS);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
ESP8266WebServer httpServer(8080);
|
ESP8266WebServer httpServer(8080);
|
||||||
ESP8266HTTPUpdateServer httpUpdater;
|
ESP8266HTTPUpdateServer httpUpdater;
|
||||||
|
|
||||||
|
String ip = "127.0.0.1";
|
||||||
|
String dev = "unknown";
|
||||||
|
float sensValues[6];
|
||||||
|
|
||||||
void setupWebUpdater(void)
|
void setupWebUpdater(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -22,6 +26,9 @@ void setupWebUpdater(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
httpUpdater.setup(&httpServer);
|
httpUpdater.setup(&httpServer);
|
||||||
|
|
||||||
|
httpServer.on("/", showHTMLMain); // oko specific site
|
||||||
|
|
||||||
httpServer.begin();
|
httpServer.begin();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -34,4 +41,29 @@ void doWebUpdater(void)
|
||||||
digitalWrite(D0, HIGH);
|
digitalWrite(D0, HIGH);
|
||||||
httpServer.handleClient();
|
httpServer.handleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSensorData(String device, String localip, float sensorValues[]) {
|
||||||
|
dev = device;
|
||||||
|
ip = localip;
|
||||||
|
for (uint8_t i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
sensValues[i] = sensorValues[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showHTMLMain(void) {
|
||||||
|
String message = "<html><head><title>OKO Weatherstation - " + String(dev) + "</title></head><body>"
|
||||||
|
"<br><a href=\"http://" + ip + ":8080/update\">firmware update</a><br><br>"
|
||||||
|
"<table>"
|
||||||
|
"<tr><td>temperature</td><td>" + String(sensValues[SENSOR_TEMPERATURE]) + "</td></tr>"
|
||||||
|
"<tr><td>humidity=" + String(sensValues[SENSOR_HUMIDITY]) + "</td></tr>"
|
||||||
|
"<tr><td>light=" + String(sensValues[SENSOR_LIGHT]) + "</td></tr>"
|
||||||
|
"<tr><td>windspeed=" + String(sensValues[SENSOR_WINDSPEED]) + "</td></tr>"
|
||||||
|
"<tr><td>pressure=" + String(sensValues[SENSOR_PRESSURE]) + "</td></tr>"
|
||||||
|
"<tr><td>batvoltage=" + String(sensValues[SENSOR_BAT_VOLTAGE]) + "</td></tr>";
|
||||||
|
"</table>"
|
||||||
|
"</body></html>";
|
||||||
|
|
||||||
|
httpServer.send(200, "text/html", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue