Compare commits
2 commits
3de73b2c98
...
26300287f9
Author | SHA1 | Date | |
---|---|---|---|
|
26300287f9 | ||
|
0b9b627b6b |
3 changed files with 62 additions and 29 deletions
|
@ -60,11 +60,11 @@ void setup()
|
|||
#endif
|
||||
|
||||
// Pin settings
|
||||
pinMode(BAT_CHARGED_PIN, INPUT);
|
||||
pinMode(BAT_CHARGING_PIN, INPUT);
|
||||
pinMode(STATUS_LED_PIN, OUTPUT);
|
||||
pinMode(ANEMOMETER_PIN, INPUT_PULLUP);
|
||||
pinMode(A0, INPUT);
|
||||
pinMode(BAT_CHARGED_PIN, INPUT);
|
||||
pinMode(BAT_CHARGING_PIN, INPUT);
|
||||
pinMode(STATUS_LED_PIN, OUTPUT);
|
||||
pinMode(ANEMOMETER_PIN, INPUT_PULLUP);
|
||||
pinMode(A0, INPUT);
|
||||
|
||||
digitalWrite(STATUS_LED_PIN, LOW);
|
||||
|
||||
|
@ -159,7 +159,7 @@ void wifiConnectionCheck()
|
|||
#ifdef USE_WIFIMANAGER
|
||||
|
||||
// Establish WiFi connection
|
||||
String wifiName = "oko-weather-" + DEVICE_NAME;
|
||||
const String wifiName = "oko-weather-" + DEVICE_NAME;
|
||||
|
||||
wifiManager.setMinimumSignalQuality(WIFI_MINIMUM_SIGNAL_QUALITY);
|
||||
// the time in seconds to wait for the known wifi connection
|
||||
|
@ -182,10 +182,11 @@ void wifiConnectionCheck()
|
|||
#endif
|
||||
}
|
||||
|
||||
#else // else of USE_WIFIMANAGER
|
||||
#else // else of USE_WIFIMANAGER, it is not defined
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("WLAN connection already OK");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -355,7 +356,6 @@ void _loop()
|
|||
delay(100);
|
||||
|
||||
#ifdef INFLUXDB_FEATURE
|
||||
|
||||
for (uint8_t i = 0; i < 5 and validData == false; i++)
|
||||
{
|
||||
if (currentSensorData[i] != 0)
|
||||
|
|
|
@ -7,16 +7,26 @@
|
|||
|
||||
Influxdb _influxdb(INFLUXDB_HOST, INFLUXDB_PORT);
|
||||
|
||||
const String msg = "weather,device=" + device + " ";
|
||||
|
||||
void influxdb_begin() {
|
||||
// Init variables to influxdb config - doesn't talk to database
|
||||
_influxdb.opendb(INFLUXDB_DB, INFLUXDB_USER, INFLUXDB_PASS);
|
||||
}
|
||||
|
||||
void pushToInfluxDB(String device, float sensorValues[]) {
|
||||
void pushToInfluxDB(String device, float sensorValues[])
|
||||
{
|
||||
uint8_t tries = 0;
|
||||
boolean addComma = false;
|
||||
|
||||
String msg = "weather,device=" + device + " ";
|
||||
#ifndef USE_WIFIMANAGER
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
debug("Not connected to WLAN");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(isnan(sensorValues[SENSOR_TEMPERATURE])))
|
||||
{
|
||||
msg += "temperature=" + String(sensorValues[SENSOR_TEMPERATURE]);
|
||||
|
@ -113,7 +123,16 @@ void influxdb_begin() {
|
|||
|
||||
}
|
||||
|
||||
void pushToInfluxDB(String device, float sensorValues[]) {
|
||||
void pushToInfluxDB(String device, float sensorValues[])
|
||||
{
|
||||
|
||||
#ifndef USE_WIFIMANAGER
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
debug("Not connected to WLAN");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(isnan(sensorValues[SENSOR_TEMPERATURE])))
|
||||
{
|
||||
|
@ -172,7 +191,8 @@ void pushToInfluxDB(String device, float sensorValues[]) {
|
|||
|
||||
}
|
||||
|
||||
void _writePoint() {
|
||||
void _writePoint()
|
||||
{
|
||||
|
||||
// wait unitl ready
|
||||
do {
|
||||
|
|
|
@ -26,15 +26,19 @@ String _webUpdater_ip = "127.0.0.1";
|
|||
String _webUpdater_dev = "unknown";
|
||||
float _webUpdater_sensValues[VALUES];
|
||||
|
||||
String hb_ws_msg_start = "{";
|
||||
String hb_ws_msg_temp = "\"temperature\": ";
|
||||
String hb_ws_msg_humi = "\"humidity\": ";
|
||||
String hb_ws_msg_light = "\"lightlevel\": ";
|
||||
String hb_ws_msg_windspeed = "\"windspeed\": ";
|
||||
String hb_ws_msg_pressure = "\"pressure\": ";
|
||||
String hb_ws_msg_timestamp = "\"timestamp\": ";
|
||||
String hb_ws_msg_valid = "\"valid\": ";
|
||||
String hb_ws_msg_end = "}";
|
||||
const String hb_ws_msg_start = "{";
|
||||
const String hb_ws_msg_temp = "\"temperature\": ";
|
||||
const String hb_ws_msg_humi = "\"humidity\": ";
|
||||
const String hb_ws_msg_light = "\"lightlevel\": ";
|
||||
const String hb_ws_msg_windspeed = "\"windspeed\": ";
|
||||
const String hb_ws_msg_pressure = "\"pressure\": ";
|
||||
const String hb_ws_msg_timestamp = "\"timestamp\": ";
|
||||
const String hb_ws_msg_valid = "\"valid\": ";
|
||||
const String hb_ws_msg_end = "}";
|
||||
|
||||
#define TR_TD_START_STR "<tr><td>"
|
||||
#define TR_TD_END_STR "</td></tr>"
|
||||
#define TD_TD_MID_STR "</td><td>"
|
||||
|
||||
boolean wuValidData = false;
|
||||
|
||||
|
@ -54,7 +58,9 @@ void setupWebUpdater(String device, String ip)
|
|||
httpServer.on("/hbWebstat", hb_webstat_send);
|
||||
#endif
|
||||
#ifdef DEBUG_WINDSPEED_MEASUREMENT
|
||||
#ifdef SENSOR_WIND
|
||||
httpServer.on("/measWind", measureWindspeed);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
httpServer.begin();
|
||||
|
@ -82,6 +88,7 @@ void setSensorData(float sensorValues[])
|
|||
for (uint8_t i = 0; i < VALUES; i++) {
|
||||
_webUpdater_sensValues[i] = sensorValues[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void showHTMLMain(void)
|
||||
|
@ -92,20 +99,21 @@ void showHTMLMain(void)
|
|||
"</head><body>"
|
||||
"<br><a href=\"http://" + _webUpdater_ip + ":8080/update\">firmware update</a><br><br>"
|
||||
"<table>"
|
||||
"<tr><td>temperature</td><td>" + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + "</td></tr>"
|
||||
"<tr><td>humidity</td><td>" + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + "</td></tr>"
|
||||
"<tr><td>light</td><td>" + String(_webUpdater_sensValues[SENSOR_LIGHT]) + "</td></tr>"
|
||||
"<tr><td>windspeed</td><td>" + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + "</td></tr>"
|
||||
"<tr><td>pressure</td><td>" + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + "</td></tr>"
|
||||
"<tr><td>batvoltage</td><td>" + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + "</td></tr>"
|
||||
"<tr><td>millis</td><td>" + String(millis()) + "</td></tr>"
|
||||
"<tr><td>valid</td><td>" + String(wuValidData) + "</td></tr>"
|
||||
TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "humidity" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>light" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_LIGHT]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>windspeed" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>pressure" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>batvoltage" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>millis" + TD_TD_MID_STR + String(millis()) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>valid" + TD_TD_MID_STR + String(wuValidData) + TR_TD_END_STR
|
||||
"</table>"
|
||||
"</body></html>";
|
||||
|
||||
httpServer.send(200, "text/html", message);
|
||||
}
|
||||
|
||||
#ifdef HOMEBRIDGE_WEBSTAT
|
||||
void hb_webstat_send(void)
|
||||
{
|
||||
String msg = hb_ws_msg_start +
|
||||
|
@ -133,6 +141,7 @@ void hb_webstat_send(void)
|
|||
|
||||
httpServer.send(200, "text/html", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIFIMANAGER
|
||||
void resetWifiManager()
|
||||
|
@ -158,6 +167,8 @@ void resetWifiManager()
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_WINDSPEED_MEASUREMENT
|
||||
#ifdef SENSOR_WIND
|
||||
void measureWindspeed()
|
||||
{
|
||||
|
||||
|
@ -175,3 +186,5 @@ void measureWindspeed()
|
|||
httpServer.send(200, "text/html", message);
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue