a sensor hub for monitoring home environment
Dependencies: HTS221 LIS3MDL LPS22HB LSM303AGR LSM6DSL VL53L0X picojson
Fork of HelloWorld_ST_Sensors by
Diff: main.h
- Revision:
- 12:058b012dbebe
- Parent:
- 11:1e0b9a529ee0
- Child:
- 13:f8e84b12665c
--- a/main.h Tue Dec 12 03:01:51 2017 +0000 +++ b/main.h Mon Dec 18 16:45:32 2017 +0000 @@ -11,15 +11,23 @@ #include "lis3mdl_class.h" #include "VL53L0X.h" #include "wifi.h" +#include "picojson.h" /* Syncing Params */ #define SENSE_PERIOD_S 5.0 #define UPLOAD_PERIOD_S 30.0 #define CHECK_PROXIMITY_PERIOD_S 1.0 +// Influx TSDB http server #define INFLUX_SERVER_URL "rpi1.nrjy.com" #define INFLUX_SERVER_PORT 8086 +// time server to get current unix time and sync rtc +#define TIME_SERVER_URL "www.convert-unix-time.com" +#define TIME_SERVER_PORT 80 +#define TIME_SERVER_QUERY "/api?timestamp=now&timezone=New_York" + + #define WIFI_WRITE_TIMEOUT 5000 #define WIFI_READ_TIMEOUT 5000 #define CONNECTION_TRIAL_MAX 5 @@ -39,12 +47,12 @@ DigitalOut ledhttp(LED2);// Http activity - /* Operation flags */ volatile bool sense_enabled = false; volatile bool take_measurements = false; volatile bool send_measurements = false; volatile bool check_proximity = false; +bool rtc_synced = false; bool WiFi_on = false; @@ -67,12 +75,13 @@ /* Environment variables */ +uint32_t distance_val = 0; float tempC_val = 0; float tempF_val = 0; float RH_val = 0; float Patm_val = 0; float tempC_val2 = 0; -int32_t distance = 0; + /* Comm vars */ @@ -94,5 +103,6 @@ void time_to_sense_cb(void); void time_to_send_cb(void); void time_to_check_distance_cb(void); -void sync_time(void); +bool sync_rtc(void); +bool getCurrentTime(uint8_t socket_id, uint32_t *timeStamp); // void toggle_led3_cb();