From 202aeb8212ba7b31f2377bb9034f110f7eeee3a4 Mon Sep 17 00:00:00 2001 From: Magnus Date: Fri, 7 May 2021 13:23:08 +0200 Subject: [PATCH 1/5] Added temp corrected gravity to push --- src/main.cpp | 26 +++++++++++--------------- src/pushtarget.cpp | 26 ++++++++++++++------------ src/pushtarget.h | 8 ++++---- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 63e9f66..933b8c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,9 +179,9 @@ void loop() { // If we dont get any readings we just skip this and try again the next interval. // if( myGyro.hasValue() ) { - angle = myGyro.getAngle(); // Gyro angle + angle = myGyro.getAngle(); // Gyro angle - stableGyroMillis = millis(); // Reset timer + stableGyroMillis = millis(); // Reset timer LOG_PERF_START("loop-temp-read"); float temp = myTempSensor.getTempC(); @@ -191,25 +191,21 @@ void loop() { float gravity = calculateGravity( angle, temp ); //LOG_PERF_STOP("loop-gravity-calc"); -#if LOG_LEVEL==6 - Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F." CR), angle, temp, gravity ); -#endif - if( myConfig.isGravityTempAdj() ) { - LOG_PERF_START("loop-gravity-corr"); - gravity = gravityTemperatureCorrection( gravity, temp, myConfig.getTempFormat() ); // Use default correction temperature of 20C - LOG_PERF_STOP("loop-gravity-corr"); -#if LOG_LEVEL==6 - Log.verbose(F("Main: Temp adjusted gravity=%F." CR), gravity ); -#endif - } + //LOG_PERF_START("loop-gravity-corr"); // Takes less than 2ms , so skip this measurment + // Use default correction temperature of 20C + float corrGravity = gravityTemperatureCorrection( gravity, temp, myConfig.getTempFormat() ); + //LOG_PERF_STOP("loop-gravity-corr"); +#if LOG_LEVEL==6 + Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F, corr=%F." CR), angle, temp, gravity, corrGravity ); +#endif // Limit the printout when sleep mode is not active. if( loopCounter%10 == 0 || sleepModeActive ) { - Log.notice(F("Main: angle=%F, temp=%F, gravity=%F, batt=%F." CR), angle, temp, gravity, volt ); + Log.notice(F("Main: angle=%F, temp=%F, gravity=%F, corrGravity=%F, batt=%F." CR), angle, temp, gravity, corrGravity ,volt ); } LOG_PERF_START("loop-push"); - myPushTarget.send( angle, gravity, temp, (millis()-runtimeMillis)/1000, sleepModeActive ); // Force the transmission if we are going to sleep + myPushTarget.send( angle, gravity, corrGravity, temp, (millis()-runtimeMillis)/1000, sleepModeActive ); // Force the transmission if we are going to sleep LOG_PERF_STOP("loop-push"); // If we have completed the update lets go to sleep diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index 936b3a1..149c8c1 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -30,7 +30,7 @@ PushTarget myPushTarget; // // Send the pressure value // -void PushTarget::send(float angle, float gravity, float temp, float runTime, bool force ) { +void PushTarget::send(float angle, float gravity, float corrGravity, float temp, float runTime, bool force ) { unsigned long timePassed = abs( millis() - ms ); unsigned long interval = myConfig.getSleepInterval()*1000; @@ -48,25 +48,25 @@ void PushTarget::send(float angle, float gravity, float temp, float runTime, boo if( myConfig.isBrewfatherActive() ) { LOG_PERF_START("push-brewfather"); - sendBrewfather( angle, gravity, temp ); + sendBrewfather( angle, gravity, corrGravity, temp ); LOG_PERF_STOP("push-brewfather"); } if( myConfig.isHttpActive() ) { LOG_PERF_START("push-http"); - sendHttp( myConfig.getHttpPushUrl(), angle, gravity, temp, runTime ); + sendHttp( myConfig.getHttpPushUrl(), angle, gravity, corrGravity, temp, runTime ); LOG_PERF_STOP("push-http"); } if( myConfig.isHttpActive2() ) { LOG_PERF_START("push-http2"); - sendHttp( myConfig.getHttpPushUrl2(), angle, gravity, temp, runTime ); + sendHttp( myConfig.getHttpPushUrl2(), angle, gravity, corrGravity, temp, runTime ); LOG_PERF_STOP("push-http2"); } if( myConfig.isInfluxDb2Active() ) { LOG_PERF_START("push-influxdb2"); - sendInfluxDb2( angle, gravity, temp, runTime ); + sendInfluxDb2( angle, gravity, corrGravity, temp, runTime ); LOG_PERF_STOP("push-influxdb2"); } } @@ -74,7 +74,7 @@ void PushTarget::send(float angle, float gravity, float temp, float runTime, boo // // Send to influx db v2 // -void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float runTime) { +void PushTarget::sendInfluxDb2(float angle, float gravity, float corrGravity, float temp, float runTime) { Log.notice(F("PUSH: Sending values to influxdb2 angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp ); WiFiClient client; @@ -88,10 +88,11 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run // Create body for influxdb2 char buf[1024]; sprintf( &buf[0], "measurement,host=%s,device=%s,temp-format=%c,gravity-format=%s " - "gravity=%.4f,angle=%.2f,temp=%.2f,battery=%.2f,rssi=%d,temp2=%.2f\n", + "gravity=%.4f,corr-gravity=%.4f,angle=%.2f,temp=%.2f,battery=%.2f,rssi=%d,temp2=%.2f\n", // TODO: Add support for plato format myConfig.getMDNS(), myConfig.getID(), myConfig.getTempFormat(), "SG", - gravity, angle, temp, myBatteryVoltage.getVoltage(), WiFi.RSSI(), myGyro.getSensorTempC() ); // For comparing gyro tempsensor vs DSB1820 + myConfig.isGravityTempAdj() ? corrGravity : gravity, + corrGravity, angle, temp, myBatteryVoltage.getVoltage(), WiFi.RSSI(), myGyro.getSensorTempC() ); // For comparing gyro tempsensor vs DSB1820 #if LOG_LEVEL==6 Log.verbose(F("PUSH: url %s." CR), serverPath.c_str()); @@ -115,7 +116,7 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run // // Send data to brewfather // -void PushTarget::sendBrewfather(float angle, float gravity, float temp ) { +void PushTarget::sendBrewfather(float angle, float gravity, float corrGravity, float temp ) { Log.notice(F("PUSH: Sending values to brewfather angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp ); DynamicJsonDocument doc(300); @@ -142,7 +143,7 @@ void PushTarget::sendBrewfather(float angle, float gravity, float temp ) { doc["temp_unit"] = String( myConfig.getTempFormat() ); doc["battery"] = reduceFloatPrecision( myBatteryVoltage.getVoltage(), 2 ); // TODO: Add support for plato format - doc["gravity"] = reduceFloatPrecision( gravity, 4 ); + doc["gravity"] = reduceFloatPrecision( myConfig.isGravityTempAdj() ? corrGravity : gravity, 4 ); doc["gravity_unit"] = myConfig.isGravitySG()?"G":"P"; WiFiClient client; @@ -174,7 +175,7 @@ void PushTarget::sendBrewfather(float angle, float gravity, float temp ) { // // Send data to http target // -void PushTarget::sendHttp( String serverPath, float angle, float gravity, float temp, float runTime ) { +void PushTarget::sendHttp( String serverPath, float angle, float gravity, float corrGravity, float temp, float runTime ) { Log.notice(F("PUSH: Sending values to http angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp ); DynamicJsonDocument doc(256); @@ -187,7 +188,8 @@ void PushTarget::sendHttp( String serverPath, float angle, float gravity, float doc["temperature"] = reduceFloatPrecision( temp, 1 ); doc["temp-units"] = String( myConfig.getTempFormat() ); // TODO: Add support for plato format - doc["gravity"] = reduceFloatPrecision( gravity, 4 ); + doc["gravity"] = reduceFloatPrecision( myConfig.isGravityTempAdj() ? corrGravity : gravity, 4 ); + doc["corr-gravity"] = reduceFloatPrecision( corrGravity, 4 ); doc["angle"] = reduceFloatPrecision( angle, 2); doc["battery"] = reduceFloatPrecision( myBatteryVoltage.getVoltage(), 2 ); doc["rssi"] = WiFi.RSSI(); diff --git a/src/pushtarget.h b/src/pushtarget.h index 66d2835..d05d64b 100644 --- a/src/pushtarget.h +++ b/src/pushtarget.h @@ -37,13 +37,13 @@ class PushTarget { private: unsigned long ms; // Used to check that we do not post to often - void sendBrewfather(float angle, float gravity, float temp ); - void sendHttp(String serverPath, float angle, float gravity, float temp, float runTime); - void sendInfluxDb2(float angle, float gravity, float temp, float runTime); + void sendBrewfather(float angle, float gravity, float corrGravity, float temp ); + void sendHttp(String serverPath, float angle, float gravity, float corrGravity, float temp, float runTime); + void sendInfluxDb2(float angle, float gravity, float corrGravity, float temp, float runTime); public: PushTarget() { ms = millis(); } - void send(float angle, float gravity, float temp, float runTime, bool force = false ); + void send(float angle, float gravity, float corrGravity, float temp, float runTime, bool force = false ); }; extern PushTarget myPushTarget; From 940520006a52128304078b84871d5f1d0c479460 Mon Sep 17 00:00:00 2001 From: Magnus Date: Thu, 27 May 2021 08:26:56 +0200 Subject: [PATCH 2/5] Update to wifi connection sequence + new perf target --- README.md | 6 ++++-- platformio.ini | 18 ++++++++++++++++++ script/copy_firmware.py | 2 ++ src/config.cpp | 7 +++++-- src/helper.cpp | 12 +++++++++--- src/helper.h | 1 + src/wifi.cpp | 8 +++++++- 7 files changed, 46 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e155e92..8a53569 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ http://gravmon.local/config.htm "interval": 900, "temperature": 20.5, // C or F based on setting, adjusted value. "temp-units": "C", // C or F based on setting - "gravity": 1.0050, // + "gravity": 1.0050, // Raw or temperature corrected gravity (based on setting) + "corr-gravity": 1.0050, // Temperature corrected gravity "angle": 45.34, "battery": 3.67, "rssi": -12, @@ -100,8 +101,9 @@ http://gravmon.local/config.htm ### This is the format for InfluxDB v2 ``` -measurement,host=,device=,temp-format=,gravity-format=SG gravity=1.0004,angle=45.45,temp=20.1,battery=3.96,rssi=-18 +measurement,host=,device=,temp-format=,gravity-format=SG,gravity=1.0004,corr-gravity=1.0004,angle=45.45,temp=20.1,battery=3.96,rssi=-18 ``` + ![Config - Push](img/config2.png) * The third section contains the gravity formula and also option for doing temperature compensation. The calibration formula uses two keywords, temp and tilt. Temperature is in the selected device format. diff --git a/platformio.ini b/platformio.ini index cbfdda6..c432585 100644 --- a/platformio.ini +++ b/platformio.ini @@ -72,6 +72,24 @@ extra_scripts = script/copy_firmware.py script/create_versionjson.py build_unflags = ${common_env_data.build_unflags} +build_flags = + ${common_env_data.build_flags} + -D LOG_LEVEL=4 +lib_deps = + ${common_env_data.lib_deps} +board = ${common_env_data.board} +build_type = release +board_build.filesystem = littlefs + +[env:gravity-perf] +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +framework = ${common_env_data.framework} +platform = ${common_env_data.platform} +extra_scripts = + script/copy_firmware.py + script/create_versionjson.py +build_unflags = ${common_env_data.build_unflags} build_flags = ${common_env_data.build_flags} -D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb diff --git a/script/copy_firmware.py b/script/copy_firmware.py index e49fc99..0b2cbb6 100644 --- a/script/copy_firmware.py +++ b/script/copy_firmware.py @@ -16,6 +16,8 @@ def after_build(source, target, env): target = dir + "\\bin\\firmware-debug.bin" if name == "gravity-release" : target = dir + "\\bin\\firmware.bin" + if name == "gravity-perf" : + target = dir + "\\bin\\firmware-perf.bin" print( "Copy file : " + source + " -> " + target ) shutil.copyfile( source, target ) diff --git a/src/config.cpp b/src/config.cpp index a0b77e6..ba66fc1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -40,7 +40,7 @@ Config::Config() { setTempFormat('C'); setGravityFormat('G'); setSleepInterval(900); // 15 minutes - setVoltageFactor(1.59); // Conversion factor for battery + setVoltageFactor(1.59); // Conversion factor for battery setTempSensorAdj(0.0); setGravityTempAdj(false); gyroCalibration = { 0, 0, 0, 0, 0 ,0 }; @@ -185,6 +185,8 @@ bool Config::loadFile() { setVoltageFactor( doc[ CFG_PARAM_VOLTAGEFACTOR ].as() ); if( !doc[ CFG_PARAM_GRAVITY_FORMULA ].isNull() ) setGravityFormula( doc[ CFG_PARAM_GRAVITY_FORMULA ] ); + if( !doc[ CFG_PARAM_GRAVITY_TEMP_ADJ ].isNull() ) + setGravityTempAdj( doc[ CFG_PARAM_GRAVITY_TEMP_ADJ ].as() ); if( !doc[ CFG_PARAM_GRAVITY_FORMAT ].isNull() ) { String s = doc[ CFG_PARAM_GRAVITY_FORMAT ]; setGravityFormat( s.charAt(0) ); @@ -247,11 +249,12 @@ void Config::debug() { Log.verbose(F("CFG : mDNS; '%s'." CR), getMDNS() ); Log.verbose(F("CFG : Sleep interval; %d." CR), getSleepInterval() ); Log.verbose(F("CFG : OTA; '%s'." CR), getOtaURL() ); - Log.verbose(F("CFG : Temp; %c." CR), getTempFormat() ); + Log.verbose(F("CFG : Temp Format; %c." CR), getTempFormat() ); Log.verbose(F("CFG : Temp Adj; %F." CR), getTempSensorAdj() ); Log.verbose(F("CFG : VoltageFactor; %F." CR), getVoltageFactor() ); Log.verbose(F("CFG : Gravity formula; '%s'." CR), getGravityFormula() ); Log.verbose(F("CFG : Gravity format; '%c'." CR), getGravityFormat() ); + Log.verbose(F("CFG : Gravity temp adj; %s." CR), isGravityTempAdj()?"true":"false" ); Log.verbose(F("CFG : Push brewfather; '%s'." CR), getBrewfatherPushUrl() ); Log.verbose(F("CFG : Push http; '%s'." CR), getHttpPushUrl() ); Log.verbose(F("CFG : Push http2; '%s'." CR), getHttpPushUrl2() ); diff --git a/src/helper.cpp b/src/helper.cpp index f469179..5cee407 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -31,6 +31,15 @@ SOFTWARE. SerialDebug mySerial; BatteryVoltage myBatteryVoltage; +// +// Print the heap information. +// +void printHeap() { +#if LOG_LEVEL==6 + Log.verbose(F("HELP: Heap %d kb, HeapFrag %d %%, FreeSketch %d kb." CR), ESP.getFreeHeap()/1024, ESP.getHeapFragmentation(), ESP.getFreeSketchSpace()/1024 ); +#endif +} + // // Enter deep sleep for the defined duration (Argument is seconds) // @@ -50,9 +59,6 @@ void printBuildOptions() { #ifdef SKIP_SLEEPMODE "SKIP_SLEEP " #endif -#ifdef USE_GYRO_TEMP - "GYRO_TEMP " -#endif #ifdef EMBED_HTML "EMBED_HTML " #endif diff --git a/src/helper.h b/src/helper.h index 9abf35a..f06b9f3 100644 --- a/src/helper.h +++ b/src/helper.h @@ -40,6 +40,7 @@ float reduceFloatPrecision( float f, int dec = 2 ); // Logging via serial void printTimestamp(Print* _logOutput); void printNewline(Print* _logOutput); +void printHeap(); // Classes class SerialDebug { diff --git a/src/wifi.cpp b/src/wifi.cpp index 30ed0f2..3ea2c70 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -82,18 +82,24 @@ bool Wifi::connect( bool showPortal ) { int i = 0; Log.notice(F("WIFI: Connecting to WIFI." CR)); + WiFi.mode(WIFI_STA); if( strlen(userSSID) ) { Log.notice(F("WIFI: Connecting to wifi using predefined settings %s." CR), userSSID); WiFi.begin( userSSID, userPWD ); } else { WiFi.begin(); +#if LOG_LEVEL==6 + Log.debug(F("WIFI: Using SSID=%s, KEY=%s." CR), WiFi.SSID().c_str(), WiFi.psk().c_str() ); +#endif } while( WiFi.status() != WL_CONNECTED ) { delay(100); Serial.print( "." ); - if( i++ > 60 ) { // Try for 6 seconds. +// if( i++ > 60 ) { // Try for 6 seconds. + if( i++ > 200 ) { // Try for 20 seconds. + Log.error(F("WIFI: Failed to connect to wifi, aborting." CR)); return connectedFlag; // Return to main that we have failed to connect. } } From 2cedab025018715f4d5a9d0bf76657179d4fca1d Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Sun, 30 May 2021 15:37:44 +0200 Subject: [PATCH 3/5] Updated to use new version of arduinolog --- src/helper.cpp | 2 +- src/helper.h | 2 +- src/wifi.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helper.cpp b/src/helper.cpp index 5cee407..737b15e 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -87,7 +87,7 @@ SerialDebug::SerialDebug(const long serialSpeed) { // // Print the timestamp (ms since start of device) // -void printTimestamp(Print* _logOutput) { +void printTimestamp(Print* _logOutput, int _logLevel) { char c[12]; sprintf(c, "%10lu ", millis()); _logOutput->print(c); diff --git a/src/helper.h b/src/helper.h index f06b9f3..8bd4f02 100644 --- a/src/helper.h +++ b/src/helper.h @@ -38,7 +38,7 @@ char* convertFloatToString( float f, char* buf, int dec = 2); float reduceFloatPrecision( float f, int dec = 2 ); // Logging via serial -void printTimestamp(Print* _logOutput); +void printTimestamp(Print* _logOutput, int _logLevel); void printNewline(Print* _logOutput); void printHeap(); diff --git a/src/wifi.cpp b/src/wifi.cpp index 3ea2c70..0ce6214 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -89,7 +89,7 @@ bool Wifi::connect( bool showPortal ) { } else { WiFi.begin(); #if LOG_LEVEL==6 - Log.debug(F("WIFI: Using SSID=%s, KEY=%s." CR), WiFi.SSID().c_str(), WiFi.psk().c_str() ); + Log.verbose(F("WIFI: Using SSID=%s, KEY=%s." CR), WiFi.SSID().c_str(), WiFi.psk().c_str() ); #endif } From a6e265dc48467d0c695748d92ecbdce5559d90b9 Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Thu, 10 Jun 2021 11:07:19 +0200 Subject: [PATCH 4/5] Added mDNS name at startup to identify device easier --- src/wifi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wifi.cpp b/src/wifi.cpp index 0ce6214..933dc89 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -106,6 +106,7 @@ bool Wifi::connect( bool showPortal ) { Serial.print( CR ); connectedFlag = true; Log.notice(F("WIFI: Connected to wifi ip=%s." CR), getIPAddress().c_str() ); + Log.notice(F("WIFI: Using mDNS name %s%s." CR), myConfig.getMDNS() ); return connectedFlag; } From e4e8be1d138a4723c24f53ed57f54c7daec54d5c Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Sat, 1 Jan 2022 13:53:07 +0100 Subject: [PATCH 5/5] Fixed compiler issues and bump to v0.4 --- bin/device.min.htm | 2 +- bin/version.json | 2 +- data/device.htm | 2 +- data/device.min.htm | 2 +- platformio.ini | 2 +- src/main.cpp | 2 +- src/pushtarget.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/device.min.htm b/bin/device.min.htm index 93d8388..fe90b77 100644 --- a/bin/device.min.htm +++ b/bin/device.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...

(C) Copyright 2021 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...

(C) Copyright 2021 Magnus Persson
\ No newline at end of file diff --git a/bin/version.json b/bin/version.json index 249c5d5..d2dc3aa 100644 --- a/bin/version.json +++ b/bin/version.json @@ -1 +1 @@ -{ "project":"gravmon", "version":"0.3.8", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] } \ No newline at end of file +{ "project":"gravmon", "version":"0.4.0", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] } \ No newline at end of file diff --git a/data/device.htm b/data/device.htm index 0f6526d..39acf16 100644 --- a/data/device.htm +++ b/data/device.htm @@ -97,7 +97,7 @@ $('#spinner').show(); $.getJSON(url, function (cfg) { console.log( cfg ); - $("#app-ver").text(cfg["app-ver"] + " (html 0.3.5)"); + $("#app-ver").text(cfg["app-ver"] + " (html 0.4.0)"); $("#mdns").text(cfg["mdns"]); $("#id").text(cfg["id"]); }) diff --git a/data/device.min.htm b/data/device.min.htm index 93d8388..fe90b77 100644 --- a/data/device.min.htm +++ b/data/device.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...

(C) Copyright 2021 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...

(C) Copyright 2021 Magnus Persson
\ No newline at end of file diff --git a/platformio.ini b/platformio.ini index c432585..2527a13 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,7 @@ build_flags = #-O0 -Wl,-Map,output.map -D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded) -D USER_SSID=\""\"" # =\""myssid\"" -D USER_SSID_PWD=\""\"" # =\""mypwd\"" - -D CFG_APPVER="\"0.3.8\"" + -D CFG_APPVER="\"0.4.0\"" lib_deps = # https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library https://github.com/codeplea/tinyexpr diff --git a/src/main.cpp b/src/main.cpp index 933b8c8..a4a9cfe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,7 +166,7 @@ void setup() { void loop() { drd->loop(); - if( sleepModeActive || abs(millis() - loopMillis) > interval ) { + if( sleepModeActive || abs( (long) (millis() - loopMillis)) > interval ) { float angle = 0; float volt = myBatteryVoltage.getVoltage(); //float sensorTemp = 0; diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index 149c8c1..9dcc709 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -31,7 +31,7 @@ PushTarget myPushTarget; // Send the pressure value // void PushTarget::send(float angle, float gravity, float corrGravity, float temp, float runTime, bool force ) { - unsigned long timePassed = abs( millis() - ms ); + unsigned long timePassed = abs( (long) (millis() - ms) ); unsigned long interval = myConfig.getSleepInterval()*1000; if( ( timePassed < interval ) && !force) {