feature/http_call_send_json #3

Merged
f merged 56 commits from feature/http_call_send_json into master 2022-11-27 11:02:22 +01:00
3 changed files with 27 additions and 6 deletions
Showing only changes of commit 0ae44ec987 - Show all commits

View file

@ -1,6 +1,5 @@
// Copy this file to config_user.h and adjust it to your needs. // Copy this file to config_user.h and adjust it to your needs.
#ifndef __CONFIG_USER_H__ #ifndef __CONFIG_USER_H__
#define __CONFIG_USER_H__ #define __CONFIG_USER_H__
@ -52,12 +51,19 @@ String DEVICE_NAME = "weatherstation";
//#define DEBUG_WINDSPEED_MEASUREMENT //#define DEBUG_WINDSPEED_MEASUREMENT
//#define HTTP_CALL_ON_WINDSPEED_EXCEED //#define HTTP_CALL_ON_WINDSPEED_EXCEED
//#define HTTP_CALL_SEND_JSON_DATA //#define HTTP_CALL_SEND_JSON_DATA
//#define SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
/********************************************************************************/
// measurement correction factors
const float HUMIDITY_FACTOR = 1.0; const float HUMIDITY_FACTOR = 1.0;
const float LIGHT_FACTOR = 1.0; const float LIGHT_FACTOR = 1.0;
const float TEMP_FACTOR = 1.0; const float TEMP_FACTOR = 1.0;
// InfluxDB credentials /********************************************************************************/
// InfluxDB1 credentials
const char *INFLUXDB_HOST = "hostname"; const char *INFLUXDB_HOST = "hostname";
const uint16_t INFLUXDB_PORT = 80; const uint16_t INFLUXDB_PORT = 80;
const char *INFLUXDB_DB = "database"; const char *INFLUXDB_DB = "database";
@ -70,7 +76,8 @@ const char *INFLUXDB_URL = "http://192.168.0.123:3124";
const char *INFLUXDB_ORG = "home_org"; const char *INFLUXDB_ORG = "home_org";
const char *INFLUXDB_BUCKET = "mybucket"; const char *INFLUXDB_BUCKET = "mybucket";
const char *INFLUXDB_TOKEN = "your api token"; const char *INFLUXDB_TOKEN = "your api token";
*/
/********************************************************************************/
// enable HTTP_CALL_ON_WINDSPEED_EXCEED to enable this feature // enable HTTP_CALL_ON_WINDSPEED_EXCEED to enable this feature
#define HTTP_CALL_ON_WINDSPEED_EXCEED_MPS 5.0 // 5.0 m/s == 18 km/h #define HTTP_CALL_ON_WINDSPEED_EXCEED_MPS 5.0 // 5.0 m/s == 18 km/h

View file

@ -530,7 +530,9 @@ void _fsm_loop()
case FSM_STATE_8: case FSM_STATE_8:
//debug("set sensor data in webupdater if required"); //debug("set sensor data in webupdater if required");
#ifdef WEBUPDATER_FEATURE #ifdef WEBUPDATER_FEATURE
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
setSensorData(currentSensorData); setSensorData(currentSensorData);
#endif
#endif #endif
fsm_state = FSM_STATE_1; fsm_state = FSM_STATE_1;
@ -611,9 +613,11 @@ void _fsm_loop()
} }
#ifdef WEBUPDATER_FEATURE #ifdef WEBUPDATER_FEATURE
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
sentWindspeed(currentSensorData[SENSOR_WINDSPEED]); sentWindspeed(currentSensorData[SENSOR_WINDSPEED]);
#endif #endif // SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
#endif #endif // WEBUPDATER_FEATURE
#endif // HTTP_CALL_ON_WINDSPEED_EXCEED
// step into read of next fsm state // step into read of next fsm state
fsm_state = FSM_STATE_2; fsm_state = FSM_STATE_2;
@ -661,8 +665,10 @@ void _battery_mode_main() {
#endif #endif
#ifdef WEBUPDATER_FEATURE #ifdef WEBUPDATER_FEATURE
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
setSensorData(currentSensorData); setSensorData(currentSensorData);
#endif #endif
#endif
} }
//*************************************************************************// //*************************************************************************//

View file

@ -23,7 +23,10 @@ ESP8266HTTPUpdateServer httpUpdater;
String _webUpdater_ip = "127.0.0.1"; String _webUpdater_ip = "127.0.0.1";
String _webUpdater_dev = "unknown"; String _webUpdater_dev = "unknown";
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
float _webUpdater_sensValues[VALUES]; float _webUpdater_sensValues[VALUES];
#endif
#define TR_TD_START_STR "<tr><td>" #define TR_TD_START_STR "<tr><td>"
#define TR_TD_END_STR "</td></tr>" #define TR_TD_END_STR "</td></tr>"
@ -70,17 +73,19 @@ void doWebUpdater(void)
} }
//*************************************************************************// //*************************************************************************//
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
void sentWindspeed(float ws) void sentWindspeed(float ws)
{ {
_webUpdater_sensValues[SENSOR_WINDSPEED] = ws; _webUpdater_sensValues[SENSOR_WINDSPEED] = ws;
} }
#endif
void setWifiReconnectCnt(uint32_t wrc) void setWifiReconnectCnt(uint32_t wrc)
{ {
_wifi_reconnect_cnt = wrc; _wifi_reconnect_cnt = wrc;
} }
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
void setSensorData(float sensorValues[]) void setSensorData(float sensorValues[])
{ {
@ -102,6 +107,7 @@ void setSensorData(float sensorValues[])
} }
} }
} }
#endif
//*************************************************************************// //*************************************************************************//
@ -121,6 +127,7 @@ void showHTMLMain(void)
#ifdef HOMEBRIDGE_WEBSTAT #ifdef HOMEBRIDGE_WEBSTAT
"<br><a href=\"http://" + _webUpdater_ip + ":8080/hbWebstat\">homebridge websatt</a><br>" "<br><a href=\"http://" + _webUpdater_ip + ":8080/hbWebstat\">homebridge websatt</a><br>"
#endif #endif
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
"<br><br><table>" "<br><br><table>"
TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR 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 + "humidity" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + TR_TD_END_STR
@ -133,6 +140,7 @@ void showHTMLMain(void)
TR_TD_START_STR + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() + TR_TD_END_STR TR_TD_START_STR + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() + TR_TD_END_STR
TR_TD_START_STR + "wifi rec cnt" + TD_TD_MID_STR + String(_wifi_reconnect_cnt) + TR_TD_END_STR TR_TD_START_STR + "wifi rec cnt" + TD_TD_MID_STR + String(_wifi_reconnect_cnt) + TR_TD_END_STR
"</table>" "</table>"
#endif
#ifndef DISABLE_WIFIMANAGER #ifndef DISABLE_WIFIMANAGER
"<br><br><br><br><br><a href=\"http://" + _webUpdater_ip + ":8080/resetWifiManager\">reset WiFi Manager</a><br>" "<br><br><br><br><br><a href=\"http://" + _webUpdater_ip + ":8080/resetWifiManager\">reset WiFi Manager</a><br>"
#endif #endif