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