Compare commits
69 Commits
v1.1.0-bet
...
v1.1.0
Author | SHA1 | Date | |
---|---|---|---|
059865f271 | |||
a9deb588aa | |||
0de8971255 | |||
08a102159b | |||
8b13b4769c | |||
c3044f9878 | |||
0a4e7f37b2 | |||
69f4b8ec3d | |||
d4c88c1200 | |||
4bbfb77361 | |||
655235fc4e | |||
4b0e5b393a | |||
db590f8f5f | |||
4c805fe235 | |||
34a1d7d3c3 | |||
bcee0e21da | |||
9fc5ab147d | |||
b3a89a1fcc | |||
03b58eb112 | |||
63ddcfbb57 | |||
68d44a5846 | |||
45294f6b07 | |||
09d8226af1 | |||
6c94c6b204 | |||
9e437d1e0d | |||
a486f1be30 | |||
0536b14280 | |||
a6bff7287e | |||
414d7d51c2 | |||
640733f143 | |||
f6196e6dbf | |||
f857dab3c0 | |||
787c5c09bb | |||
afe3ec2412 | |||
980099a5e5 | |||
99d577d4a0 | |||
6db6e96d90 | |||
92df08baa2 | |||
5466550f68 | |||
94f703b087 | |||
57e078986b | |||
e445e7649c | |||
a5f7f0f8a4 | |||
7826e56d8a | |||
353d6d77e1 | |||
437873489e | |||
e34e73fae2 | |||
69a4c5607c | |||
d980fdae1a | |||
272e349375 | |||
34d46ef768 | |||
588ff2d1e0 | |||
5d1811d240 | |||
85e602d29b | |||
8ee882c522 | |||
51e7ee6867 | |||
70858ef841 | |||
83bd80ba28 | |||
d33576b2df | |||
5c9525c0c5 | |||
ad8704fc20 | |||
f1c1958f88 | |||
e5394113e4 | |||
6d4e713da8 | |||
36a858af2d | |||
77d2c15e39 | |||
9df072cc78 | |||
bedbda4662 | |||
76702dfc95 |
34
README.md
34
README.md
@ -21,18 +21,24 @@ Note! If Brewflasher being flagged as malware by your antivirus software, try th
|
||||
The main differences:
|
||||
---------------------
|
||||
|
||||
* Modern web based user interface for configuration when connected to WIFI
|
||||
* Efficient software, long lifespan (+45 days with 5min update frequencey)
|
||||
* Send data to multiple endpoints (http-post, http-get, influxdb v2, mqtt)
|
||||
* Instructions for service such as; Brewfather, Fermentrack, Ubidots, Home Assistant, Brewers Friend, Brewspy, Thingspeak, Blynk.
|
||||
* SSL support for all remote endpoints
|
||||
* ESP32 support with Bluetooth push
|
||||
* Customize data format to be pushed
|
||||
* Automatic temperature adjustment of gravity when enabled
|
||||
* Use the temperature sensor in gyro instead of DS18B20
|
||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity.
|
||||
* Visual graph showing how gravity formula will be interpreted
|
||||
* OTA support or firmware upload via web interface
|
||||
* REST API for scripting
|
||||
|
||||
* Operates in two modes gravity monitoring and configuration mode
|
||||
* Gravity mode is comparable to how the iSpindle works when collectintg data
|
||||
* Configuration mode has a modern HTML5 based web UI. No need to start the access point to change settings
|
||||
* Offloading some of the functionallity to run in the web browser, this allows for more advanced features.
|
||||
* REST API to enable scripted configuration
|
||||
* Send data to multiple endpoints and services at once (2xHTTP POST, HTTP GET, MQTT, INFLUXDB2)
|
||||
* Directly test all endpoints from user interface with feedback to simplify troubleshooting
|
||||
* Complete format customization for all endpoints using templates (dont really need to change the software to support new services)
|
||||
* Setup guides for how to send data to many popular services. Currently 10+ are documented
|
||||
* Automatic temperature adjustment of gravity (just tick a checkbox)
|
||||
* OTA support from webserver
|
||||
* Firmware update via web interface
|
||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity and let GravityMon creates a formula
|
||||
* Visual graph showing how formula will be interpreted based on entered values
|
||||
* Using the temperature sensor in gyro instead of DS18B20 (faster)
|
||||
* SSL support in all endpoints (no certificate validation due to limitations on esp8266).
|
||||
* Built in performance measurements (used to optimise code)
|
||||
* Storage mode when placed on cap (indefinite sleep)
|
||||
* Customize various hardware parameters to opimize device functionallity.
|
||||
*
|
||||
No code has been reused from the iSpindle project.
|
||||
|
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item active"><a class="nav-link" href="#"><b>About</b></a></li></ul></div></div></nav><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingAbout"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAbout" aria-expanded="true" aria-controls="collapseAbout"><b>About</b></button></h2><div id="collapseAbout" class="accordion-collapse collapse show" aria-labelledby="headingAbout" data-bs-parent="#accordion"><div class="accordion-body"><div class="row h3 col-sm-8">Beer Gravity Monitor</div><div class="row col-sm-8 mb-3">This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.</div><div class="row h3 col-sm-8 mb-3">MIT License</div><div class="row col-sm-8 mb-3">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</div><div class="row h3 col-sm-8 mb-3">Credits to</div><div class="row col-sm-8 mb-3">This software uses the following libraries and without these this software would have been much more difficult to acheive:<br><br><ul><li>https://github.com/jrowberg/i2cdevlib</li><li>https://github.com/codeplea/tinyexpr</li><li>https://github.com/graphitemaster/incbin</li><li>https://github.com/khoih-prog/ESP_DoubleResetDetector</li><li>https://github.com/khoih-prog/ESP_WiFiManager</li><li>https://github.com/thijse/Arduino-Log</li><li>https://github.com/bblanchon/ArduinoJson</li><li>https://github.com/PaulStoffregen/OneWire</li><li>https://github.com/milesburton/Arduino-Temperature-Control-Library</li><li>https://github.com/Rotario</li><li>https://github.com/256dpi/arduino-mqtt</li><li>https://graphjs.com</li><li>https://getbootstrap.com</li><li>https://github.com/lorol/LITTLEFS</li><li>https://github.com/h2zero/NimBLE-Arduino</li><li>https://github.com/spouliot/tilt-sim</li></ul></div></div></div></div></div></div><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Configuration</a><ul class="dropdown-menu"><li><a class="dropdown-item" href="/config.htm">Configuration</a></li><li><a class="dropdown-item" href="/format.htm">Format editor</a></li><li><a class="dropdown-item" href="/test.htm">Test push</a></li><li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item"><a class="nav-link active" href="#">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></div></nav><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingAbout"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAbout" aria-expanded="true" aria-controls="collapseAbout"><b>About</b></button></h2><div id="collapseAbout" class="accordion-collapse collapse show" aria-labelledby="headingAbout" data-bs-parent="#accordion"><div class="accordion-body"><div class="row h3 col-sm-8">Beer Gravity Monitor</div><div class="row col-sm-8 mb-3">This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.</div><div class="row h3 col-sm-8 mb-3">MIT License</div><div class="row col-sm-8 mb-3">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</div><div class="row h3 col-sm-8 mb-3">Credits to</div><div class="row col-sm-8 mb-3">This software uses the following libraries and without these this software would have been much more difficult to acheive:<br><br><ul><li>https://github.com/jrowberg/i2cdevlib</li><li>https://github.com/codeplea/tinyexpr</li><li>https://github.com/graphitemaster/incbin</li><li>https://github.com/khoih-prog/ESP_DoubleResetDetector</li><li>https://github.com/khoih-prog/ESP_WiFiManager</li><li>https://github.com/thijse/Arduino-Log</li><li>https://github.com/bblanchon/ArduinoJson</li><li>https://github.com/PaulStoffregen/OneWire</li><li>https://github.com/milesburton/Arduino-Temperature-Control-Library</li><li>https://github.com/Rotario</li><li>https://github.com/256dpi/arduino-mqtt</li><li>https://graphjs.com</li><li>https://getbootstrap.com</li><li>https://github.com/lorol/LITTLEFS</li><li>https://github.com/h2zero/NimBLE-Arduino</li><li>https://github.com/spouliot/tilt-sim</li></ul></div></div></div></div></div></div><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
BIN
bin/firmware.bin
BIN
bin/firmware.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -28,17 +28,26 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/config.htm">Configuration</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#"><b>About</b></a>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="spinner-border text-light" id="spinner" role="status"></div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item active"><a class="nav-link" href="#"><b>About</b></a></li></ul></div></div></nav><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingAbout"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAbout" aria-expanded="true" aria-controls="collapseAbout"><b>About</b></button></h2><div id="collapseAbout" class="accordion-collapse collapse show" aria-labelledby="headingAbout" data-bs-parent="#accordion"><div class="accordion-body"><div class="row h3 col-sm-8">Beer Gravity Monitor</div><div class="row col-sm-8 mb-3">This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.</div><div class="row h3 col-sm-8 mb-3">MIT License</div><div class="row col-sm-8 mb-3">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</div><div class="row h3 col-sm-8 mb-3">Credits to</div><div class="row col-sm-8 mb-3">This software uses the following libraries and without these this software would have been much more difficult to acheive:<br><br><ul><li>https://github.com/jrowberg/i2cdevlib</li><li>https://github.com/codeplea/tinyexpr</li><li>https://github.com/graphitemaster/incbin</li><li>https://github.com/khoih-prog/ESP_DoubleResetDetector</li><li>https://github.com/khoih-prog/ESP_WiFiManager</li><li>https://github.com/thijse/Arduino-Log</li><li>https://github.com/bblanchon/ArduinoJson</li><li>https://github.com/PaulStoffregen/OneWire</li><li>https://github.com/milesburton/Arduino-Temperature-Control-Library</li><li>https://github.com/Rotario</li><li>https://github.com/256dpi/arduino-mqtt</li><li>https://graphjs.com</li><li>https://getbootstrap.com</li><li>https://github.com/lorol/LITTLEFS</li><li>https://github.com/h2zero/NimBLE-Arduino</li><li>https://github.com/spouliot/tilt-sim</li></ul></div></div></div></div></div></div><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Configuration</a><ul class="dropdown-menu"><li><a class="dropdown-item" href="/config.htm">Configuration</a></li><li><a class="dropdown-item" href="/format.htm">Format editor</a></li><li><a class="dropdown-item" href="/test.htm">Test push</a></li><li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item"><a class="nav-link active" href="#">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></div></nav><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingAbout"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAbout" aria-expanded="true" aria-controls="collapseAbout"><b>About</b></button></h2><div id="collapseAbout" class="accordion-collapse collapse show" aria-labelledby="headingAbout" data-bs-parent="#accordion"><div class="accordion-body"><div class="row h3 col-sm-8">Beer Gravity Monitor</div><div class="row col-sm-8 mb-3">This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.</div><div class="row h3 col-sm-8 mb-3">MIT License</div><div class="row col-sm-8 mb-3">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</div><div class="row h3 col-sm-8 mb-3">Credits to</div><div class="row col-sm-8 mb-3">This software uses the following libraries and without these this software would have been much more difficult to acheive:<br><br><ul><li>https://github.com/jrowberg/i2cdevlib</li><li>https://github.com/codeplea/tinyexpr</li><li>https://github.com/graphitemaster/incbin</li><li>https://github.com/khoih-prog/ESP_DoubleResetDetector</li><li>https://github.com/khoih-prog/ESP_WiFiManager</li><li>https://github.com/thijse/Arduino-Log</li><li>https://github.com/bblanchon/ArduinoJson</li><li>https://github.com/PaulStoffregen/OneWire</li><li>https://github.com/milesburton/Arduino-Temperature-Control-Library</li><li>https://github.com/Rotario</li><li>https://github.com/256dpi/arduino-mqtt</li><li>https://graphjs.com</li><li>https://getbootstrap.com</li><li>https://github.com/lorol/LITTLEFS</li><li>https://github.com/h2zero/NimBLE-Arduino</li><li>https://github.com/spouliot/tilt-sim</li></ul></div></div></div></div></div></div><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2021-22 Magnus Persson</div></body></html>
|
@ -16,8 +16,6 @@
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<!-- START MENU -->
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
||||
@ -29,11 +27,19 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/config.htm">Configuration</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#"><b>Calibration</b></a>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">Calibration</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/about.htm">About</a>
|
||||
|
File diff suppressed because one or more lines are too long
@ -28,8 +28,16 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#"><b>Configuration</b></a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
@ -107,7 +115,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 +514,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 +529,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 +796,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 +823,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
@ -15,8 +15,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- START MENU -->
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
||||
@ -24,9 +22,26 @@
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="javascript:history.back()">Back to configuration</a>
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="#">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/about.htm">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -34,6 +49,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<!-- START MAIN INDEX -->
|
||||
|
||||
<div class="container row-margin-10">
|
||||
@ -135,7 +151,7 @@
|
||||
showError("Upload failed");
|
||||
},
|
||||
success: function(resp) {
|
||||
showSuccess("Upload completed, device is restarting. Waiting 10 seconds to refresh browser.");
|
||||
showSuccess("Upload completed, device is restarting. Waiting 10 seconds to refresh browser. If you don't get any gyro readings after update, please press the reset button!");
|
||||
setTimeout(() => {
|
||||
window.location = "/";
|
||||
}, 10000);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><!-- START MENU --><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav mr-auto"><li class="nav-item"><a class="nav-link" href="javascript:history.back()">Back to configuration</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></div></nav><!-- START MAIN INDEX --><div class="container row-margin-10"><div class="alert alert-success alert-dismissible hide fade d-none" role="alert"><div id="alert"></div><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("hide").addClass("show").removeClass("d-none"),$("#alert").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("hide").addClass("show").removeClass("d-none"),$("#alert").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("hide").removeClass("show").addClass("d-none")})</script><div class="accordion" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingFirmware"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseFirmware" aria-expanded="true" aria-controls="collapseFirmware"><b>Upload firmware</b></button></h2><div id="collapseFirmware" class="accordion-collapse collapse show" aria-labelledby="headingFirmware" data-bs-parent="#accordion"><div class="accordion-body"><div class="row mb-3"><div class="col-md-12 themed-grid-col bg-light">Here you can upload a new firmware version, it will not check the version number so you can also downgrade the firmware here.</div></div><div class="row mb-3"><div class="col-md-2 themed-grid-col bg-light">Current version:</div><div class="col-md-10 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3"><div class="col-md-2 themed-grid-col bg-light">Platform:</div><div class="col-md-10 themed-grid-col bg-light" id="platform">Loading...</div></div><form id="uploadForm" enctype="multipart/form-data"><div class="row mb-3"><div class="col-md-8 custom-file"><input type="file" accept=".bin" class="custom-file-input" name="name" id="name" onchange="checkName()" data-bs-toggle="tooltip" title="Select a firmware file to upload"></div></div><div class="row mb-3"><div class="col-md-4"><button type="submit" class="btn btn-primary" id="upload-btn" value="upload" data-bs-toggle="tooltip" title="Update the device with the selected firmware">Flash firmware</button></div></div></form><div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div></div></div></div></div><script type="text/javascript">window.onload = getStatus;
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><nav class="navbar navbar-expand-lg navbar-dark bg-primary"><div class="container"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarNav"><ul class="navbar-nav"><li class="nav-item"><a class="nav-link" href="/index.htm">Home</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Configuration</a><ul class="dropdown-menu"><li><a class="dropdown-item" href="/config.htm">Configuration</a></li><li><a class="dropdown-item" href="/format.htm">Format editor</a></li><li><a class="dropdown-item" href="/test.htm">Test push</a></li><li><a class="dropdown-item" href="#">Upload firmware</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/calibration.htm">Calibration</a></li><li class="nav-item"><a class="nav-link" href="/about.htm">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></div></nav><!-- START MAIN INDEX --><div class="container row-margin-10"><div class="alert alert-success alert-dismissible hide fade d-none" role="alert"><div id="alert"></div><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("hide").addClass("show").removeClass("d-none"),$("#alert").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("hide").addClass("show").removeClass("d-none"),$("#alert").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("hide").removeClass("show").addClass("d-none")})</script><div class="accordion" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingFirmware"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseFirmware" aria-expanded="true" aria-controls="collapseFirmware"><b>Upload firmware</b></button></h2><div id="collapseFirmware" class="accordion-collapse collapse show" aria-labelledby="headingFirmware" data-bs-parent="#accordion"><div class="accordion-body"><div class="row mb-3"><div class="col-md-12 themed-grid-col bg-light">Here you can upload a new firmware version, it will not check the version number so you can also downgrade the firmware here.</div></div><div class="row mb-3"><div class="col-md-2 themed-grid-col bg-light">Current version:</div><div class="col-md-10 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3"><div class="col-md-2 themed-grid-col bg-light">Platform:</div><div class="col-md-10 themed-grid-col bg-light" id="platform">Loading...</div></div><form id="uploadForm" enctype="multipart/form-data"><div class="row mb-3"><div class="col-md-8 custom-file"><input type="file" accept=".bin" class="custom-file-input" name="name" id="name" onchange="checkName()" data-bs-toggle="tooltip" title="Select a firmware file to upload"></div></div><div class="row mb-3"><div class="col-md-4"><button type="submit" class="btn btn-primary" id="upload-btn" value="upload" data-bs-toggle="tooltip" title="Update the device with the selected firmware">Flash firmware</button></div></div></form><div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div></div></div></div></div><script type="text/javascript">window.onload = getStatus;
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#uploadForm").on('submit', function(e) {
|
||||
@ -26,7 +26,7 @@
|
||||
showError("Upload failed");
|
||||
},
|
||||
success: function(resp) {
|
||||
showSuccess("Upload completed, device is restarting. Waiting 10 seconds to refresh browser.");
|
||||
showSuccess("Upload completed, device is restarting. Waiting 10 seconds to refresh browser. If you don't get any gyro readings after update, please press the reset button!");
|
||||
setTimeout(() => {
|
||||
window.location = "/";
|
||||
}, 10000);
|
||||
|
157
html/format.htm
157
html/format.htm
@ -15,8 +15,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- START MENU -->
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
||||
@ -24,9 +22,26 @@
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="javascript:history.back()">Back to configuration</a>
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="#">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/about.htm">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -34,29 +49,54 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<!-- START MAIN INDEX -->
|
||||
|
||||
<div class="container row-margin-10">
|
||||
|
||||
<div class="alert alert-success alert-dismissible hide fade d-none" role="alert">
|
||||
<div id="alert"></div>
|
||||
<div class="alert alert-success alert-dismissible hide fade d-none" role="alert" id="alert">
|
||||
<div id="alert-msg"></div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning alert-dismissible hide fade d-none" role="alert" id="warning-ha">
|
||||
<div>Home Assistant device configuration detected in MQTT format. These messages will be posted when format is saved and not during gravity measurement.</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning alert-dismissible hide fade d-none" role="alert" id="warning-length">
|
||||
<div>The format template is quite large, its possible the device will not have enough memory to handle it.</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function showError( msg ) {
|
||||
$('.alert').removeClass('alert-success').addClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
||||
$('#alert').text( msg );
|
||||
$('#alert').removeClass('alert-success').addClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
||||
$('#alert-msg').text( msg );
|
||||
}
|
||||
|
||||
function showSuccess( msg ) {
|
||||
$('.alert').addClass('alert-success').removeClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
||||
$('#alert').text( msg );
|
||||
$('#alert').addClass('alert-success').removeClass('alert-danger').removeClass('hide').addClass('show').removeClass('d-none');
|
||||
$('#alert-msg').text( msg );
|
||||
}
|
||||
|
||||
$("#alert-btn").click(function(e){
|
||||
$('.alert').addClass('hide').removeClass('show').addClass('d-none');
|
||||
$('#alert').addClass('hide').removeClass('show').addClass('d-none');
|
||||
});
|
||||
|
||||
function showWarningHomeAssistant() {
|
||||
$('#warning-ha').removeClass('d-none').addClass('show').removeClass('hide');
|
||||
}
|
||||
function hideWarningHomeAssistant() {
|
||||
$('#warning-ha').addClass('d-none').removeClass('show').addClass('hide');
|
||||
}
|
||||
|
||||
function showWarningLength() {
|
||||
$('#warning-length').removeClass('d-none').addClass('show').removeClass('hide');
|
||||
}
|
||||
function hideWarningLength() {
|
||||
$('#warning-length').addClass('d-none').removeClass('show').addClass('hide');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="accordion" id="accordion">
|
||||
@ -89,7 +129,7 @@
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="10" class="form-control" name="format" id="format">
|
||||
<textarea rows="10" class="form-control" name="format" id="format" onchange="updateStatusField()" onkeydown="updateStatusField()">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
@ -101,7 +141,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%22signal_strength%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%22voltage%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 +157,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>
|
||||
@ -128,6 +170,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8" id="status">
|
||||
</div>
|
||||
|
||||
<hr class="my-2">
|
||||
|
||||
<pre class="card-preview" id="preview" name="preview"></pre>
|
||||
@ -141,6 +186,8 @@
|
||||
<script type="text/javascript">
|
||||
window.onload = getConfig;
|
||||
|
||||
var maxCharsInFormatTemplate = 1500;
|
||||
|
||||
setButtonDisabled( true );
|
||||
|
||||
// Opens the targetet according (if URL has #collapseOne to #collapseFour)
|
||||
@ -151,6 +198,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
function updateStatusField() {
|
||||
var t = $("#format").val();
|
||||
$("#status").text( t.length + " characters in template, recommended maximum is " + maxCharsInFormatTemplate );
|
||||
|
||||
if (t.length > maxCharsInFormatTemplate) {
|
||||
showWarningLength();
|
||||
} else {
|
||||
hideWarningLength();
|
||||
}
|
||||
};
|
||||
|
||||
$("#push-target").change(function(e){
|
||||
console.log(e)
|
||||
selectFormat();
|
||||
@ -167,29 +225,88 @@
|
||||
$("#format").val( decodeURIComponent(item.format) );
|
||||
}
|
||||
});
|
||||
|
||||
updateStatusField();
|
||||
});
|
||||
|
||||
// Clear the selected template
|
||||
$("#clear-btn").click(function(e) {
|
||||
$("#format").val( "" );
|
||||
updateStatusField();
|
||||
});
|
||||
|
||||
// Store the format
|
||||
$("#format-btn").click(function(e) {
|
||||
var s = $("#format").val();
|
||||
|
||||
/*if (s.length > maxCharsInFormatTemplate) {
|
||||
showError("Format template is too large for the device to handle, unable to save.")
|
||||
return;
|
||||
}*/
|
||||
|
||||
$('#spinner').show();
|
||||
setButtonDisabled( true );
|
||||
var ha = false;
|
||||
|
||||
hideWarningHomeAssistant();
|
||||
if ($("#push-target").val() == "mqtt") {
|
||||
if (s.search("homeassistant/sensor/") != -1) {
|
||||
console.log("Current format is mqtt, it contains topics for Home Assistant device registration.")
|
||||
showWarningHomeAssistant();
|
||||
ha = true;
|
||||
}
|
||||
}
|
||||
|
||||
s = s.replaceAll("\n", "");
|
||||
var obj = 'id=' + $("#id").val() + '&' + $("#push-target").val() + '=' + encodeURIComponent(s);
|
||||
var obj = 'id=' + $("#id").val() + "&" + $("#push-target").val() + '=' + encodeURIComponent(s);
|
||||
console.log(obj);
|
||||
|
||||
$.ajax( {
|
||||
type: "POST",
|
||||
url: "/api/config/format",
|
||||
data: obj,
|
||||
success: function(result) { showSuccess('Format stored successfully.'); getConfig(); },
|
||||
error: function(result) { showError('Unable to store format.'); }
|
||||
success: function(result) { showSuccess('Format stored successfully.'); postHomeAssistant(ha); },
|
||||
error: function(result) { showError('Unable to store format.'); $('#spinner').hide(); },
|
||||
always: function() { $('#spinner').hide(); setButtonDisabled( false ); }
|
||||
} );
|
||||
});
|
||||
|
||||
function postHomeAssistant(active) {
|
||||
if (!active) {
|
||||
getConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Current format is mqtt, running post tests to register device.")
|
||||
$('#spinner').show();
|
||||
setButtonDisabled( true );
|
||||
|
||||
var url = "/api/test/push";
|
||||
url += "?id=" + $("#id").val() + "&format=mqtt";
|
||||
//var url = "/test/push.json";
|
||||
$.getJSON(url, function (cfg) {
|
||||
console.log(cfg);
|
||||
|
||||
var code = cfg["code"];
|
||||
var success = cfg["success"];
|
||||
var enabled = cfg["enabled"];
|
||||
|
||||
if(success) {
|
||||
showSuccess( "Format stored successfully. Home Assistant Device Registration Successful." );
|
||||
} else {
|
||||
showError( "Format stored successfully. Home Assistant Device Registration Failed!" );
|
||||
}
|
||||
})
|
||||
.fail(function() {
|
||||
showError( "Format stored successfully. Home Assistant Device Registration Failed!" );
|
||||
})
|
||||
.always(function() {
|
||||
$('#spinner').hide();
|
||||
setButtonDisabled( false );
|
||||
getConfig();
|
||||
});
|
||||
}
|
||||
|
||||
// Test the calibration
|
||||
$("#test-btn").click(function(e) {
|
||||
var url = "/api/status";
|
||||
@ -238,6 +355,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 {
|
||||
@ -261,6 +380,9 @@
|
||||
function setButtonDisabled( b ) {
|
||||
$("#format-btn").prop("disabled", b);
|
||||
$("#test-btn").prop("disabled", b);
|
||||
$("#copy-btn").prop("disabled", b);
|
||||
$("#clear-btn").prop("disabled", b);
|
||||
$("#push-target").prop("disabled", b);
|
||||
}
|
||||
|
||||
function selectFormat() {
|
||||
@ -272,6 +394,7 @@
|
||||
console.log(s);
|
||||
$("#format").val(s);
|
||||
$("#preview").text("");
|
||||
updateStatusField();
|
||||
}
|
||||
|
||||
// Get the configuration values from the API
|
||||
@ -299,6 +422,8 @@
|
||||
$('#spinner').hide();
|
||||
setButtonDisabled( false );
|
||||
});
|
||||
|
||||
updateStatusField();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -16,8 +16,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- START MENU -->
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
||||
@ -27,10 +25,18 @@
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#"><b>Home</b></a>
|
||||
<a class="nav-link active" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/config.htm">Configuration</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="/test.htm">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
@ -44,6 +50,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<!-- START MAIN INDEX -->
|
||||
|
||||
<div class="container row-margin-10">
|
||||
@ -153,11 +160,33 @@
|
||||
});
|
||||
setInterval(function() {
|
||||
loadLog();
|
||||
}, 5000);
|
||||
}, 30000);
|
||||
|
||||
function loadLog() {
|
||||
$("#logContent").load("/log");
|
||||
//$("#logContent").load("/test/log");
|
||||
var url2 = "/log2";
|
||||
var url1 = "/log";
|
||||
//var url2 = "/test/log2";
|
||||
//var url1 = "/test/log1";
|
||||
var log = "";
|
||||
|
||||
$.get(url2, function(data) {
|
||||
console.log(data);
|
||||
var list = data.split("\n");
|
||||
list.forEach(function (item, index) {
|
||||
log = item + "\n" + log;
|
||||
});
|
||||
}).always( function() {
|
||||
$.get(url1, function(data) {
|
||||
console.log(data);
|
||||
var list = data.split("\n");
|
||||
list.forEach(function (item, index) {
|
||||
log = item + "\n" + log;
|
||||
});
|
||||
}).always( function() {
|
||||
console.log(log);
|
||||
$("#logContent").text(log);
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -175,13 +204,13 @@
|
||||
|
||||
<div class="collapse row-margin-10" id="collapseLog">
|
||||
<div class="card card-body">
|
||||
<pre><code class="card-text" id="logContent"></code></pre>
|
||||
<pre><code class="card-text" id="logContent" data-bs-toggle="tooltip" title="Shows the last errors on the device, newest on top.">Loading log data, please wait...</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collapse row-margin-10" id="collapseSupport">
|
||||
<div class="card card-body">
|
||||
<pre><code class="card-text" id="supportContent"></code></pre>
|
||||
<pre><code class="card-text" id="supportContent">Collecting support data, please wait...</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -293,7 +322,11 @@
|
||||
|
||||
var angle = cfg["angle"];
|
||||
|
||||
if(angle==0) {
|
||||
if(angle==-1) {
|
||||
showError("Unable to connect to gyro, try a reset or power off/on")
|
||||
$("#angle").text("No gyro");
|
||||
$("#gravity").text("No gyro");
|
||||
} else if(angle==0) {
|
||||
$("#angle").text("Gyro moving");
|
||||
$("#gravity").text("Gyro moving");
|
||||
} else {
|
||||
@ -322,10 +355,14 @@
|
||||
|
||||
$("#battery").text(batt + " V (" + charge + "%)" );
|
||||
|
||||
if( cfg["temp-c"] == -273) {
|
||||
$("#temp").text("No temp sensor");
|
||||
} else {
|
||||
if( cfg["temp-format"] == "C")
|
||||
$("#temp").text(cfg["temp-c"] + " C");
|
||||
else
|
||||
$("#temp").text(cfg["temp-f"] + " F");
|
||||
}
|
||||
|
||||
if( cfg["sleep-mode"] )
|
||||
$("#sleep-mode").attr("checked", true );
|
||||
@ -342,7 +379,7 @@
|
||||
}
|
||||
|
||||
function start() {
|
||||
setInterval(getStatus, 3000);
|
||||
setInterval(getStatus, 5000);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -15,8 +15,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- START MENU -->
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a>
|
||||
@ -24,9 +22,26 @@
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="javascript:history.back()">Back to configuration</a>
|
||||
<a class="nav-link" href="/index.htm">Home</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle active" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Configuration
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/config.htm">Configuration</a></li>
|
||||
<li><a class="dropdown-item" href="/format.htm">Format editor</a></li>
|
||||
<li><a class="dropdown-item" href="#">Test push</a></li>
|
||||
<li><a class="dropdown-item" href="/firmware.htm">Upload firmware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/calibration.htm">Calibration</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/about.htm">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,6 +20,7 @@ framework = arduino
|
||||
board = d1_mini
|
||||
build_unflags =
|
||||
build_flags =
|
||||
-Wl,-Map,output.map
|
||||
-D BAUD=${common_env_data.monitor_speed}
|
||||
-D ACTIVATE_OTA
|
||||
#-D DEBUG_ESP_HTTP_CLIENT
|
||||
@ -34,8 +35,8 @@ build_flags =
|
||||
-D USER_SSID=\""\"" # =\""myssid\""
|
||||
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
|
||||
-D CFG_APPVER="\"1.1.0\""
|
||||
-D CFG_GITREV=\""beta-1\""
|
||||
#!python script/git_rev.py
|
||||
#-D CFG_GITREV=\""beta-4\""
|
||||
!python script/git_rev.py
|
||||
lib_deps = # Switched to forks for better version control.
|
||||
# Using local copy of these libraries
|
||||
#https://github.com/mp-se/i2cdevlib.git#<document>
|
||||
@ -62,9 +63,8 @@ extra_scripts =
|
||||
build_unflags =
|
||||
${common_env_data.build_unflags}
|
||||
build_flags =
|
||||
-Wl,-Map,output.map
|
||||
${common_env_data.build_flags}
|
||||
#-D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
|
||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
|
||||
#-D SKIP_SLEEPMODE
|
||||
#-D DOUBLERESETDETECTOR_DEBUG=true
|
||||
#-D FORCE_GRAVITY_MODE # used to debug gravity mode
|
||||
|
27
src/calc.cpp
27
src/calc.cpp
@ -52,8 +52,7 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
||||
#endif
|
||||
|
||||
if (noAngles < 3) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CALC: Not enough values for deriving formula"));
|
||||
writeErrorLog("CALC: Not enough values for deriving formula");
|
||||
return ERR_FORMULA_NOTENOUGHVALUES;
|
||||
} else {
|
||||
double coeffs[order + 1];
|
||||
@ -98,18 +97,15 @@ 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]);
|
||||
writeErrorLog(
|
||||
"CALC: Validation failed on angle %.2f, deviation too large %.4f "
|
||||
"SG, formula order %d",
|
||||
fd.a[i], dev * 1000, order);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(
|
||||
F("CALC: Error validating created formula. Deviation to large, "
|
||||
"formula rejected."));
|
||||
return ERR_FORMULA_UNABLETOFFIND;
|
||||
}
|
||||
|
||||
@ -118,8 +114,7 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
||||
}
|
||||
}
|
||||
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CALC: Internal error finding formula."));
|
||||
writeErrorLog("CALC: Internal error finding formula.");
|
||||
return ERR_FORMULA_INTERNAL;
|
||||
}
|
||||
|
||||
@ -164,8 +159,7 @@ double calculateGravity(double angle, double temp, const char *tempFormula) {
|
||||
return g;
|
||||
}
|
||||
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("CALC: Failed to parse gravity expression " + String(err));
|
||||
writeErrorLog("CALC: Failed to parse gravity expression %d", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -211,10 +205,9 @@ double gravityTemperatureCorrectionC(double gravitySG, double tempC,
|
||||
return g;
|
||||
}
|
||||
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(
|
||||
"CALC: Failed to parse expression for gravity temperature correction " +
|
||||
String(err));
|
||||
writeErrorLog(
|
||||
"CALC: Failed to parse expression for gravity temperature correction %d",
|
||||
err);
|
||||
return gravitySG;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -145,12 +145,11 @@ bool Config::saveFile() {
|
||||
File configFile = LittleFS.open(CFG_FILENAME, "w");
|
||||
|
||||
if (!configFile) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to save configuration."));
|
||||
writeErrorLog("CFG : Failed to save configuration.");
|
||||
return false;
|
||||
}
|
||||
|
||||
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
||||
DynamicJsonDocument doc(3000);
|
||||
createJson(doc);
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||
@ -176,23 +175,21 @@ bool Config::loadFile() {
|
||||
#endif
|
||||
|
||||
if (!LittleFS.exists(CFG_FILENAME)) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Configuration file does not exist."));
|
||||
writeErrorLog("CFG : Configuration file does not exist.");
|
||||
return false;
|
||||
}
|
||||
|
||||
File configFile = LittleFS.open(CFG_FILENAME, "r");
|
||||
|
||||
if (!configFile) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to load configuration."));
|
||||
writeErrorLog("CFG : Failed to load configuration.");
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -201,8 +198,7 @@ bool Config::loadFile() {
|
||||
configFile.close();
|
||||
|
||||
if (err) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to parse configuration (json)"));
|
||||
writeErrorLog("CFG : Failed to parse configuration (json)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -377,8 +373,7 @@ bool AdvancedConfig::saveFile() {
|
||||
File configFile = LittleFS.open(CFG_HW_FILENAME, "w");
|
||||
|
||||
if (!configFile) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to write hardware configuration "));
|
||||
writeErrorLog("CFG : Failed to write hardware configuration ");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -429,8 +424,7 @@ bool AdvancedConfig::loadFile() {
|
||||
File configFile = LittleFS.open(CFG_HW_FILENAME, "r");
|
||||
|
||||
if (!configFile) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to read hardware configuration "));
|
||||
writeErrorLog("CFG : Failed to read hardware configuration");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -446,8 +440,7 @@ bool AdvancedConfig::loadFile() {
|
||||
configFile.close();
|
||||
|
||||
if (err) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("CFG : Failed to parse hardware configuration (json)"));
|
||||
writeErrorLog("CFG : Failed to parse hardware configuration (json)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -46,8 +46,7 @@ bool GyroSensor::setup() {
|
||||
uint8_t id = accelgyro.getDeviceID();
|
||||
|
||||
if (id != 0x34 && id != 0x38) { // Allow both MPU6050 and MPU6000
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("GYRO: Failed to connect to gyro, is it connected?"));
|
||||
writeErrorLog("GYRO: Failed to connect to gyro, is it connected?");
|
||||
_sensorConnected = false;
|
||||
} else {
|
||||
#if !defined(GYRO_DISABLE_LOGGING)
|
||||
@ -294,9 +293,8 @@ void GyroSensor::applyCalibration() {
|
||||
if ((_calibrationOffset.ax + _calibrationOffset.ay + _calibrationOffset.az +
|
||||
_calibrationOffset.gx + _calibrationOffset.gy + _calibrationOffset.gz) ==
|
||||
0) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(
|
||||
F("GYRO: No valid calibration values, please calibrate the device."));
|
||||
writeErrorLog(
|
||||
"GYRO: No valid calibration values, please calibrate the device.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
161
src/helper.cpp
161
src/helper.cpp
@ -47,75 +47,68 @@ void tcp_cleanup() {
|
||||
while (tcp_tw_pcbs) tcp_abort(tcp_tw_pcbs);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert sg to plato
|
||||
//
|
||||
void checkResetReason() {
|
||||
#if defined(ESP8266)
|
||||
rst_info* _rinfo;
|
||||
_rinfo = ESP.getResetInfoPtr();
|
||||
|
||||
Log.notice(F("HELP: Last reset cause %d" CR), _rinfo->exccause);
|
||||
|
||||
if (_rinfo->exccause > 0) {
|
||||
char s[120];
|
||||
snprintf(&s[0], sizeof(s),
|
||||
"HELP: Exception (%d) reason=%d epc1=0x%08x epc2=0x%08x "
|
||||
"epc3=0x%08x execvaddr=0x%08x depc=0x%08x",
|
||||
_rinfo->exccause, _rinfo->reason, _rinfo->epc1, _rinfo->epc2,
|
||||
_rinfo->epc3, _rinfo->excvaddr, _rinfo->depc);
|
||||
writeErrorLog(&s[0]);
|
||||
}
|
||||
#else // defined (ESP32)
|
||||
#warning "Todo: Handle reset reasons on ESP32"
|
||||
#endif
|
||||
}
|
||||
|
||||
void writeErrorLog(const char* format, ...) {
|
||||
File f = LittleFS.open(ERR_FILENAME, "a");
|
||||
|
||||
if (f && f.size() > ERR_FILEMAXSIZE) {
|
||||
f.close();
|
||||
LittleFS.remove(ERR_FILENAME2);
|
||||
LittleFS.rename(ERR_FILENAME, ERR_FILENAME2);
|
||||
f = LittleFS.open(ERR_FILENAME, "a");
|
||||
}
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char buf[120];
|
||||
vsnprintf(&buf[0], sizeof(buf), format, arg);
|
||||
va_end(arg);
|
||||
Log.errorln(&buf[0]);
|
||||
|
||||
if (f) {
|
||||
#if defined(ESP8266)
|
||||
f.write(&buf[0], strlen(&buf[0]));
|
||||
#else // ESP32
|
||||
f.write((unsigned char*)&buf[0], strlen(&buf[0]));
|
||||
#endif
|
||||
f.println();
|
||||
f.close();
|
||||
} else {
|
||||
Log.warning(F("HELP: Failed to open error log." CR));
|
||||
}
|
||||
}
|
||||
|
||||
double convertToPlato(double sg) {
|
||||
if (sg) return 259 - (259 / sg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert plato to sg
|
||||
//
|
||||
double convertToSG(double plato) { return 259 / (259 - plato); }
|
||||
|
||||
//
|
||||
// Conversion to F
|
||||
//
|
||||
float convertCtoF(float c) { return (c * 1.8) + 32.0; }
|
||||
|
||||
//
|
||||
// Conversion to C
|
||||
//
|
||||
float convertFtoC(float f) { return (f - 32.0) / 1.8; }
|
||||
|
||||
//
|
||||
// Load error log from disk
|
||||
//
|
||||
ErrorFileLog::ErrorFileLog() {
|
||||
File errFile = LittleFS.open(ERR_FILENAME, "r");
|
||||
int i = 0;
|
||||
|
||||
if (errFile) {
|
||||
do {
|
||||
_errors[i] = errFile.readStringUntil('\n');
|
||||
_errors[i].replace("\r", "");
|
||||
_errors[i].replace("\n", "");
|
||||
} while (_errors[i++].length());
|
||||
errFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add new entry to top of error log
|
||||
//
|
||||
void ErrorFileLog::addEntry(String err) {
|
||||
for (int i = (ERR_COUNT - 1); i > 0; i--) {
|
||||
_errors[i] = _errors[i - 1];
|
||||
}
|
||||
_errors[0] = err;
|
||||
err += String(CR);
|
||||
Log.error(err.c_str());
|
||||
save();
|
||||
}
|
||||
|
||||
//
|
||||
// Save error log
|
||||
//
|
||||
void ErrorFileLog::save() {
|
||||
File errFile = LittleFS.open(ERR_FILENAME, "w");
|
||||
if (errFile) {
|
||||
for (int i = 0; i < ERR_COUNT; i++) {
|
||||
errFile.println(_errors[i]);
|
||||
}
|
||||
errFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Load history log of floats
|
||||
//
|
||||
FloatHistoryLog::FloatHistoryLog(String fName) {
|
||||
_fName = fName;
|
||||
|
||||
@ -133,9 +126,6 @@ FloatHistoryLog::FloatHistoryLog(String fName) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add entry to top of log
|
||||
//
|
||||
void FloatHistoryLog::addEntry(float time) {
|
||||
for (int i = (10 - 1); i > 0; i--) {
|
||||
_runTime[i] = _runTime[i - 1];
|
||||
@ -144,9 +134,6 @@ void FloatHistoryLog::addEntry(float time) {
|
||||
save();
|
||||
}
|
||||
|
||||
//
|
||||
// Save log
|
||||
//
|
||||
void FloatHistoryLog::save() {
|
||||
File runFile = LittleFS.open(_fName, "w");
|
||||
if (runFile) {
|
||||
@ -157,9 +144,6 @@ void FloatHistoryLog::save() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Print the heap information.
|
||||
//
|
||||
void printHeap(String prefix) {
|
||||
#if defined(ESP8266)
|
||||
Log.notice(
|
||||
@ -175,9 +159,6 @@ void printHeap(String prefix) {
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Enter deep sleep for the defined duration (Argument is seconds)
|
||||
//
|
||||
void deepSleep(int t) {
|
||||
#if LOG_LEVEL == 6 && !defined(HELPER_DISABLE_LOGGING)
|
||||
Log.verbose(F("HELP: Entering sleep mode for %ds." CR), t);
|
||||
@ -186,9 +167,6 @@ void deepSleep(int t) {
|
||||
ESP.deepSleep(wake);
|
||||
}
|
||||
|
||||
//
|
||||
// Print the build options used
|
||||
//
|
||||
void printBuildOptions() {
|
||||
Log.notice(F("Build options: %s (%s) LOGLEVEL %d "
|
||||
#ifdef SKIP_SLEEPMODE
|
||||
@ -201,9 +179,6 @@ void printBuildOptions() {
|
||||
CFG_APPVER, CFG_GITREV, LOG_LEVEL);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure serial debug output
|
||||
//
|
||||
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
||||
// Start serial with auto-detected rate (default to defined BAUD)
|
||||
Serial.flush();
|
||||
@ -214,18 +189,12 @@ SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
||||
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
||||
}
|
||||
|
||||
//
|
||||
// Print the timestamp (ms since start of device)
|
||||
//
|
||||
void printTimestamp(Print* _logOutput, int _logLevel) {
|
||||
char c[12];
|
||||
snprintf(c, sizeof(c), "%10lu ", millis());
|
||||
_logOutput->print(c);
|
||||
}
|
||||
|
||||
//
|
||||
// Read and calculate the battery voltage
|
||||
//
|
||||
void BatteryVoltage::read() {
|
||||
// The analog pin can only handle 3.3V maximum voltage so we need to reduce
|
||||
// the voltage (from max 5V)
|
||||
@ -251,9 +220,6 @@ void BatteryVoltage::read() {
|
||||
|
||||
PerfLogging myPerfLogging;
|
||||
|
||||
//
|
||||
// Clear the current cache
|
||||
//
|
||||
void PerfLogging::clear() {
|
||||
// Clear the measurements
|
||||
if (first == 0) return;
|
||||
@ -270,17 +236,11 @@ void PerfLogging::clear() {
|
||||
} while (pe != 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Start measuring this performance point
|
||||
//
|
||||
void PerfLogging::start(const char* key) {
|
||||
PerfEntry* pe = add(key);
|
||||
pe->start = millis();
|
||||
}
|
||||
|
||||
//
|
||||
// Finalize measuring of this performance point
|
||||
//
|
||||
void PerfLogging::stop(const char* key) {
|
||||
PerfEntry* pe = find(key);
|
||||
|
||||
@ -293,9 +253,6 @@ void PerfLogging::stop(const char* key) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Print the collected performance data
|
||||
//
|
||||
void PerfLogging::print() {
|
||||
PerfEntry* pe = first;
|
||||
|
||||
@ -305,9 +262,6 @@ void PerfLogging::print() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Push collected performance data to influx (use influx configuration)
|
||||
//
|
||||
void PerfLogging::pushInflux() {
|
||||
if (!myConfig.isInfluxDb2Active()) return;
|
||||
|
||||
@ -409,29 +363,19 @@ void PerfLogging::pushInflux() {
|
||||
|
||||
#endif // COLLECT_PERFDATA
|
||||
|
||||
//
|
||||
// Convert float to formatted string with n decimals. Buffer should be at least
|
||||
// 10 chars.
|
||||
//
|
||||
char* convertFloatToString(float f, char* buffer, int dec) {
|
||||
dtostrf(f, 6, dec, buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//
|
||||
// Reduce precision to n decimals
|
||||
//
|
||||
float reduceFloatPrecision(float f, int dec) {
|
||||
char buffer[5];
|
||||
dtostrf(f, 6, dec, &buffer[0]);
|
||||
return atof(&buffer[0]);
|
||||
}
|
||||
|
||||
//
|
||||
// urlencode
|
||||
//
|
||||
// https://circuits4you.com/2019/03/21/esp8266-url-encode-decode-example/
|
||||
//
|
||||
String urlencode(String str) {
|
||||
String encodedString;
|
||||
encodedString.reserve(str.length() * 2);
|
||||
@ -475,9 +419,6 @@ unsigned char h2int(char c) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
//
|
||||
// urlencode string
|
||||
//
|
||||
String urldecode(String str) {
|
||||
String encodedString;
|
||||
encodedString.reserve(str.length());
|
||||
|
@ -28,13 +28,18 @@ SOFTWARE.
|
||||
#include <main.hpp>
|
||||
|
||||
#define ERR_FILENAME "/error.log"
|
||||
#define ERR_COUNT 15
|
||||
#define ERR_FILENAME2 "/error2.log"
|
||||
#define ERR_FILEMAXSIZE 4000
|
||||
|
||||
#define RUNTIME_FILENAME "/runtime.log"
|
||||
|
||||
// tcp cleanup
|
||||
void tcp_cleanup();
|
||||
|
||||
// Error logging
|
||||
void writeErrorLog(const char* format, ...);
|
||||
void checkResetReason();
|
||||
|
||||
// Sleep mode
|
||||
void deepSleep(int t);
|
||||
|
||||
@ -67,16 +72,6 @@ class SerialDebug {
|
||||
static Logging* getLog() { return &Log; }
|
||||
};
|
||||
|
||||
class ErrorFileLog {
|
||||
private:
|
||||
String _errors[ERR_COUNT];
|
||||
|
||||
public:
|
||||
ErrorFileLog();
|
||||
void addEntry(String error);
|
||||
void save();
|
||||
};
|
||||
|
||||
class FloatHistoryLog {
|
||||
private:
|
||||
String _fName;
|
||||
|
30
src/main.cpp
30
src/main.cpp
@ -117,10 +117,13 @@ void checkSleepMode(float angle, float volt) {
|
||||
Log.notice(
|
||||
F("Main: Storage mode entered, going to sleep for maximum time." CR));
|
||||
#if defined(ESP8266)
|
||||
ESP.deepSleep(ESP.deepSleepMax());
|
||||
// ESP.deepSleep(ESP.deepSleepMax());
|
||||
ESP.deepSleep(0); // indefinite sleep
|
||||
#else
|
||||
#warning "Check and test the max deep sleep for esp32"
|
||||
deepSleep(70 * 60); // quick search on internet suggest max time is 70 min
|
||||
// deepSleep(70 * 60); // quick search on internet suggest max time is 70
|
||||
// min
|
||||
ESP.deepSleep(0); // indefinite sleep
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -133,12 +136,9 @@ void setup() {
|
||||
#if LOG_LEVEL == 6 && !defined(MAIN_DISABLE_LOGGING)
|
||||
// Add a delay so that serial is started.
|
||||
// delay(3000);
|
||||
#if defined(ESP8266)
|
||||
Log.verbose(F("Main: Reset reason %s." CR), ESP.getResetInfo().c_str());
|
||||
#else // defined (ESP32)
|
||||
#endif
|
||||
#endif
|
||||
// Main startup
|
||||
|
||||
#if defined(ESP8266)
|
||||
Log.notice(F("Main: Started setup for %s." CR),
|
||||
String(ESP.getChipId(), HEX).c_str());
|
||||
@ -157,6 +157,7 @@ void setup() {
|
||||
|
||||
LOG_PERF_START("main-config-load");
|
||||
myConfig.checkFileSystem();
|
||||
checkResetReason();
|
||||
myConfig.loadFile();
|
||||
myWifi.init();
|
||||
myAdvancedConfig.loadFile();
|
||||
@ -192,14 +193,14 @@ void setup() {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!myGyro.setup()) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(
|
||||
F("MAIN: Failed to initialize the gyro, is it connected?"));
|
||||
} else {
|
||||
if (myGyro.setup()) {
|
||||
LOG_PERF_START("main-gyro-read");
|
||||
myGyro.read();
|
||||
LOG_PERF_STOP("main-gyro-read");
|
||||
} else {
|
||||
Log.notice(
|
||||
F("Main: Failed to connect to the gyro, software will not be able "
|
||||
"to detect angles." CR));
|
||||
}
|
||||
|
||||
myBatteryVoltage.read();
|
||||
@ -279,7 +280,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, "
|
||||
|
@ -34,9 +34,6 @@ SOFTWARE.
|
||||
|
||||
#define PUSHINT_FILENAME "/push.dat"
|
||||
|
||||
//
|
||||
// Decrease counters
|
||||
//
|
||||
void PushIntervalTracker::update(const int index, const int defaultValue) {
|
||||
if (_counters[index] <= 0)
|
||||
_counters[index] = defaultValue;
|
||||
@ -44,9 +41,6 @@ void PushIntervalTracker::update(const int index, const int defaultValue) {
|
||||
_counters[index]--;
|
||||
}
|
||||
|
||||
//
|
||||
// Load data from file
|
||||
//
|
||||
void PushIntervalTracker::load() {
|
||||
File intFile = LittleFS.open(PUSHINT_FILENAME, "r");
|
||||
|
||||
@ -143,10 +137,11 @@ void PushTarget::sendAll(float angle, float gravitySG, float corrGravitySG,
|
||||
|
||||
if (myConfig.isMqttActive() && intDelay.useMqtt()) {
|
||||
LOG_PERF_START("push-mqtt");
|
||||
sendMqtt(engine, myConfig.isMqttSSL());
|
||||
sendMqtt(engine, myConfig.isMqttSSL(), true);
|
||||
LOG_PERF_STOP("push-mqtt");
|
||||
}
|
||||
|
||||
engine.freeMemory();
|
||||
intDelay.save();
|
||||
}
|
||||
|
||||
@ -232,8 +227,7 @@ void PushTarget::sendInfluxDb2(TemplatingEngine& engine, bool isSecure) {
|
||||
_lastSuccess = true;
|
||||
Log.notice(F("PUSH: InfluxDB2 push successful, response=%d" CR), _lastCode);
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("PUSH: Influxdb push failed response=" + String(_lastCode));
|
||||
writeErrorLog("PUSH: Influxdb push failed response=%d", _lastCode);
|
||||
}
|
||||
|
||||
if (isSecure) {
|
||||
@ -261,8 +255,8 @@ void PushTarget::addHttpHeader(HTTPClient& http, String header) {
|
||||
value.c_str());
|
||||
http.addHeader(name, value);
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("PUSH: Unable to set header, invalid value " + header);
|
||||
writeErrorLog("PUSH: Unable to set header, invalid value %s",
|
||||
header.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,9 +332,8 @@ void PushTarget::sendHttpPost(TemplatingEngine& engine, bool isSecure,
|
||||
_lastSuccess = true;
|
||||
Log.notice(F("PUSH: HTTP post successful, response=%d" CR), _lastCode);
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("PUSH: HTTP post failed response=" + String(_lastCode) +
|
||||
String(index == 0 ? " (http)" : " (http2)"));
|
||||
writeErrorLog("PUSH: HTTP post failed response=%d http%d", _lastCode,
|
||||
index + 1);
|
||||
}
|
||||
|
||||
if (isSecure) {
|
||||
@ -399,8 +392,7 @@ void PushTarget::sendHttpGet(TemplatingEngine& engine, bool isSecure) {
|
||||
_lastSuccess = true;
|
||||
Log.notice(F("PUSH: HTTP get successful, response=%d" CR), _lastCode);
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("PUSH: HTTP get failed response=" + String(_lastCode));
|
||||
writeErrorLog("PUSH: HTTP get failed response=%d", _lastCode);
|
||||
}
|
||||
|
||||
if (isSecure) {
|
||||
@ -416,9 +408,11 @@ void PushTarget::sendHttpGet(TemplatingEngine& engine, bool isSecure) {
|
||||
//
|
||||
// Send data to mqtt target
|
||||
//
|
||||
void PushTarget::sendMqtt(TemplatingEngine& engine, bool isSecure) {
|
||||
void PushTarget::sendMqtt(TemplatingEngine& engine, bool isSecure,
|
||||
bool skipHomeAssistantRegistration) {
|
||||
#if !defined(PUSH_DISABLE_LOGGING)
|
||||
Log.notice(F("PUSH: Sending values to mqtt." CR));
|
||||
Log.notice(F("PUSH: Sending values to mqtt. Skip HA registration=%s" CR),
|
||||
skipHomeAssistantRegistration ? "yes" : "no");
|
||||
#endif
|
||||
_lastCode = 0;
|
||||
_lastSuccess = false;
|
||||
@ -483,15 +477,22 @@ void PushTarget::sendMqtt(TemplatingEngine& engine, bool isSecure) {
|
||||
Log.verbose(F("PUSH: topic '%s', value '%s'." CR), topic.c_str(),
|
||||
value.c_str());
|
||||
#endif
|
||||
|
||||
if (skipHomeAssistantRegistration &&
|
||||
topic.startsWith("homeassistant/sensor/")) {
|
||||
Log.notice(F("PUSH: Ignoring Home Assistant registration topic %s" CR),
|
||||
topic.c_str());
|
||||
} else {
|
||||
if (mqtt.publish(topic, value)) {
|
||||
_lastSuccess = true;
|
||||
Log.notice(F("PUSH: MQTT publish successful on %s" CR), topic.c_str());
|
||||
_lastCode = 0;
|
||||
} else {
|
||||
_lastSuccess = false;
|
||||
_lastCode = mqtt.lastError();
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("PUSH: MQTT push on " + topic +
|
||||
" failed error=" + String(mqtt.lastError()));
|
||||
writeErrorLog("PUSH: MQTT push on %s failed error=%d", topic.c_str(),
|
||||
_lastCode);
|
||||
}
|
||||
}
|
||||
|
||||
index = next + 1;
|
||||
|
@ -61,7 +61,8 @@ class PushTarget {
|
||||
sendHttpGet(engine, isSecure);
|
||||
}
|
||||
void sendInfluxDb2(TemplatingEngine& engine, bool isSecure);
|
||||
void sendMqtt(TemplatingEngine& engine, bool isSecure);
|
||||
void sendMqtt(TemplatingEngine& engine, bool isSecure,
|
||||
bool skipHomeAssistantRegistration = true);
|
||||
int getLastCode() { return _lastCode; }
|
||||
bool getLastSuccess() { return _lastSuccess; }
|
||||
};
|
||||
|
@ -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
|
||||
@ -138,30 +141,30 @@ void TemplatingEngine::initialize(float angle, float gravitySG,
|
||||
//
|
||||
// Create the data using defined template.
|
||||
//
|
||||
const String& TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
||||
const char* TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
||||
String fname;
|
||||
baseTemplate.reserve(600);
|
||||
_baseTemplate.reserve(600);
|
||||
|
||||
// Load templates from memory
|
||||
switch (idx) {
|
||||
case TEMPLATE_HTTP1:
|
||||
baseTemplate = String(iSpindleFormat);
|
||||
_baseTemplate = String(iSpindleFormat);
|
||||
fname = TPL_FNAME_HTTP1;
|
||||
break;
|
||||
case TEMPLATE_HTTP2:
|
||||
baseTemplate = String(iSpindleFormat);
|
||||
_baseTemplate = String(iSpindleFormat);
|
||||
fname = TPL_FNAME_HTTP2;
|
||||
break;
|
||||
case TEMPLATE_HTTP3:
|
||||
baseTemplate = String(iHttpGetFormat);
|
||||
_baseTemplate = String(iHttpGetFormat);
|
||||
fname = TPL_FNAME_HTTP3;
|
||||
break;
|
||||
case TEMPLATE_INFLUX:
|
||||
baseTemplate = String(influxDbFormat);
|
||||
_baseTemplate = String(influxDbFormat);
|
||||
fname = TPL_FNAME_INFLUXDB;
|
||||
break;
|
||||
case TEMPLATE_MQTT:
|
||||
baseTemplate = String(mqttFormat);
|
||||
_baseTemplate = String(mqttFormat);
|
||||
fname = TPL_FNAME_MQTT;
|
||||
break;
|
||||
}
|
||||
@ -172,7 +175,7 @@ const String& TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
||||
char buf[file.size() + 1];
|
||||
memset(&buf[0], 0, file.size() + 1);
|
||||
file.readBytes(&buf[0], file.size());
|
||||
baseTemplate = String(&buf[0]);
|
||||
_baseTemplate = String(&buf[0]);
|
||||
file.close();
|
||||
Log.notice(F("TPL : Template loaded from disk %s." CR), fname.c_str());
|
||||
}
|
||||
@ -182,13 +185,16 @@ const String& TemplatingEngine::create(TemplatingEngine::Templates idx) {
|
||||
#endif
|
||||
|
||||
// Insert data into template.
|
||||
transform(baseTemplate);
|
||||
transform();
|
||||
_baseTemplate.clear();
|
||||
|
||||
#if LOG_LEVEL == 6
|
||||
// Log.verbose(F("TPL : Transformed '%s'." CR), baseTemplate.c_str());
|
||||
#endif
|
||||
|
||||
return baseTemplate;
|
||||
if (_output) return _output;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -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,23 +85,25 @@ 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;
|
||||
char _buffer[20] = "";
|
||||
String _baseTemplate;
|
||||
char *_output = 0;
|
||||
|
||||
void setVal(String key, float val, int dec = 2) {
|
||||
String s = convertFloatToString(val, &buffer[0], dec);
|
||||
String s = convertFloatToString(val, &_buffer[0], dec);
|
||||
s.trim();
|
||||
setVal(key, s);
|
||||
}
|
||||
void setVal(String key, int val) { setVal(key, String(val)); }
|
||||
void setVal(String key, char val) { setVal(key, String(val)); }
|
||||
void setVal(String key, String val) {
|
||||
int max = sizeof(items) / sizeof(KeyVal);
|
||||
int max = sizeof(_items) / sizeof(KeyVal);
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (items[i].key.equals(key)) {
|
||||
items[i].val = val;
|
||||
if (_items[i].key.equals(key)) {
|
||||
_items[i].val = val;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -107,21 +111,73 @@ class TemplatingEngine {
|
||||
Log.warning(F("TPL : Key not found %s." CR), key.c_str());
|
||||
}
|
||||
|
||||
void transform(String& s) {
|
||||
int max = sizeof(items) / sizeof(KeyVal);
|
||||
void transform() {
|
||||
const char *format = _baseTemplate.c_str();
|
||||
int len = _baseTemplate.length();
|
||||
int size = len;
|
||||
|
||||
// Lets check how much memory will be needed to transform the template
|
||||
for (int j = 0; j < len - 2; j++) {
|
||||
if (*(format + j) == '$' && *(format + j + 1) == '{') {
|
||||
// Start of format tag found
|
||||
int max = sizeof(_items) / sizeof(KeyVal);
|
||||
for (int i = 0; i < max; i++) {
|
||||
while (s.indexOf(items[i].key) != -1)
|
||||
s.replace(items[i].key, items[i].val);
|
||||
if (strncmp(format + j, _items[i].key.c_str(),
|
||||
_items[i].key.length()) == 0) {
|
||||
// Found key
|
||||
size = size - _items[i].key.length() + _items[i].val.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
freeMemory(); // In case this is reused
|
||||
_output = static_cast<char *>(malloc(size + 20));
|
||||
|
||||
if (!_output) {
|
||||
Log.error(F("TPL : Unable to allocate memory for transforming template, "
|
||||
"needed %d." CR),
|
||||
size);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(_output, 0, size + 20);
|
||||
|
||||
// Lets do the transformation
|
||||
int k = 0;
|
||||
for (int j = 0; j < len - 2; j++) {
|
||||
if (*(format + j) == '$' && *(format + j + 1) == '{') {
|
||||
// Start of format tag found
|
||||
int max = sizeof(_items) / sizeof(KeyVal);
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (strncmp(format + j, _items[i].key.c_str(),
|
||||
_items[i].key.length()) == 0) {
|
||||
// Found key
|
||||
strncat(_output, format + k, j - k);
|
||||
strncat(_output, _items[i].val.c_str(), _items[i].val.length());
|
||||
k = j + _items[i].key.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
strncat(_output, format + k, size - k);
|
||||
Log.notice(F("TPL : Transformed template %d chars to %d chars" CR),
|
||||
strlen(format), strlen(_output));
|
||||
|
||||
#if LOG_LEVEL == 6
|
||||
printHeap("TPL ");
|
||||
Log.verboseln(format);
|
||||
Log.verboseln(_output);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dumpAll() {
|
||||
int max = sizeof(items) / sizeof(KeyVal);
|
||||
int max = sizeof(_items) / sizeof(KeyVal);
|
||||
for (int i = 0; i < max; i++) {
|
||||
Serial.print("Key=\'");
|
||||
Serial.print(items[i].key.c_str());
|
||||
Serial.print(_items[i].key.c_str());
|
||||
Serial.print("\', Val=\'");
|
||||
Serial.print(items[i].val.c_str());
|
||||
Serial.print(_items[i].val.c_str());
|
||||
Serial.println("\'");
|
||||
}
|
||||
}
|
||||
@ -135,9 +191,18 @@ class TemplatingEngine {
|
||||
TEMPLATE_MQTT = 4
|
||||
};
|
||||
|
||||
TemplatingEngine() {}
|
||||
~TemplatingEngine() { freeMemory(); }
|
||||
|
||||
void freeMemory() {
|
||||
if (_output) free(_output);
|
||||
|
||||
_output = 0;
|
||||
_baseTemplate.clear();
|
||||
}
|
||||
void initialize(float angle, float gravitySG, float corrGravitySG,
|
||||
float tempC, float runTime);
|
||||
const String& create(TemplatingEngine::Templates idx);
|
||||
const char *create(TemplatingEngine::Templates idx);
|
||||
};
|
||||
|
||||
#endif // SRC_TEMPLATING_HPP_
|
||||
|
@ -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,13 +164,11 @@ 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");
|
||||
}
|
||||
|
||||
//
|
||||
// Callback from webServer when / has been accessed.
|
||||
//
|
||||
void WebServerHandler::webHandleUploadFile() {
|
||||
LOG_PERF_START("webserver-api-upload-file");
|
||||
Log.verbose(F("WEB : webServer callback for /api/upload(post)." CR));
|
||||
@ -208,9 +210,7 @@ void WebServerHandler::webHandleUploadFile() {
|
||||
maxSketchSpace / 1024);
|
||||
|
||||
if (!Update.begin(maxSketchSpace, U_FLASH, PIN_LED)) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(
|
||||
F("WEB : Not enough space to store for this firmware."));
|
||||
writeErrorLog("WEB : Not enough space to store for this firmware.");
|
||||
_uploadReturn = 500;
|
||||
}
|
||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
@ -232,9 +232,8 @@ void WebServerHandler::webHandleUploadFile() {
|
||||
delay(500);
|
||||
ESP_RESET();
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("WEB : Failed to finish firmware flashing error=" +
|
||||
String(Update.getError()));
|
||||
writeErrorLog("WEB : Failed to finish firmware flashing error=%d",
|
||||
Update.getError());
|
||||
_uploadReturn = 500;
|
||||
}
|
||||
} else {
|
||||
@ -292,9 +291,6 @@ void WebServerHandler::webHandleCalibrate() {
|
||||
LOG_PERF_STOP("webserver-api-calibrate");
|
||||
}
|
||||
|
||||
//
|
||||
// Callback from webServer when / has been accessed.
|
||||
//
|
||||
void WebServerHandler::webHandleFactoryDefaults() {
|
||||
String id = _server->arg(PARAM_ID);
|
||||
Log.notice(F("WEB : webServer callback for /api/factory." CR));
|
||||
@ -318,16 +314,27 @@ void WebServerHandler::webHandleFactoryDefaults() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Callback from webServer when / has been accessed.
|
||||
//
|
||||
void WebServerHandler::webHandleLogClear() {
|
||||
String id = _server->arg(PARAM_ID);
|
||||
Log.notice(F("WEB : webServer callback for /api/clearlog." CR));
|
||||
|
||||
if (!id.compareTo(myConfig.getID())) {
|
||||
_server->send(200, "text/plain", "Removing logfiles...");
|
||||
LittleFS.remove(ERR_FILENAME);
|
||||
LittleFS.remove(ERR_FILENAME2);
|
||||
_server->send(200, "text/plain", "Logfiles cleared.");
|
||||
} else {
|
||||
_server->send(400, "text/plain", "Unknown ID.");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
double angle = 0; // Indicate we have no valid gyro value
|
||||
|
||||
if (myGyro.hasValue()) angle = myGyro.getAngle();
|
||||
|
||||
@ -335,9 +342,13 @@ void WebServerHandler::webHandleStatus() {
|
||||
double gravity = calculateGravity(angle, tempC);
|
||||
|
||||
doc[PARAM_ID] = myConfig.getID();
|
||||
doc[PARAM_ANGLE] = reduceFloatPrecision(angle);
|
||||
doc[PARAM_ANGLE] = myGyro.isConnected()
|
||||
? reduceFloatPrecision(angle)
|
||||
: -1; // Indicate that we have no connection to gyro
|
||||
|
||||
if (myConfig.isGravityTempAdj()) {
|
||||
gravity = gravityTemperatureCorrectionC(gravity, tempC);
|
||||
gravity = gravityTemperatureCorrectionC(
|
||||
gravity, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
}
|
||||
if (myConfig.isGravityPlato()) {
|
||||
doc[PARAM_GRAVITY] = reduceFloatPrecision(convertToPlato(gravity), 1);
|
||||
@ -376,15 +387,13 @@ 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");
|
||||
}
|
||||
|
||||
//
|
||||
// Callback from webServer when / has been accessed.
|
||||
//
|
||||
void WebServerHandler::webHandleClearWIFI() {
|
||||
String id = _server->arg(PARAM_ID);
|
||||
Log.notice(F("WEB : webServer callback for /api/clearwifi." CR));
|
||||
@ -405,9 +414,6 @@ void WebServerHandler::webHandleClearWIFI() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Used to force the device to never sleep.
|
||||
//
|
||||
void WebServerHandler::webHandleStatusSleepmode() {
|
||||
LOG_PERF_START("webserver-api-sleepmode");
|
||||
String id = _server->arg(PARAM_ID);
|
||||
@ -671,9 +677,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 +730,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 +741,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 +759,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 +773,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 +791,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 +845,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");
|
||||
}
|
||||
@ -877,8 +891,7 @@ void WebServerHandler::webHandleConfigFormatWrite() {
|
||||
_server->sendHeader("Location", "/format.htm", true);
|
||||
_server->send(302, "text/plain", "Format updated");
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("WEB : Unable to store format file"));
|
||||
writeErrorLog("WEB : Unable to store format file");
|
||||
_server->send(400, "text/plain", "Unable to store format in file.");
|
||||
}
|
||||
|
||||
@ -908,7 +921,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);
|
||||
@ -931,10 +945,11 @@ void WebServerHandler::webHandleTestPush() {
|
||||
push.sendInfluxDb2(engine, myConfig.isInfluxSSL());
|
||||
enabled = true;
|
||||
} else if (!type.compareTo(PARAM_FORMAT_MQTT) && myConfig.isMqttActive()) {
|
||||
push.sendMqtt(engine, myConfig.isMqttSSL());
|
||||
push.sendMqtt(engine, myConfig.isMqttSSL(), false);
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
engine.freeMemory();
|
||||
DynamicJsonDocument doc(100);
|
||||
doc[PARAM_PUSH_ENABLED] = enabled;
|
||||
doc[PARAM_PUSH_SUCCESS] = push.getLastSuccess();
|
||||
@ -943,6 +958,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,48 +1021,52 @@ 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);
|
||||
|
||||
doc[PARAM_ID] = myConfig.getID();
|
||||
String out;
|
||||
out.reserve(7000);
|
||||
out += "{\"id\":\"" + String(myConfig.getID()) + "\",";
|
||||
|
||||
String s = readFile(TPL_FNAME_HTTP1);
|
||||
out += "\"" + String(PARAM_FORMAT_HTTP1) + "\":\"";
|
||||
if (s.length())
|
||||
doc[PARAM_FORMAT_HTTP1] = urlencode(s);
|
||||
out += urlencode(s);
|
||||
else
|
||||
doc[PARAM_FORMAT_HTTP1] = urlencode(String(&iSpindleFormat[0]));
|
||||
out += urlencode(String(&iSpindleFormat[0]));
|
||||
|
||||
s = readFile(TPL_FNAME_HTTP2);
|
||||
out += "\",\"" + String(PARAM_FORMAT_HTTP2) + "\":\"";
|
||||
if (s.length())
|
||||
doc[PARAM_FORMAT_HTTP2] = urlencode(s);
|
||||
out += urlencode(s);
|
||||
else
|
||||
doc[PARAM_FORMAT_HTTP2] = urlencode(String(&iSpindleFormat[0]));
|
||||
out += urlencode(String(&iSpindleFormat[0]));
|
||||
|
||||
s = readFile(TPL_FNAME_HTTP3);
|
||||
out += "\",\"" + String(PARAM_FORMAT_HTTP3) + "\":\"";
|
||||
if (s.length())
|
||||
doc[PARAM_FORMAT_HTTP3] = urlencode(s);
|
||||
out += urlencode(s);
|
||||
else
|
||||
doc[PARAM_FORMAT_HTTP3] = urlencode(String(&iHttpGetFormat[0]));
|
||||
out += urlencode(String(&iHttpGetFormat[0]));
|
||||
|
||||
s = readFile(TPL_FNAME_INFLUXDB);
|
||||
out += "\",\"" + String(PARAM_FORMAT_INFLUXDB) + "\":\"";
|
||||
if (s.length())
|
||||
doc[PARAM_FORMAT_INFLUXDB] = urlencode(s);
|
||||
out += urlencode(s);
|
||||
else
|
||||
doc[PARAM_FORMAT_INFLUXDB] = urlencode(String(&influxDbFormat[0]));
|
||||
out += urlencode(String(&influxDbFormat[0]));
|
||||
|
||||
s = readFile(TPL_FNAME_MQTT);
|
||||
out += "\",\"" + String(PARAM_FORMAT_MQTT) + "\":\"";
|
||||
if (s.length())
|
||||
doc[PARAM_FORMAT_MQTT] = urlencode(s);
|
||||
out += urlencode(s);
|
||||
else
|
||||
doc[PARAM_FORMAT_MQTT] = urlencode(String(&mqttFormat[0]));
|
||||
out += urlencode(String(&mqttFormat[0]));
|
||||
|
||||
out += "\"}";
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(out.c_str());
|
||||
Serial.print(CR);
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(2048);
|
||||
serializeJson(doc, out);
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-config-format-read");
|
||||
}
|
||||
@ -1237,6 +1257,7 @@ bool WebServerHandler::setupWebServer() {
|
||||
#endif
|
||||
|
||||
// Static content
|
||||
Log.notice(F("WEB : Setting up handlers for web server." CR));
|
||||
#if defined(EMBED_HTML)
|
||||
_server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
||||
_server->on("/index.htm",
|
||||
@ -1279,30 +1300,26 @@ bool WebServerHandler::setupWebServer() {
|
||||
_server->on("/firmware.htm",
|
||||
std::bind(&WebServerHandler::webReturnFirmwareHtm, this));
|
||||
_server->serveStatic("/log", LittleFS, ERR_FILENAME);
|
||||
_server->serveStatic("/log2", LittleFS, ERR_FILENAME2);
|
||||
_server->serveStatic("/runtime", LittleFS, RUNTIME_FILENAME);
|
||||
|
||||
// Dynamic content
|
||||
_server->on(
|
||||
"/api/config", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleConfig, this)); // Get config.json
|
||||
_server->on("/api/clearlog", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleLogClear, this));
|
||||
_server->on("/api/config", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleConfig, this));
|
||||
_server->on("/api/formula", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleFormulaRead,
|
||||
this)); // Get formula.json (calibration page)
|
||||
std::bind(&WebServerHandler::webHandleFormulaRead, this));
|
||||
_server->on("/api/formula", HTTP_POST,
|
||||
std::bind(&WebServerHandler::webHandleFormulaWrite,
|
||||
this)); // Get formula.json (calibration page)
|
||||
std::bind(&WebServerHandler::webHandleFormulaWrite, this));
|
||||
_server->on("/api/calibrate", HTTP_POST,
|
||||
std::bind(&WebServerHandler::webHandleCalibrate,
|
||||
this)); // Run calibration routine (param id)
|
||||
std::bind(&WebServerHandler::webHandleCalibrate, this));
|
||||
_server->on("/api/factory", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleFactoryDefaults,
|
||||
this)); // Reset the device
|
||||
std::bind(&WebServerHandler::webHandleFactoryDefaults, this));
|
||||
_server->on("/api/status", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleStatus,
|
||||
this)); // Get the status.json
|
||||
std::bind(&WebServerHandler::webHandleStatus, this));
|
||||
_server->on("/api/clearwifi", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleClearWIFI,
|
||||
this)); // Clear wifi settings
|
||||
std::bind(&WebServerHandler::webHandleClearWIFI, this));
|
||||
_server->on(
|
||||
"/api/upload", HTTP_GET,
|
||||
std::bind(&WebServerHandler::webHandleUpload, this)); // Get upload.json
|
||||
@ -1349,9 +1366,6 @@ bool WebServerHandler::setupWebServer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// called from main loop
|
||||
//
|
||||
void WebServerHandler::loop() {
|
||||
#if defined(ESP8266)
|
||||
MDNS.update();
|
||||
|
@ -76,6 +76,7 @@ class WebServerHandler {
|
||||
void webHandleCalibrate();
|
||||
void webHandleUploadFile();
|
||||
void webHandleUpload();
|
||||
void webHandleLogClear();
|
||||
void webHandlePageNotFound();
|
||||
|
||||
String readFile(String fname);
|
||||
|
15
src/wifi.cpp
15
src/wifi.cpp
@ -203,9 +203,7 @@ bool WifiConnection::waitForConnection(int maxTime) {
|
||||
|
||||
if (i++ >
|
||||
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("WIFI: Failed to connect to wifi " +
|
||||
String(WiFi.status()));
|
||||
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
||||
WiFi.disconnect();
|
||||
Serial.print(CR);
|
||||
return false; // Return to main that we have failed to connect.
|
||||
@ -346,9 +344,7 @@ bool WifiConnection::updateFirmware() {
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED: {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("WIFI: OTA update failed " +
|
||||
String(ESPhttpUpdate.getLastError()));
|
||||
writeErrorLog("WIFI: OTA update failed %d", ESPhttpUpdate.getLastError());
|
||||
} break;
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
break;
|
||||
@ -378,9 +374,7 @@ void WifiConnection::downloadFile(HTTPClient &http, String &fname) {
|
||||
f.close();
|
||||
Log.notice(F("WIFI: Downloaded file %s." CR), fname.c_str());
|
||||
} else {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry("WIFI: Failed to download html-file " +
|
||||
String(httpResponseCode));
|
||||
writeErrorLog("WIFI: Failed to download html-file %d", httpResponseCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,8 +413,7 @@ bool WifiConnection::checkFirmwareVersion() {
|
||||
#endif
|
||||
DeserializationError err = deserializeJson(ver, payload);
|
||||
if (err) {
|
||||
ErrorFileLog errLog;
|
||||
errLog.addEntry(F("WIFI: Failed to parse version.json"));
|
||||
writeErrorLog("WIFI: Failed to parse version.json");
|
||||
} else {
|
||||
#if LOG_LEVEL == 6 && !defined(WIFI_DISABLE_LOGGING)
|
||||
Log.verbose(F("WIFI: Project %s version %s." CR),
|
||||
|
@ -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
|
||||
|
||||
|
@ -65,6 +65,8 @@ Other parameters are the same as in the configuration guide.
|
||||
"angle": 90.93,
|
||||
"gravity": 1.105,
|
||||
"battery": 0.04,
|
||||
"app-ver": "0.1.0",
|
||||
"app-build": "build",
|
||||
"platform": "esp8266",
|
||||
"runtime-average": 3.12
|
||||
}
|
||||
@ -83,6 +85,8 @@ Retrive the current device status via an HTTP GET command. Payload is in JSON fo
|
||||
|
||||
* ``temp-format`` can be either ``C`` or ``F``
|
||||
* ``platform`` can be either ``esp8266`` or ``esp32``
|
||||
* ``temp-c`` will be set to -273 C if there is no temp sensor
|
||||
* ``angle`` will be set to 0 if no valid angle is found and -1 if there is no gyro
|
||||
|
||||
Other parameters are the same as in the configuration guide.
|
||||
|
||||
@ -102,6 +106,7 @@ Other parameters are the same as in the configuration guide.
|
||||
"token2": "token2",
|
||||
"rssi": -56,
|
||||
"app-ver": "0.0.0",
|
||||
"app-build": "gitrev",
|
||||
"mdns": "gravmon",
|
||||
"sleep-interval": 30,
|
||||
"platform": "esp8266",
|
||||
@ -156,18 +161,19 @@ Used for adjusting some internal constants and other advanced settings. Should b
|
||||
|
||||
{
|
||||
"gyro-read-count": 50,
|
||||
"tempsensor-resolution": 9,
|
||||
"gyro-moving-threashold": 500,
|
||||
"formula-max-deviation": 1.6,
|
||||
"formula-max-deviation": 3.0,
|
||||
"wifi-portal-timeout": 120,
|
||||
"wifi-connect-timeout": 20,
|
||||
"push-timeout": 10,
|
||||
"formula-calibration-temp": 20,
|
||||
"ignore-low-angles": false,
|
||||
"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
|
||||
}
|
||||
|
||||
POST: /api/config/advanced
|
||||
@ -354,7 +360,7 @@ Calling the API's from Python
|
||||
=============================
|
||||
|
||||
Here is some example code for how to access the API's from a python script. Keys should always be
|
||||
present or the API call will fail.
|
||||
present or the API call will fail. You only need to include the parameters you want to change.
|
||||
|
||||
The requests package converts the json to standard form post format.
|
||||
|
||||
|
@ -37,8 +37,9 @@ connection. It will show 0 if data has not been collected yet.
|
||||
|
||||
.. tip::
|
||||
|
||||
The button `view error log` will show the last 15 errors on the device. This can be useful for checking errors without
|
||||
the need to connect to the serial port or to check what errors has occured while in `gravity mode`.
|
||||
The button `view error log` will show the last error messages on the device. This can be useful for checking errors without
|
||||
the need to connect to the serial port or to check what errors has occured while in `gravity mode`. From v1.1 it will also detect
|
||||
any abnormal restarts or crashes and record these in the logfile.
|
||||
|
||||
|
||||
Configuration
|
||||
@ -55,7 +56,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:**
|
||||
|
||||
@ -214,7 +216,7 @@ build this into the gravity formula.
|
||||
|
||||
This formula assumes that the calibration has been done at 20°C / 68°F.
|
||||
|
||||
Formula used in temperature correction.
|
||||
Formula used in temperature correction. The calibration temperature can be changed under advanced settings.
|
||||
|
||||
::
|
||||
|
||||
@ -236,7 +238,8 @@ Factor used to calcualate the battery voltage. If you get a too low/high voltage
|
||||
* **Config voltage:**
|
||||
|
||||
Defines the level of voltage when the device should enter config mode due to charging. This might vary between different battery manufacturers.
|
||||
If you dont what the device to go into configuration mode when charging, set this to 6V.
|
||||
If you dont what the device to go into configuration mode when charging, set this to 6V. This was added since differnt batteries have different
|
||||
voltages when fully charged.
|
||||
|
||||
* **Temperature correction:**
|
||||
|
||||
@ -252,9 +255,10 @@ been running the value would be totally off.
|
||||
|
||||
* **Enable storage mode when placed on cap**
|
||||
|
||||
When place on the cap (<5 degres tilt) the device will go into max sleep. In order to wake it up you need to do a reset (or wait for the device
|
||||
to wake up). One option is to attach a magnetic reed switch (default open) to the reset pin and use a magnet to force a reset without opening
|
||||
the tube. The reed switch is typically an electronic component of 14 mm long incapsulated in a small glass tube.
|
||||
When place on the cap (<5 degres tilt) the device will go into deep sleep forever (until reset). In order to wake it
|
||||
up you need to do a reset. One option is to attach a magnetic reed switch (default open) to the reset pin and use a
|
||||
magnet to force a reset without opening the tube. The reed switch is typically an electronic component of 14 mm
|
||||
long incapsulated in a small glass tube. See hardware section for more information, :ref:`hardware`.
|
||||
|
||||
* **Bluetooth: (Only ESP32)**
|
||||
|
||||
@ -316,6 +320,10 @@ data and of the deviation on any point is bigger the formula will be rejected.
|
||||
|
||||
If this option is checked any angles below that of SG 1 will be discarded as invalid and never sent to any server. Default = off.
|
||||
|
||||
* **Gravity calibration temp**
|
||||
|
||||
This option allows you to set the correction temperature used in the automatic temperature gravity adjustment formula. Standard is 20C.
|
||||
|
||||
* **DS18B20 Resolution:**
|
||||
|
||||
Define the resolution used on the temp sensor. 9 bits is default and will give an accuracy of 0.5C, 12 bits will give an accuracy of 0.0625C but will also
|
||||
|
@ -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.
|
||||
|
||||
|
@ -43,3 +43,24 @@ Schema for esp32 build
|
||||
.. image:: images/schema_esp32.png
|
||||
:width: 700
|
||||
:alt: Schema esp32
|
||||
|
||||
Modifying with reed switch
|
||||
--------------------------
|
||||
|
||||
A reed switch is a switch that reacts to magnetic fields. The ones I have tested are normally open and close in proximity to
|
||||
a magnet.
|
||||
|
||||
.. image:: images/reed.jpg
|
||||
:width: 400
|
||||
:alt: Reed switch
|
||||
|
||||
If this is connected to the reset button a magnet can be used to trigger a reset of the device. The image below shows how
|
||||
I mounted the iSPINDLE PCB v4.0 just under the cap. The lower red circle shows the reset connection point for the reed switch.
|
||||
|
||||
The reed switch is the glass tube visible under the esp8266.
|
||||
|
||||
.. image:: images/reed_build.jpg
|
||||
:width: 400
|
||||
:alt: Reed build
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 36 KiB |
BIN
src_docs/source/images/reed.jpg
Normal file
BIN
src_docs/source/images/reed.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
src_docs/source/images/reed_build.jpg
Normal file
BIN
src_docs/source/images/reed_build.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 574 KiB |
@ -7,66 +7,90 @@ Welcome to GravityMon's documentation!
|
||||
######################################
|
||||
|
||||
.. note::
|
||||
This documentation reflects **v1.1 BETA 1**. Last updated 2022-07-06
|
||||
This documentation reflects **v1.1**. Last updated 2022-08-14
|
||||
|
||||
* 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>`_
|
||||
User interface overview
|
||||
-----------------------
|
||||
|
||||
This animation shows how the user interface is structured, it reflects an older version but the structure is the same.
|
||||
|
||||
.. image:: images/gravitymon.gif
|
||||
:width: 800
|
||||
:alt: User Inteface Walkthrough
|
||||
|
||||
.. _main_features:
|
||||
|
||||
Main features
|
||||
-------------
|
||||
|
||||
* Operates in two modes gravity monitoring and configuration mode
|
||||
* Gravity mode is comparable to how the iSpindle works when collectintg data
|
||||
* Configuration mode has a modern HTML5 based web UI. No need to start the access point to change settings
|
||||
* Offloading some of the functionallity to run in the web browser, this allows for more advanced features.
|
||||
* REST API to enable scripted configuration
|
||||
* Send data to multiple endpoints and services at once (2xHTTP POST, HTTP GET, MQTT, INFLUXDB2)
|
||||
* Directly test all endpoints from user interface with feedback to simplify troubleshooting
|
||||
* Complete format customization for all endpoints using templates (dont really need to change the software to support new services)
|
||||
* Setup guides for how to send data to many popular services. Currently 10+ are documented
|
||||
* Automatic temperature adjustment of gravity (just tick a checkbox)
|
||||
* OTA support from webserver
|
||||
* Firmware update via web interface
|
||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity and let GravityMon creates a formula
|
||||
* Visual graph showing how formula will be interpreted based on entered values
|
||||
* Using the temperature sensor in gyro instead of DS18B20 (faster)
|
||||
* SSL support in all endpoints (no certificate validation due to limitations on esp8266).
|
||||
* Built in performance measurements (used to optimise code)
|
||||
* Storage mode when placed on cap (indefinite sleep)
|
||||
* Customize various hardware parameters to opimize device functionallity.
|
||||
|
||||
For a complete breakdown see the :ref:`functionallity`
|
||||
|
||||
.. note::
|
||||
If you are missing some feature, please reach out on `Github <https://github.com/mp-se/gravitymon/discussions>`_ or `homebrewtalk.com <https://www.homebrewtalk.com/threads/replacement-firmware-for-ispindel-gravitymon.698058/>`_
|
||||
|
||||
What is GravityMon?
|
||||
--------------------
|
||||
|
||||
GravityMon is used to measure gravity and temperature during fermentation of beer and report the progress. The graph below is
|
||||
an example on how the fermentation process can be tracked. This is from my last brew that was over on a few days. The graph is rendered using
|
||||
Fermentrack.
|
||||
an example on how the fermentation process can be tracked. The graph has been rendered using Fermentrack.
|
||||
|
||||
.. image:: images/fermentation.png
|
||||
:width: 500
|
||||
:alt: Example fermentation
|
||||
|
||||
GravityMon is a replacement firmware for the iSpindle and uses the same hardware configuration and is 100% compatible. It
|
||||
implements a lot of the features that has been requested in the orginal iSpindle project but has been rejected for
|
||||
implements a lot of the features that has been requested in the orginal iSpindle project but never implemented for
|
||||
various reasons. Here is a list of :ref:`main_features`.
|
||||
|
||||
From v0.9 the firmware now supports a iSpindle build based on an ESP32 d1 mini (pin compatible with esp8266). See :ref:`hardware`.
|
||||
From v0.9 the firmware also supports a iSpindle built using an ESP32 d1 mini (pin compatible with esp8266). Currently this is an experimental
|
||||
version but since it has more memory and processing capacity it could support more functions. See :ref:`hardware`.
|
||||
|
||||
I started GravityMon because I like to create software and wanted to do some low level programming. I had done a few
|
||||
I started GravityMon because I like to create software and wanted to do some microcontroller programming. I had done a few
|
||||
projects based on esp8266 and also started to brew beer so this combination was quite natural.
|
||||
|
||||
The hardware design comes from the fantastic iSpindle project so that is not covered in this documentation. For more
|
||||
information on this topic and function please visit `iSpindel Homepage <https://www.ispindel.de>`_ .
|
||||
|
||||
My approach to this software is a little different from that the original iSpindle firmware. The github repository
|
||||
can be found here; `GravityMon on Github <https://github.com/mp-se/gravitymon>`_
|
||||
My approach to this software is a little different from that the original iSpindle firmware as can be seen in the list of features.
|
||||
|
||||
The github repository can be found here; `GravityMon on Github <https://github.com/mp-se/gravitymon>`_
|
||||
|
||||
.. note::
|
||||
I dont take responsibility for any errors or issues caused by the software. The software is provided as-is. I will however
|
||||
try my best to fix issues that might occur.
|
||||
|
||||
I have tested this software over the last year on 20+ brews with good results.
|
||||
I have tested this software on 40+ brews with good results.
|
||||
|
||||
.. _main_features:
|
||||
|
||||
Main features:
|
||||
--------------
|
||||
Documentation for older versions
|
||||
--------------------------------
|
||||
|
||||
* Operates in two modes gravity monitoring and configuration mode (simplify calibration). Gravity mode
|
||||
is comparable to how the iSpindle works.
|
||||
* Modern web based UI when in configuration mode. No need to start the access point changing settings.
|
||||
* REST API to enable scripted configuration
|
||||
* Send data to multiple endpoints and services at once
|
||||
* Setup guides for how to send data to many popular services. Currently 8+ are documented.
|
||||
* Automatic temperature adjustment of gravity reading
|
||||
* OTA support from webserver
|
||||
* Built in function to create gravity formulas, no need for additional software, just enter tilt/gravity and
|
||||
let GravityMon create the formula.
|
||||
* Visual graph showing how formula will be interpreted based on entered values
|
||||
* Using the temperature sensor in gyro instead of DS18B20 (faster)
|
||||
* SSL support in standard HTTP and MQTT connections.
|
||||
* Option to customize data posted to endpoints using template from the UI.
|
||||
* Built in performance measurements (used to optimise code)
|
||||
* 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>`_
|
||||
|
||||
For a complete breakdown see the :ref:`functionallity`
|
||||
|
||||
Software architecture
|
||||
---------------------
|
||||
|
||||
This is a simple overview of the different components that the software contains. The green ones are only active during `configuration mode` in
|
||||
order to save battery.
|
||||
|
@ -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
|
||||
----------------------
|
||||
|
||||
|
@ -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.
|
||||
|
@ -6,24 +6,59 @@ Releases
|
||||
v1.1.0
|
||||
======
|
||||
|
||||
Documentation
|
||||
+++++++++++++
|
||||
* Fixed errors in data format section
|
||||
* Added q&a on formula creation and value deviation
|
||||
* Added documentation for Brewpiless as target
|
||||
* Updated docs for ubidots service integration.
|
||||
* Added brewblox as new service
|
||||
Features
|
||||
++++++++
|
||||
* Added information to error log about abnormal resets (for instance crashes) to detect and fix those
|
||||
* Changed storage mode so that the device will go into deep sleep until reset (sleep forever)
|
||||
* Updated sensor types in home assistant for auto registration of device
|
||||
* Added ${app-ver} and ${app-build} to format template as new variables
|
||||
* Improved error messages when creating formula so the troublesome measurement points can be identified
|
||||
* Changed defaule validation threashold from 1.6 SG to 3.0 SG, this should allow for some more variance when creating formula
|
||||
* Updated format template for Home Assistant, aligned with new mqtt configuration format
|
||||
* Added format template for Home Assistant with automatic device registration
|
||||
* 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 deep sleep.
|
||||
|
||||
Known issues, not yet fixed
|
||||
+++++++++++++++++++++++++++
|
||||
* When updating firmware and the feature `deep sleep` is active the device will activate deep sleep if the gyro is not responding. FIX: Reboot device
|
||||
|
||||
Issues adressed
|
||||
++++++++++++++++
|
||||
* Refactored error logging function to reduce memory usage and crashes. Max size of error log is 2 x 4 kb
|
||||
* Refactored format template engine to reduce memory usage and crashes, can how handle slightly larger payloads than before. Increase from around 1100 chars to 1600 chars
|
||||
* BUG: Refactored format api to handle larger payloads
|
||||
* BUG: After manual firmware upload the device would crash and go into wifi setup mode.
|
||||
* BUG: After manual firmware upload the device will in some cases not be able to connect with the gyro, the symptom is that it will say, "Gyro moving" in the web UI. In this case the device needs to be reset (or powered on/off). I havent found a way to fix this from the code. The message after firmware update has been updated with this information
|
||||
* BUG: Temp corrected gravity was not used when pushing data to removed
|
||||
* BUG: Low memory in format api which resulted in mqtt template to be set to null
|
||||
* BUG: Large format templates could be saved but when loading it's only blank
|
||||
* 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
|
||||
|
||||
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)
|
||||
* Updated format template with information on size and warning message if the template is too large
|
||||
* Added error message if gyro connection/initialization fails (before the message was Gyro Moving only)
|
||||
* Added error message if no temp sensor can be found
|
||||
* Added drop down menus in user interface to simplify navigation to sub pages (format, test and upload)
|
||||
* Added Assistant Device registration, this is only done when format template is saved, during normal operation only data values are posted on MQTT. If HA is restarted then the device will disappear
|
||||
* Calibration temperature (for temp adjustment) can now be set under advanced settings, default is 20C
|
||||
* Changed length of device name from 12 to 63 chars. 63 is the max limit according to mdns.
|
||||
* Under format options its now possible to select brewfather ispindle format to avoid errors connected to using the wrong format template with the various brewfather endpoints
|
||||
* Added brewblox as format under format options
|
||||
* Added home assistant (with device registration) as format under format options
|
||||
* User can now edit the voltage level that forces the device into config mode (device detects charging)
|
||||
|
||||
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.
|
||||
Documentation
|
||||
+++++++++++++
|
||||
* Added documentation for Brewpiless as target
|
||||
* Added documentation for BVrewblox as target
|
||||
* Updated documentation for HA integration since described method was deprecated
|
||||
* Updated documentation for ubidots service integration
|
||||
* Updated documentation in data format section
|
||||
* Updated hardware section with documentation on installing reed switch
|
||||
* Updated configuration section with documentation on new settings
|
||||
* Added q&a on formula creation and value deviation
|
||||
|
||||
Other
|
||||
+++++
|
||||
@ -32,10 +67,6 @@ Other
|
||||
* Updated OneWire library to be complaint with new ESP32 SDK
|
||||
* Fixed issue in i2cdev connected to wrong usage of TwoWire on ESP32 (Gyro initialization hang).
|
||||
|
||||
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.
|
||||
|
||||
v1.0.0
|
||||
======
|
||||
|
@ -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,51 @@ device is named `gravmon2`
|
||||
|
||||
::
|
||||
|
||||
mqtt:
|
||||
sensor:
|
||||
- platform: mqtt
|
||||
name: "gravmon2_gravity"
|
||||
- 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"
|
||||
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. The registration will occur when you save the format template. If Home Assistant
|
||||
is restarted then the device will dissapear. The first method is the most persistant one.
|
||||
|
||||
.. 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":"voltage","unit_of_meas":"V","stat_t":"gravmon/${mdns}/battery"}|
|
||||
|
||||
|
||||
Brewer's Friend
|
||||
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"gyro-read-count": 50,
|
||||
"gyro-moving-threashold": 500,
|
||||
"formula-max-deviation": 1.6,
|
||||
"formula-max-deviation": 3,
|
||||
"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
|
||||
}
|
@ -64,5 +64,7 @@
|
||||
"battery": 0.04,
|
||||
"runtime-average": 3.0,
|
||||
"ble": "pink",
|
||||
"app-ver": "0.1.0",
|
||||
"app-build": "build",
|
||||
"platform": "esp32"
|
||||
}
|
7
test/log1
Normal file
7
test/log1
Normal file
@ -0,0 +1,7 @@
|
||||
Log Entry 11
|
||||
Log Entry 12
|
||||
Log Entry 13
|
||||
Log Entry 14
|
||||
Log Entry 15
|
||||
Log Entry 16
|
||||
Log Entry 17
|
Reference in New Issue
Block a user