Added estimated runtime on config

This commit is contained in:
Magnus Persson 2022-03-18 19:24:28 +01:00
parent d4452e1d59
commit aae29786bb
6 changed files with 64 additions and 18 deletions

View File

@ -132,7 +132,7 @@
<div class="col-sm-2">
<input type="number" min="10" max="3600" class="form-control" name="sleep-interval" id="sleep-interval">
</div>
<label for="sleep-interval" class="col-sm-7 col-form-label" id="sleep-interval-info"></label>
<label for="sleep-interval" class="col-sm-4 col-form-label" id="sleep-interval-info"></label>
</div>
<div class="form-group row">
<div class="col-sm-8 offset-sm-3">
@ -547,16 +547,15 @@ function checkHeader(input) {
window.location.href = "/test.htm";
});
function estimateBatteryLife(interval) {
function estimateBatteryLife(interval, rt) {
// ESP8266 consumes between 140-170mA when WIFI is on. Deep sleep is 20uA.
// MPU-6050 consumes 4mA
// DS18B20 consumes 1mA
// For this estimation we use an average of 160mA
var pwrActive = 160; // mA per hour
var pwrSleep = 5; // mA per day
var batt = 2200; // mA
var rt = parseInt($("#runtime-average").val());
var pwrActive = 170; // mA per hour
var pwrSleep = 15; // mA per day
var batt = 2000; // mA
if(rt<1) rt = 2;
@ -567,15 +566,19 @@ function checkHeader(input) {
function updateSleepInfo() {
var i = parseInt($("#sleep-interval").val());
var rt = parseInt($("#runtime-average").val());
var j = 0;
var j = estimateBatteryLife(i);
if( rt>0 )
j = estimateBatteryLife(i, rt);
var t1 = Math.floor(i/60) + " m " + (i%60) + " s";
var t2 = Math.floor(j/7) + " weeks " + (i%7) + " days";
var t2 = Math.floor(j/7) + " weeks " + Math.floor(j%7) + " days";
$("#sleep-interval-info").text(t1);
//$("#sleep-interval-info").text( t1 + " - Estimated life: " + t2);
console.log( "Estimated life: " + t2);
if( j )
$("#sleep-interval-info").text( t1 + " - Estimated runtime: " + t2);
else
$("#sleep-interval-info").text( t1 );
hideWarningGyro();
if(i>0 && i<300) {
@ -609,7 +612,7 @@ function checkHeader(input) {
setButtonDisabled( true );
var url = "/api/config";
//var url = "/test/config.json";
var url = "/test/config.json";
$('#spinner').show();
$.getJSON(url, function (cfg) {
console.log( cfg );

File diff suppressed because one or more lines are too long

View File

@ -69,7 +69,8 @@ Device Setting
.. note::
A low value such as 30s will give a lifespan of 1-2 weeks and 300s (5 min) would last for 3+ weeks. This assumes that
there is good wifi connection that takes less than 1s to reconnect. Poor wifi connection is the main reason for battery drain.
there is good wifi connection that takes less than 1s to reconnect. Poor wifi connection is the main reason for battery drain.
The device will show the estimated lifespan based on the average connection time, if no data exist it will not be shown.
* **Calibration values:**

View File

@ -8,6 +8,7 @@ v0.9.0
* Added one http push target that uses HTTP GET. This can be used with ubidots or blynk api's.
* Added function to test push targets from configuration page. It will send data and show the return code as a first step.
* Added documetation on how to integrate with Blynk.io using http get.
* Config page now shows the estimated runtime for the device (based on a full battery and previous average runtime)
* Experimental release of firmware using an esp32 instead of esp8266
* Merged index and device pages into one so that all the needed information is available on the index page.
* Removed api for device (/api/device), it's now merged into the /api/status api.

View File

@ -10,14 +10,55 @@ Brewfather
Brewfather is an all in one service that allows you to manage you recepies and brews.
Just enter the http adress found on brewfather, not other settings are needed. The endpoint has the following format:
.. tip::
The integration named Brewfather is uses the custom stream endpoint in brewfather not the standard iSpindle
endpoint. You can use the iSpindle endpoint as well. In that case just use the http-1 or http-2 fields.
**Option 1** - Custom Stream
This option makes use of the push endpoint called Brewfather in the UI. Just enter the http stream adress found
on brewfather, not other settings are needed. The stream endpoint URL has the following format:
.. code-block::
http://log.brewfather.net/http://log.brewfather.net/stream?id=<yourid>
http://log.brewfather.net/stream?id=<yourid>
Documentation on this can be found under `Brewfather Custom Endpoint <https://docs.brewfather.app/integrations/custom-stream>`_
The implementation is basically a http request with the following format template:
.. code-block::
{
"name": "${mdns}",
"temp": ${temp},
"aux_temp": 0,
"ext_temp": 0,
"temp_unit": "${temp-unit}",
"gravity": ${gravity},
"gravity_unit": "${gravity-unit}",
"pressure": 0,
"pressure_unit": "PSI",
"ph": 0,
"bpm": 0,
"comment": "",
"beer": "",
"battery": ${battery}
}
The URL is found under settings.
**Option 2** - iSpindle Endpoint
This opion makes use of the standard http (1 or 2) endpoints in the push section. The brewfather iSpindle endpoint
has the following format:
.. code-block::
http://log.brewfather.net/ispindel?id=<yourid>
Documentation on this can be found under `Brewfather iSpindle Endpoint <https://docs.brewfather.app/integrations/ispindel>`_
Fermentrack
+++++++++++

View File

@ -39,7 +39,7 @@
"angle": 90.93,
"gravity": 1.105,
"battery": 0.04,
"runtime-average": 2.0,
"runtime-average": 3.0,
"ble": "pink",
"platform": "esp32"
}