27 Commits

Author SHA1 Message Date
a5f7f0f8a4 Updated release notes for beta 2 2022-07-29 08:37:34 +02:00
7826e56d8a GitHub Action Build 2022-07-27 22:03:51 +00:00
353d6d77e1 Minor fixes for new features 2022-07-27 23:58:25 +02:00
437873489e Added ver and build into templating 2022-07-27 13:11:17 +02:00
e34e73fae2 GitHub Action Build 2022-07-27 06:49:27 +00:00
69a4c5607c Merge branch 'dev' of https://github.com/mp-se/gravitymon into dev 2022-07-27 08:44:48 +02:00
d980fdae1a Adding sw ver to template engine 2022-07-27 08:44:32 +02:00
272e349375 GitHub Action Build 2022-07-27 06:18:09 +00:00
34d46ef768 Updated error message 2022-07-27 08:12:44 +02:00
588ff2d1e0 GitHub Action Build 2022-07-27 06:07:51 +00:00
5d1811d240 Updated config view 2022-07-27 08:02:19 +02:00
85e602d29b GitHub Action Build 2022-07-27 05:56:41 +00:00
8ee882c522 Adjusted error handling and formula deviation 2022-07-27 07:52:03 +02:00
51e7ee6867 GitHub Action Build 2022-07-27 05:48:54 +00:00
70858ef841 Updated error msg 2022-07-27 07:45:02 +02:00
83bd80ba28 GitHub Action Build 2022-07-27 05:43:50 +00:00
d33576b2df Increase size of buffer 2022-07-27 07:39:31 +02:00
5c9525c0c5 GitHub Action Build 2022-07-26 19:28:17 +00:00
ad8704fc20 Changed error message in formula validation 2022-07-26 21:23:50 +02:00
f1c1958f88 Merge branch 'dev' of https://github.com/mp-se/gravitymon into dev 2022-07-26 21:11:24 +02:00
e5394113e4 Updated HA integration 2022-07-26 21:11:16 +02:00
6d4e713da8 GitHub Action Build 2022-07-23 07:08:20 +00:00
36a858af2d Merge branch 'dev' of https://github.com/mp-se/gravitymon into dev 2022-07-23 09:00:46 +02:00
77d2c15e39 Updated docs for v1.1 beta 2 2022-07-23 08:58:48 +02:00
9df072cc78 GitHub Action Build 2022-07-07 10:25:06 +00:00
bedbda4662 Made cal temp adjustable in UI 2022-07-07 11:11:45 +02:00
76702dfc95 Fix #90 2022-07-07 10:13:17 +02:00
29 changed files with 207 additions and 81 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -107,7 +107,7 @@
<div class="row mb-3">
<label for="mdns" class="col-sm-2 col-form-label">Device name</label>
<div class="col-sm-3">
<input type="text" maxlength="12" class="form-control" name="mdns" id="mdns" placeholder="gravmon" data-bs-toggle="tooltip" title="Name of the device. Will be used for identifying the device when pushing data and on the local network.">
<input type="text" maxlength="63" class="form-control" name="mdns" id="mdns" placeholder="gravmon" data-bs-toggle="tooltip" title="Name of the device. Will be used for identifying the device when pushing data and on the local network.">
</div>
</div>
@ -506,9 +506,9 @@
<div class="row mb-3">
<label for="formula-max-deviation" class="col-sm-3 col-form-label">Formula max deviation (SG)</label>
<div class="col-sm-3">
<input disabled type="number" step=".1" min="1" max="10" class="form-control" name="formula-max-deviation" id="formula-max-deviation" placeholder="1.6" checked data-bs-toggle="tooltip" title="When validating the derived formula this is the maximum accepted deviation for the supplied values">
<input disabled type="number" step=".1" min="1" max="10" class="form-control" name="formula-max-deviation" id="formula-max-deviation" placeholder="3" checked data-bs-toggle="tooltip" title="When validating the derived formula this is the maximum accepted deviation for the supplied values">
</div>
<div class="col-sm-5">(1 - 10) - default 1.6 SG</div>
<div class="col-sm-5">(1 - 10) - default 3 SG</div>
</div>
<div class="row mb-3">
@ -521,6 +521,14 @@
<div class="col-sm-5" name="water-angle" id="water-angle"></div>
</div>
<div class="row mb-3">
<label for="formula-calibration-temp" class="col-sm-3 col-form-label">Gravity calibration temp</label>
<div class="col-sm-3">
<input disabled type="number" step=".01" min="0" max="100" class="form-control" name="formula-calibration-temp" id="formula-calibration-temp" placeholder="20" checked data-bs-toggle="tooltip" title="Calibration temperature, used in temperatur correction formula, default 20C/68F">
</div>
<div class="col-sm-5">(0 - 100) - default 20C/68F</div>
</div>
<hr>
<div class="row mb-3">
@ -780,6 +788,7 @@
$("#formula-max-deviation").prop("disabled", b);
$("#wifi-portal-timeout").prop("disabled", b);
$("#wifi-connect-timeout").prop("disabled", b);
$("#formula-calibration-temp").prop("disabled", b);
$("#int-http1").prop("disabled", b);
$("#int-http2").prop("disabled", b);
$("#int-http3").prop("disabled", b);
@ -806,14 +815,15 @@
$("#wifi-connect-timeout").val(cfg["wifi-connect-timeout"]);
$("#tempsensor-resolution").val(cfg["tempsensor-resolution"]);
$("#ignore-low-angles").prop( "checked", cfg["ignore-low-angles"] );
$("#formula-calibration-temp").val(cfg["formula-calibration-temp"]);
$("#int-http1").val(cfg["int-http1"]);
$("#int-http2").val(cfg["int-http2"]);
$("#int-http3").val(cfg["int-http3"]);
$("#int-influx").val(cfg["int-influx"]);
$("#int-mqtt").val(cfg["int-mqtt"]);
if ( cfg["gyro-read-count"] != 50 || cfg["gyro-moving-threashold"] != 500 || cfg["formula-max-deviation"] != 1.6 || cfg["wifi-portal-timeout"] != 120 || cfg["wifi-connect-timeout"] != 20 || cfg["tempsensor-resolution"] != 9 ||
cfg["int-http1"] != 0 || cfg["int-http2"] != 0 || cfg["int-http3"] != 0 || cfg["int-influx"] != 0 || cfg["int-mqtt"] != 0 || cfg["ignore-low-angles"] != false ) {
if ( cfg["gyro-read-count"] != 50 || cfg["gyro-moving-threashold"] != 500 || cfg["formula-max-deviation"] != 3 || cfg["wifi-portal-timeout"] != 120 || cfg["wifi-connect-timeout"] != 20 || cfg["tempsensor-resolution"] != 9 ||
cfg["int-http1"] != 0 || cfg["int-http2"] != 0 || cfg["int-http3"] != 0 || cfg["int-influx"] != 0 || cfg["int-mqtt"] != 0 || cfg["ignore-low-angles"] != false || (cfg["formula-calibration-temp"] != 20 && cfg["formula-calibration-temp"] != 68)) {
$("#adv-config").attr("checked", false );
}
})

File diff suppressed because one or more lines are too long

View File

@ -101,7 +101,8 @@
{ "id": "iSpindle-Post", "format": "%7B%20%22name%22%20%3A%20%22%24%7Bmdns%7D%22%2C%20%22ID%22%3A%20%22%24%7Bid%7D%22%2C%20%22token%22%20%3A%20%22%24%7Btoken%7D%22%2C%20%22interval%22%3A%20%24%7Bsleep-interval%7D%2C%20%22temperature%22%3A%20%24%7Btemp%7D%2C%20%22temp_units%22%3A%20%22%24%7Btemp-unit%7D%22%2C%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%20%22angle%22%3A%20%24%7Bangle%7D%2C%20%22battery%22%3A%20%24%7Bbattery%7D%2C%20%22RSSI%22%3A%20%24%7Brssi%7D%7D" },
{ "id": "BrewFatherCustom-Post", "format": "%7B%20%20%20%22name%22%3A%20%22%24%7Bmdns%7D%22%2C%20%20%20%22temp%22%3A%20%24%7Btemp%7D%2C%20%20%20%22aux_temp%22%3A%200%2C%20%20%20%22ext_temp%22%3A%200%2C%20%20%20%22temp_unit%22%3A%20%22%24%7Btemp-unit%7D%22%2C%20%20%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%20%20%20%22gravity_unit%22%3A%20%22%24%7Bgravity-unit%7D%22%2C%20%20%20%22pressure%22%3A%200%2C%20%20%20%22pressure_unit%22%3A%20%22PSI%22%2C%20%20%20%22ph%22%3A%200%2C%20%20%20%22bpm%22%3A%200%2C%20%20%20%22comment%22%3A%20%22%22%2C%20%20%20%22beer%22%3A%20%22%22%2C%20%20%20%22battery%22%3A%20%24%7Bbattery%7D%7D" },
{ "id": "iSpindle-Mqtt", "format": "ispindel%2F%24%7Bmdns%7D%2Ftilt%3A%24%7Bangle%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2Ftemperature%3A%24%7Btemp%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2Ftemp_units%3A%24%7Btemp-unit%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2Fbattery%3A%24%7Bbattery%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2Fgravity%3A%24%7Bgravity%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2Finterval%3A%24%7Bsleep-interval%7D%7C%0Aispindel%2F%24%7Bmdns%7D%2FRSSI%3A%24%7Brssi%7D%7C" },
{ "id": "HomeAssistant-Mqtt", "format": "gravmon%2F%24%7Bmdns%7D%2Ftilt%3A%24%7Bangle%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Ftemperature%3A%24%7Btemp%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Ftemp_units%3A%24%7Btemp-unit%7D%7C" },
{ "id": "HomeAssistant-Mqtt", "format": "gravmon%2F%24%7Bmdns%7D%2Ftemperature%3A%24%7Btemp%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Fgravity%3A%24%7Bgravity%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Frssi%3A%24%7Brssi%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Ftilt%3A%24%7Btilt%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Fbattery%3A%24%7Bbattery%7D%7C%0A" },
{ "id": "HomeAssistant-Mqtt2", "format": "gravmon%2F%24%7Bmdns%7D%2Ftemperature%3A%24%7Btemp%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Fgravity%3A%24%7Bgravity%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Frssi%3A%24%7Brssi%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Ftilt%3A%24%7Btilt%7D%7C%0Agravmon%2F%24%7Bmdns%7D%2Fbattery%3A%24%7Bbattery%7D%7C%0Ahomeassistant%2Fsensor%2Fgravmon_%24%7Bid%7D%2Ftemperature%2Fconfig%3A%7B%22dev%22%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%22mdl%22%3A%22gravmon%22%2C%22sw%22%3A%22%24%7Bapp-ver%7D%22%2C%22ids%22%3A%22%24%7Bid%7D%22%7D%2C%22uniq_id%22%3A%22%24%7Bid%7D_temp%22%2C%22name%22%3A%22temperature%22%2C%22dev_cla%22%3A%22temperature%22%2C%22unit_of_meas%22%3A%22%24%7Btemp-unit%7D%22%2C%22stat_t%22%3A%22gravmon%2F%24%7Bmdns%7D%2Ftemperature%22%7D%7C%0Ahomeassistant%2Fsensor%2Fgravmon_%24%7Bid%7D%2Fgravity%2Fconfig%3A%7B%22dev%22%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%22mdl%22%3A%22gravmon%22%2C%22sw%22%3A%22%24%7Bapp-ver%7D%22%2C%22ids%22%3A%22%24%7Bid%7D%22%7D%2C%22uniq_id%22%3A%22%24%7Bid%7D_grav%22%2C%22name%22%3A%22gravity%22%2C%22dev_cla%22%3A%22temperature%22%2C%22unit_of_meas%22%3A%22%20%24%7Bgravity-unit%7D%22%2C%22stat_t%22%3A%22gravmon%2F%24%7Bmdns%7D%2Fgravity%22%7D%7C%0Ahomeassistant%2Fsensor%2Fgravmon_%24%7Bid%7D%2Frssi%2Fconfig%3A%7B%22dev%22%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%22mdl%22%3A%22gravmon%22%2C%22sw%22%3A%22%24%7Bapp-ver%7D%22%2C%22ids%22%3A%22%24%7Bid%7D%22%7D%2C%22uniq_id%22%3A%22%24%7Bid%7D_rssi%22%2C%22name%22%3A%22rssi%22%2C%22dev_cla%22%3A%22temperature%22%2C%22unit_of_meas%22%3A%22dBm%22%2C%22stat_t%22%3A%22gravmon%2F%24%7Bmdns%7D%2Frssi%22%7D%7C%0Ahomeassistant%2Fsensor%2Fgravmon_%24%7Bid%7D%2Ftilt%2Fconfig%3A%7B%22dev%22%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%22mdl%22%3A%22gravmon%22%2C%22sw%22%3A%22%24%7Bapp-ver%7D%22%2C%22ids%22%3A%22%24%7Bid%7D%22%7D%2C%22uniq_id%22%3A%22%24%7Bid%7D_tilt%22%2C%22name%22%3A%22tilt%22%2C%22dev_cla%22%3A%22temperature%22%2C%22stat_t%22%3A%22gravmon%2F%24%7Bmdns%7D%2Ftilt%22%7D%7C%0Ahomeassistant%2Fsensor%2Fgravmon_%24%7Bid%7D%2Fbattery%2Fconfig%3A%7B%22dev%22%3A%7B%22name%22%3A%22%24%7Bmdns%7D%22%2C%22mdl%22%3A%22gravmon%22%2C%22sw%22%3A%22%24%7Bapp-ver%7D%22%2C%22ids%22%3A%22%24%7Bid%7D%22%7D%2C%22uniq_id%22%3A%22%24%7Bid%7D_batt%22%2C%22name%22%3A%22battery%22%2C%22dev_cla%22%3A%22temperature%22%2C%22unit_of_meas%22%3A%22V%22%2C%22stat_t%22%3A%22gravmon%2F%24%7Bmdns%7D%2Fbattery%22%7D%7C%0A" },
{ "id": "Brewblox-Mqtt", "format": "brewcast%2Fhistory%3A%7B%22key%22%3A%22%24%7Bmdns%7D%22%2C%22data%22%3A%7B%22Temperature%5BdegC%5D%22%3A%20%24%7Btemp-c%7D%2C%22Temperature%5BdegF%5D%22%3A%20%24%7Btemp-f%7D%2C%22Battery%5BV%5D%22%3A%24%7Bbattery%7D%2C%22Tilt%5Bdeg%5D%22%3A%24%7Bangle%7D%2C%22Rssi%5BdBm%5D%22%3A%24%7Brssi%7D%2C%22SG%22%3A%24%7Bgravity-sg%7D%2C%22Plato%22%3A%24%7Bgravity-plato%7D%7D%7D%7C" },
{ "id": "UBIDots-Post", "format": "%7B%0A%20%20%20%22temperature%22%3A%20%24%7Btemp%7D%2C%0A%20%20%20%22gravity%22%3A%20%24%7Bgravity%7D%2C%0A%20%20%20%22angle%22%3A%20%24%7Bangle%7D%2C%0A%20%20%20%22battery%22%3A%20%24%7Bbattery%7D%2C%0A%20%20%20%22rssi%22%3A%20%24%7Brssi%7D%0A%7D" } ];
</script>
@ -116,6 +117,7 @@
<option value="GravityMon-Post">GravityMon (POST)</option>
<option value="iSpindle-Mqtt">iSpindle (MQTT)</option>
<option value="HomeAssistant-Mqtt">Home Assistant (MQTT)</option>
<option value="HomeAssistant-Mqtt2">Home Assistant - Auto register sensor (MQTT)</option>
<option value="UBIDots-Post">UBIdots (POST)</option>
<option value="BrewFatherCustom-Post">Brewfather - Custom Endpoint (POST)</option>
<option value="iSpindle-Post">Brewfather - iSpindle Endpoint (POST)</option>
@ -238,6 +240,8 @@
doc = doc.replaceAll("${corr-gravity}", cfg["gravity"]);
doc = doc.replaceAll("${angle}", cfg["angle"]);
doc = doc.replaceAll("${tilt}", cfg["angle"]);
doc = doc.replaceAll("${app-ver}", cfg["app-ver"]);
doc = doc.replaceAll("${app-build}", cfg["app-build"]);
// Format in a readable json string.
try {

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,7 @@ build_flags =
-D USER_SSID=\""\"" # =\""myssid\""
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
-D CFG_APPVER="\"1.1.0\""
-D CFG_GITREV=\""beta-1\""
-D CFG_GITREV=\""beta-2\""
#!python script/git_rev.py
lib_deps = # Switched to forks for better version control.
# Using local copy of these libraries

View File

@ -98,18 +98,18 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer,
// If the deviation is more than 2 degress we mark it as failed.
if (dev * 1000 > myAdvancedConfig.getMaxFormulaCreationDeviation()) {
char s[20];
snprintf(&s[0], sizeof(s), "%.8f", dev);
Log.error(F("CALC: Deviation to large: %s" CR), &s[0]);
char s[120];
snprintf(&s[0], sizeof(s),
"CALC: Validation failed on angle %f, deviation too large "
"%.2f SG, formula order %d",
fd.a[i], dev * 1000, order);
ErrorFileLog errLog;
errLog.addEntry(&s[0]);
valid = false;
}
}
if (!valid) {
ErrorFileLog errLog;
errLog.addEntry(
F("CALC: Error validating created formula. Deviation to large, "
"formula rejected."));
return ERR_FORMULA_UNABLETOFFIND;
}

View File

@ -32,9 +32,8 @@ SOFTWARE.
double calculateGravity(double angle, double tempC,
const char *tempFormula = 0);
double gravityTemperatureCorrectionC(
double gravity, double tempC,
double calTempC = myAdvancedConfig.getDefaultCalibrationTemp());
double gravityTemperatureCorrectionC(double gravity, double tempC,
double calTempC);
int createFormula(RawFormulaData &fd, char *formulaBuffer,
int formulaBufferSize, int order);

View File

@ -150,7 +150,7 @@ bool Config::saveFile() {
return false;
}
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
DynamicJsonDocument doc(3000);
createJson(doc);
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
@ -192,7 +192,7 @@ bool Config::loadFile() {
Log.notice(F("CFG : Size of configuration file=%d bytes." CR),
configFile.size());
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
DynamicJsonDocument doc(3000);
DeserializationError err = deserializeJson(doc, configFile);
#if LOG_LEVEL == 6
serializeJson(doc, Serial);

View File

@ -27,8 +27,6 @@ SOFTWARE.
#include <helper.hpp>
#include <resources.hpp>
#define CFG_JSON_BUFSIZE 3192
#define CFG_APPNAME "GravityMon" // Name of firmware
#define CFG_FILENAME "/gravitymon.json" // Name of config file
#define CFG_HW_FILENAME "/hardware.json" // Name of config file for hw
@ -56,12 +54,12 @@ struct RawFormulaData {
class AdvancedConfig {
private:
int _wifiPortalTimeout = 120;
int _wifiConnectTimeout = 20;
float _maxFormulaCreationDeviation = 1.6;
float _defaultCalibrationTemp = 20.0;
int _wifiPortalTimeout = 120; // seconds
int _wifiConnectTimeout = 20; // seconds
float _maxFormulaCreationDeviation = 3; // SG
float _defaultCalibrationTemp = 20.0; // C
int _gyroSensorMovingThreashold = 500;
int _tempSensorResolution = 9;
int _tempSensorResolution = 9; // bits
int _gyroReadCount = 50;
int _gyroReadDelay = 3150; // us, empirical, to hold sampling to 200 Hz
int _pushTimeout = 10; // seconds

View File

@ -279,7 +279,12 @@ bool loopReadGravity() {
LOG_PERF_STOP("loop-temp-read");
float gravitySG = calculateGravity(angle, tempC);
float corrGravitySG = gravityTemperatureCorrectionC(gravitySG, tempC);
float corrGravitySG = gravityTemperatureCorrectionC(
gravitySG, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
if (myConfig.isGravityTempAdj()) {
gravitySG = corrGravitySG;
}
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%FC, gravity=%F, "

View File

@ -130,6 +130,9 @@ void TemplatingEngine::initialize(float angle, float gravitySG,
setVal(TPL_GRAVITY_CORR_P, convertToPlato(corrGravitySG), 1);
setVal(TPL_GRAVITY_UNIT, myConfig.getGravityFormat());
setVal(TPL_APP_VER, CFG_APPVER);
setVal(TPL_APP_BUILD, CFG_GITREV);
#if LOG_LEVEL == 6
// dumpAll();
#endif

View File

@ -53,6 +53,8 @@ SOFTWARE.
#define TPL_GRAVITY_CORR_G "${corr-gravity-sg}"
#define TPL_GRAVITY_CORR_P "${corr-gravity-plato}"
#define TPL_GRAVITY_UNIT "${gravity-unit}" // G or P
#define TPL_APP_VER "${app-ver}"
#define TPL_APP_BUILD "${app-build}"
#define TPL_FNAME_HTTP1 "/http-1.tpl"
#define TPL_FNAME_HTTP2 "/http-2.tpl"
@ -73,7 +75,7 @@ class TemplatingEngine {
String val;
};
KeyVal items[21] = {{TPL_MDNS, ""}, {TPL_ID, ""},
KeyVal items[23] = {{TPL_MDNS, ""}, {TPL_ID, ""},
{TPL_SLEEP_INTERVAL, ""}, {TPL_TEMP, ""},
{TPL_TEMP_C, ""}, {TPL_TEMP_F, ""},
{TPL_TEMP_UNITS, ""}, {TPL_BATTERY, ""},
@ -83,7 +85,8 @@ class TemplatingEngine {
{TPL_GRAVITY_P, ""}, {TPL_GRAVITY_CORR, ""},
{TPL_GRAVITY_CORR_G, ""}, {TPL_GRAVITY_CORR_P, ""},
{TPL_GRAVITY_UNIT, ""}, {TPL_TOKEN, ""},
{TPL_TOKEN2, ""}};
{TPL_TOKEN2, ""}, {TPL_APP_VER, ""},
{TPL_APP_BUILD, ""}};
char buffer[20];
String baseTemplate;

View File

@ -44,12 +44,15 @@ void WebServerHandler::webHandleConfig() {
LOG_PERF_START("webserver-api-config");
Log.notice(F("WEB : webServer callback for /api/config(get)." CR));
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
DynamicJsonDocument doc(2000);
myConfig.createJson(doc);
doc[PARAM_PASS] = ""; // dont show the wifi password
doc[PARAM_PASS2] = "";
doc[PARAM_APP_VER] = String(CFG_APPVER);
doc[PARAM_APP_BUILD] = String(CFG_GITREV);
double angle = 0;
if (myGyro.hasValue()) angle = myGyro.getAngle();
@ -69,8 +72,8 @@ void WebServerHandler::webHandleConfig() {
doc[PARAM_TEMP_ADJ] = reduceFloatPrecision(myConfig.getTempSensorAdjC(), 1);
if (myConfig.isGravityTempAdj()) {
gravity =
gravityTemperatureCorrectionC(gravity, tempC, myConfig.getTempFormat());
gravity = gravityTemperatureCorrectionC(
gravity, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
}
if (myConfig.isGravityPlato()) {
@ -97,8 +100,9 @@ void WebServerHandler::webHandleConfig() {
#endif
String out;
out.reserve(CFG_JSON_BUFSIZE);
out.reserve(2000);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-config");
}
@ -160,6 +164,7 @@ void WebServerHandler::webHandleUpload() {
String out;
out.reserve(300);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-upload");
}
@ -325,7 +330,7 @@ void WebServerHandler::webHandleStatus() {
LOG_PERF_START("webserver-api-status");
Log.notice(F("WEB : webServer callback for /api/status(get)." CR));
DynamicJsonDocument doc(512);
DynamicJsonDocument doc(500);
double angle = 0;
@ -337,7 +342,8 @@ void WebServerHandler::webHandleStatus() {
doc[PARAM_ID] = myConfig.getID();
doc[PARAM_ANGLE] = reduceFloatPrecision(angle);
if (myConfig.isGravityTempAdj()) {
gravity = gravityTemperatureCorrectionC(gravity, tempC);
gravity = gravityTemperatureCorrectionC(
gravity, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
}
if (myConfig.isGravityPlato()) {
doc[PARAM_GRAVITY] = reduceFloatPrecision(convertToPlato(gravity), 1);
@ -376,8 +382,9 @@ void WebServerHandler::webHandleStatus() {
#endif
String out;
out.reserve(300);
out.reserve(500);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-status");
}
@ -671,9 +678,11 @@ void WebServerHandler::webHandleConfigAdvancedWrite() {
if (_server->hasArg(PARAM_HW_FORMULA_DEVIATION))
myAdvancedConfig.setMaxFormulaCreationDeviation(
_server->arg(PARAM_HW_FORMULA_DEVIATION).toFloat());
if (_server->hasArg(PARAM_HW_FORMULA_CALIBRATION_TEMP))
myAdvancedConfig.SetDefaultCalibrationTemp(
_server->arg(PARAM_HW_FORMULA_CALIBRATION_TEMP).toFloat());
if (_server->hasArg(PARAM_HW_FORMULA_CALIBRATION_TEMP)) {
float t = _server->arg(PARAM_HW_FORMULA_CALIBRATION_TEMP).toFloat();
if (myConfig.isTempF()) t = convertFtoC(t);
myAdvancedConfig.SetDefaultCalibrationTemp(t);
}
if (_server->hasArg(PARAM_HW_WIFI_PORTAL_TIMEOUT))
myAdvancedConfig.setWifiPortalTimeout(
_server->arg(PARAM_HW_WIFI_PORTAL_TIMEOUT).toInt());
@ -722,7 +731,7 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
LOG_PERF_START("webserver-api-config-advanced");
Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR));
DynamicJsonDocument doc(512);
DynamicJsonDocument doc(500);
doc[PARAM_HW_GYRO_READ_COUNT] = myAdvancedConfig.getGyroReadCount();
// doc[PARAM_HW_GYRO_READ_DELAY] = myAdvancedConfig.getGyroReadDelay();
@ -733,8 +742,9 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
doc[PARAM_HW_WIFI_PORTAL_TIMEOUT] = myAdvancedConfig.getWifiPortalTimeout();
doc[PARAM_HW_WIFI_CONNECT_TIMEOUT] = myAdvancedConfig.getWifiConnectTimeout();
doc[PARAM_HW_PUSH_TIMEOUT] = myAdvancedConfig.getPushTimeout();
float t = myAdvancedConfig.getDefaultCalibrationTemp();
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] =
myAdvancedConfig.getDefaultCalibrationTemp();
myConfig.isTempC() ? t : reduceFloatPrecision(convertCtoF(t), 1);
doc[PARAM_HW_PUSH_INTERVAL_HTTP1] = myAdvancedConfig.getPushIntervalHttp1();
doc[PARAM_HW_PUSH_INTERVAL_HTTP2] = myAdvancedConfig.getPushIntervalHttp2();
doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = myAdvancedConfig.getPushIntervalHttp3();
@ -750,8 +760,9 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
#endif
String out;
out.reserve(512);
out.reserve(500);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-config-advanced");
}
@ -763,7 +774,7 @@ void WebServerHandler::webHandleFormulaRead() {
LOG_PERF_START("webserver-api-formula-read");
Log.notice(F("WEB : webServer callback for /api/formula(get)." CR));
DynamicJsonDocument doc(512);
DynamicJsonDocument doc(500);
const RawFormulaData& fd = myConfig.getFormulaData();
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
@ -781,10 +792,13 @@ void WebServerHandler::webHandleFormulaRead() {
doc[PARAM_ERROR] = "Internal error creating formula.";
break;
case ERR_FORMULA_NOTENOUGHVALUES:
doc[PARAM_ERROR] = "Not enough values to create formula.";
doc[PARAM_ERROR] =
"Not enough values to create formula, need at least 3 angles.";
break;
case ERR_FORMULA_UNABLETOFFIND:
doc[PARAM_ERROR] = "Unable to find an accurate formula based on input.";
doc[PARAM_ERROR] =
"Unable to find an accurate formula based on input, check error log "
"and graph below.";
break;
default:
doc[PARAM_GRAVITY_FORMULA] = myConfig.getGravityFormula();
@ -832,8 +846,9 @@ void WebServerHandler::webHandleFormulaRead() {
#endif
String out;
out.reserve(256);
out.reserve(500);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-formula-read");
}
@ -908,7 +923,8 @@ void WebServerHandler::webHandleTestPush() {
float angle = myGyro.getAngle();
float tempC = myTempSensor.getTempC(myConfig.isGyroTemp());
float gravitySG = calculateGravity(angle, tempC);
float corrGravitySG = gravityTemperatureCorrectionC(gravitySG, tempC);
float corrGravitySG = gravityTemperatureCorrectionC(
gravitySG, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
TemplatingEngine engine;
engine.initialize(angle, gravitySG, corrGravitySG, tempC, 2.1);
@ -943,6 +959,7 @@ void WebServerHandler::webHandleTestPush() {
String out;
out.reserve(100);
serializeJson(doc, out);
doc.clear();
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
serializeJson(doc, Serial);
@ -1005,7 +1022,7 @@ void WebServerHandler::webHandleConfigFormatRead() {
LOG_PERF_START("webserver-api-config-format-read");
Log.notice(F("WEB : webServer callback for /api/config/formula(get)." CR));
DynamicJsonDocument doc(2048);
DynamicJsonDocument doc(5000);
doc[PARAM_ID] = myConfig.getID();
@ -1045,8 +1062,9 @@ void WebServerHandler::webHandleConfigFormatRead() {
#endif
String out;
out.reserve(2048);
out.reserve(3000);
serializeJson(doc, out);
doc.clear();
_server->send(200, "application/json", out.c_str());
LOG_PERF_STOP("webserver-api-config-format-read");
}

View File

@ -99,4 +99,10 @@ These are the format keys available for use in the format.
* - ${gravity-unit}
- Gravity format, `G` or `P`
- G
* - ${app-ver}
- Software version
- 1.1.0
* - ${app-build}
- Software revision (git hash)
- ..e456743

View File

@ -55,7 +55,8 @@ Device Setting
* **Device name:**
This is unique name for the device. It will be used in pushing data as well as mDNS name on the network (<name>.local)
This is unique name for the device. It will be used in pushing data as well as mDNS name on the network (<name>.local).
The limitation is 63 chars but using long names might break endpoints that data is sent to if they have other limitations.
* **Temperature format:**

View File

@ -9,8 +9,31 @@ Create formula
Here you can enter up to 10 values (angles + gravity) that is then used to create the formula. Angles equal to zero will be regarded as empty even if there is a gravity reading.
When you submit the values the device will try create a forumla with increasing level of complexity. It will start
with a order 2 formula and then try 3 and 4.
Once the formula has been created it will validate the formula against the supplied angles/gravity and if there is a too
high difference, it will fail. You can adjust the sensitivity under advanced settings if you have issues.
Under the Error Log you will also find hints to what problem the formula creator encountered. Here is an example:
`CALC: Validation failed on angle 33.430000, deviation too large 5.86, formula order 4`
`CALC: Validation failed on angle 33.430000, deviation too large 3.14, formula order 2`
This means that the angle 33.43 had a deviation of 5.8 SG and since the default threashold is 3, it will fail. You
can also see that it has failed on that point in both a order 2 and 4 formula.
.. image:: images/qa_1.png
:width: 400
:alt: Example of deviating value
So in this case you can either increase the threashold or remove the angle that has an issue. You can also
use the graph on the calibration page to identify angles that is probably not correct.
.. image:: images/formula2.png
:width: 800
:alt: Formula graph
Once the formula is created a graph over the entered values and a simulation of the formula will give you a nice overview on how the formula will work.

View File

@ -7,7 +7,7 @@ Welcome to GravityMon's documentation!
######################################
.. note::
This documentation reflects **v1.1 BETA 1**. Last updated 2022-07-06
This documentation reflects **v1.1 BETA 2**. Last updated 2022-07-23
* Docs for: `v1.0 <https://mp-se.github.io/gravitymon/v1.0/index.html>`_
* Docs for: `v0.9 <https://mp-se.github.io/gravitymon/v0.9/index.html>`_

View File

@ -19,6 +19,12 @@ Step 2 - Setup WIFI
When the device starts up the first time it will first start an WIFI access point so that the WIFI Settings
can be configured. The instructions for that can be found here :ref:`setup_wifi`
.. note::
Since the user interface is built using modern frameworks the device requires access to the internet
for the UI to render and data to be populated. The sites that are needed are; https://cdn.jsdelivr.net/npm/bootstrap
and https://code.jquery.com
Step 3 - Configuration
----------------------

View File

@ -29,3 +29,19 @@ To fix these this you can;
- change the advanced setting (Formula max deviation) to a higher value and save the values again.
In the case above this paramater was changed from 1.6 SG to 4 SG and the formula was accepted. The deviation on this point was just above 3 SG.
User interface does not render correctly
----------------------------------------
Since the user interface is built using bootstrap v5 the device requires access to the internet
to download required javascripts and css files. Due to size it would not be possible to store these
on the device. Make sure the device can access: https://cdn.jsdelivr.net/npm/bootstrap
Data is not popoulated in the fields
------------------------------------
The user interface uses JQuery to fetch data from the device. This javascript library needs to be downloaded
from the internet. Due to size it would not be possible to store these on the device. Make sure the
device can access: https://code.jquery.com
Also ensure that any security tools does not block the execution of these features.

View File

@ -3,8 +3,8 @@
Releases
########
v1.1.0
======
v1.1.0 - beta 2
===============
Documentation
+++++++++++++
@ -13,17 +13,25 @@ Documentation
* Added documentation for Brewpiless as target
* Updated docs for ubidots service integration.
* Added brewblox as new service
* (beta2) Updated docs for HA integration since method was depricated
User interface
++++++++++++++
* Under format options its now possible to select brewfather ispindle format to avoid mixing endpoints.
* Added brewblox as format under format options.
* User can now edit the voltage level that forces the device into config mode (charging)
* (beta2) Calibration temperature (for temp adjustment) can now be set under advanced settings.
* (beta2) Changes length of device name from 12 to 63 chars. 63 is the max limit according to mdns.
Features
++++++++
* Added storage mode which is activated under hardware setting. When place on the cap (<5 degres tilt) the device will go into
storage mode and sleep for the max allowed time.
* Added storage mode which is activated under hardware setting. When place on the cap (<5 degres tilt) the device will go into storage mode and sleep for the max allowed time.
* Added ${app-ver} and ${app-build} to format template as new variables.
* Added format templates for HA auto registration
* (beta2) Improved error messages when creating formula so the meaasurement points can be identified.
* (beta2) Changed defaule validation threashold from 1.6 SG to 3.0 SG, this should allow for some more variance when creating formula.
* (beta2) Updated format template for Home Assistant for using manual configuration (Aligned with new mqtt configuration format)
* (beta2) Added format template for Home Assistant with automatic device registration
Other
+++++
@ -36,6 +44,9 @@ Issues adressed
++++++++++++++++
* BUG: Copy format templates used an old format for iSpindle and Gravmon where the token was not used.
* BUG: Gravity correction formula not calculating correctly.
* (beta2) BUG: Temp corrected gravity was not used when pushing data to removed
* (beta2) BUG: Low memory in format api which resulted in mqtt template to be set to null
* (beta2) BUG: Large format templates could be saved but when loading it's only blank. Increased total memory from 3kb to 5kb
v1.0.0
======

View File

@ -129,7 +129,7 @@ format template that can be used. For information on customizing the format see
Home Assistant
+++++++++++++++
`HomeAssistant <https://www.homeassistant.com>`_ is a platform for home automation and can collect sensor data
`HomeAssistant <https://www.homeassistant.io>`_ is a platform for home automation and can collect sensor data
from multiple devices.
This setup uses the MQTT integration with home assistant to collect values from the device.
@ -139,31 +139,50 @@ device is named `gravmon2`
::
mqtt:
sensor:
- platform: mqtt
name: "gravmon2_gravity"
state_topic: "gravmon/gravmon2/gravity"
- platform: mqtt
name: "gravmon2_battery"
state_topic: "gravmon/gravmon2/battery"
- platform: mqtt
name: "gravmon2_rssi"
state_topic: "gravmon/gravmon2/RSSI"
- platform: mqtt
name: "gravmon2_temp"
state_topic: "gravmon/gravmon2/temp"
- name: "Gravmon2-Gravity"
state_topic: "gravmon/gravmon2/gravity"
unique_id: gravmon2_grav
unit_of_measurement: "SG"
- name: "Gravmon2-RSSI"
state_topic: "gravmon/gravmon2/rssi"
unique_id: gravmon2_rssi
unit_of_measurement: "dBm"
Enter the name of the MQTT server in Home Assistant in the URL. You might need to install that option
first. This is the format needed to submit the data to the correct topics as needed above. You can add as
many sensors / topics as you want.
many sensors / topics as you want. It's also possible that you will need to create a user and supply the
username / password to be able to publish messages on a topic.
::
gravmon/${mdns}/gravity:${gravity}|
gravmon/${mdns}/rssi:${rssi}|
gravmon/${mdns}/battery:${battery}|
gravmon/${mdns}/RSSI:${rssi}|
gravmon/${mdns}/temp:${temp}|
It's also possible to allow home assistant to do autodisovery and automatically create the sensor. This format
template will create two sensors and update the values for them.
.. warning::
This will only work on 1.1+ since the the memory allocation on previous versions are not enough to handle this large payload.
Earlier version can handle 2 of the values.
::
gravmon/${mdns}/temperature:${temp}|
gravmon/${mdns}/gravity:${gravity}|
gravmon/${mdns}/rssi:${rssi}|
gravmon/${mdns}/tilt:${tilt}|
gravmon/${mdns}/battery:${battery}|
homeassistant/sensor/gravmon_${id}/temperature/config:{"dev":{"name":"${mdns}","mdl":"gravmon","sw":"${app-ver}","ids":"${id}"},"uniq_id":"${id}_temp","name":"temperature","dev_cla":"temperature","unit_of_meas":"${temp-unit}","stat_t":"gravmon/${mdns}/temperature"}|
homeassistant/sensor/gravmon_${id}/gravity/config:{"dev":{"name":"${mdns}","mdl":"gravmon","sw":"${app-ver}","ids":"${id}"},"uniq_id":"${id}_grav","name":"gravity","dev_cla":"temperature","unit_of_meas":" ${gravity-unit}","stat_t":"gravmon/${mdns}/gravity"}|
homeassistant/sensor/gravmon_${id}/rssi/config:{"dev":{"name":"${mdns}","mdl":"gravmon","sw":"${app-ver}","ids":"${id}"},"uniq_id":"${id}_rssi","name":"rssi","dev_cla":"temperature","unit_of_meas":"dBm","stat_t":"gravmon/${mdns}/rssi"}|
homeassistant/sensor/gravmon_${id}/tilt/config:{"dev":{"name":"${mdns}","mdl":"gravmon","sw":"${app-ver}","ids":"${id}"},"uniq_id":"${id}_tilt","name":"tilt","dev_cla":"temperature","stat_t":"gravmon/${mdns}/tilt"}|
homeassistant/sensor/gravmon_${id}/battery/config:{"dev":{"name":"${mdns}","mdl":"gravmon","sw":"${app-ver}","ids":"${id}"},"uniq_id":"${id}_batt","name":"battery","dev_cla":"temperature","unit_of_meas":"V","stat_t":"gravmon/${mdns}/battery"}|
Brewer's Friend

View File

@ -4,13 +4,13 @@
"formula-max-deviation": 1.6,
"wifi-portal-timeout": 120,
"wifi-connect-timeout": 20,
"formula-calibration-temp": 20,
"tempsensor-resolution": 9,
"ignore-low-angles": false,
"push-timeout": 10,
"formula-calibration-temp": 20,
"int-http1": 0,
"int-http2": 0,
"int-http3": 0,
"int-influx": 0,
"int-mqtt": 0
"int-mqtt": 0,
"tempsensor-resolution": 9,
"ignore-low-angles": false
}

View File

@ -64,5 +64,7 @@
"battery": 0.04,
"runtime-average": 3.0,
"ble": "pink",
"app-ver": "0.1.0",
"app-build": "build",
"platform": "esp32"
}