Made config voltage configurable
This commit is contained in:
parent
0c936cfb88
commit
79a3274286
@ -390,11 +390,18 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<label for="voltage-factor" class="col-sm-2 col-form-label">Voltage factor</label>
|
<label for="voltage-factor" class="col-sm-2 col-form-label">Voltage factor</label>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<input type="number" step=".01" class="form-control" name="voltage-factor" id="voltage-factor" placeholder="1.59" data-bs-toggle="tooltip" title="Factor used to calculate the battery voltage. When running on battery, the voltage should be less than 4.15V">
|
<input type="number" step=".01" class="form-control" name="voltage-factor" id="voltage-factor" placeholder="1.59" data-bs-toggle="tooltip" title="Factor used to calculate the battery voltage. Can vary depending on the R2 value">
|
||||||
</div>
|
</div>
|
||||||
<label for="voltage-factor" class="col-sm-3 col-form-label" id="battery">Loading...</label>
|
<label for="voltage-factor" class="col-sm-3 col-form-label" id="battery">Loading...</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="voltage-config" class="col-sm-2 col-form-label">Config voltage</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" step=".01" class="form-control" name="voltage-config" id="voltage-config" placeholder="4.16" data-bs-toggle="tooltip" title="Over this level the device will always go into configuration mode, some batteries might have a higher voltage when fully charged">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<label for="temp-adjustment-value" class="col-sm-2 col-form-label">Temp Sensor Adj</label>
|
<label for="temp-adjustment-value" class="col-sm-2 col-form-label">Temp Sensor Adj</label>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
@ -865,6 +872,7 @@
|
|||||||
$("#mqtt-pass").val(cfg["mqtt-pass"]);
|
$("#mqtt-pass").val(cfg["mqtt-pass"]);
|
||||||
$("#sleep-interval").val(cfg["sleep-interval"]);
|
$("#sleep-interval").val(cfg["sleep-interval"]);
|
||||||
$("#voltage-factor").val(cfg["voltage-factor"]);
|
$("#voltage-factor").val(cfg["voltage-factor"]);
|
||||||
|
$("#voltage-config").val(cfg["voltage-config"]);
|
||||||
$("#gravity-formula").val(cfg["gravity-formula"]);
|
$("#gravity-formula").val(cfg["gravity-formula"]);
|
||||||
$("#temp-adjustment-value").val(cfg["temp-adjustment-value"]);
|
$("#temp-adjustment-value").val(cfg["temp-adjustment-value"]);
|
||||||
$("#gravity-temp-adjustment").prop( "checked", cfg["gravity-temp-adjustment"] );
|
$("#gravity-temp-adjustment").prop( "checked", cfg["gravity-temp-adjustment"] );
|
||||||
|
File diff suppressed because one or more lines are too long
@ -86,7 +86,8 @@ void Config::createJson(DynamicJsonDocument& doc) {
|
|||||||
doc[PARAM_PUSH_MQTT_USER] = getMqttUser();
|
doc[PARAM_PUSH_MQTT_USER] = getMqttUser();
|
||||||
doc[PARAM_PUSH_MQTT_PASS] = getMqttPass();
|
doc[PARAM_PUSH_MQTT_PASS] = getMqttPass();
|
||||||
doc[PARAM_SLEEP_INTERVAL] = getSleepInterval();
|
doc[PARAM_SLEEP_INTERVAL] = getSleepInterval();
|
||||||
doc[PARAM_VOLTAGEFACTOR] = getVoltageFactor();
|
doc[PARAM_VOLTAGE_FACTOR] = getVoltageFactor();
|
||||||
|
doc[PARAM_VOLTAGE_CONFIG] = getVoltageConfig();
|
||||||
doc[PARAM_GRAVITY_FORMULA] = getGravityFormula();
|
doc[PARAM_GRAVITY_FORMULA] = getGravityFormula();
|
||||||
doc[PARAM_GRAVITY_FORMAT] = String(getGravityFormat());
|
doc[PARAM_GRAVITY_FORMAT] = String(getGravityFormat());
|
||||||
doc[PARAM_TEMP_ADJ] = getTempSensorAdjC();
|
doc[PARAM_TEMP_ADJ] = getTempSensorAdjC();
|
||||||
@ -254,8 +255,10 @@ bool Config::loadFile() {
|
|||||||
|
|
||||||
if (!doc[PARAM_SLEEP_INTERVAL].isNull())
|
if (!doc[PARAM_SLEEP_INTERVAL].isNull())
|
||||||
setSleepInterval(doc[PARAM_SLEEP_INTERVAL].as<int>());
|
setSleepInterval(doc[PARAM_SLEEP_INTERVAL].as<int>());
|
||||||
if (!doc[PARAM_VOLTAGEFACTOR].isNull())
|
if (!doc[PARAM_VOLTAGE_FACTOR].isNull())
|
||||||
setVoltageFactor(doc[PARAM_VOLTAGEFACTOR].as<float>());
|
setVoltageFactor(doc[PARAM_VOLTAGE_FACTOR].as<float>());
|
||||||
|
if (!doc[PARAM_VOLTAGE_CONFIG].isNull())
|
||||||
|
setVoltageConfig(doc[PARAM_VOLTAGE_CONFIG].as<float>());
|
||||||
if (!doc[PARAM_GRAVITY_FORMULA].isNull())
|
if (!doc[PARAM_GRAVITY_FORMULA].isNull())
|
||||||
setGravityFormula(doc[PARAM_GRAVITY_FORMULA]);
|
setGravityFormula(doc[PARAM_GRAVITY_FORMULA]);
|
||||||
if (!doc[PARAM_GRAVITY_TEMP_ADJ].isNull())
|
if (!doc[PARAM_GRAVITY_TEMP_ADJ].isNull())
|
||||||
|
@ -146,6 +146,7 @@ class Config {
|
|||||||
String _otaURL = "";
|
String _otaURL = "";
|
||||||
char _tempFormat = 'C';
|
char _tempFormat = 'C';
|
||||||
float _voltageFactor = 1.59;
|
float _voltageFactor = 1.59;
|
||||||
|
float _voltageConfig = 4.15;
|
||||||
float _tempSensorAdjC = 0;
|
float _tempSensorAdjC = 0;
|
||||||
int _sleepInterval = 900;
|
int _sleepInterval = 900;
|
||||||
bool _gyroTemp = false;
|
bool _gyroTemp = false;
|
||||||
@ -378,6 +379,16 @@ class Config {
|
|||||||
_saveNeeded = true;
|
_saveNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getVoltageConfig() { return _voltageConfig; }
|
||||||
|
void setVoltageConfig(float f) {
|
||||||
|
_voltageConfig = f;
|
||||||
|
_saveNeeded = true;
|
||||||
|
}
|
||||||
|
void setVoltageConfig(String s) {
|
||||||
|
_voltageConfig = s.toFloat();
|
||||||
|
_saveNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
float getTempSensorAdjC() { return _tempSensorAdjC; }
|
float getTempSensorAdjC() { return _tempSensorAdjC; }
|
||||||
void setTempSensorAdjC(float f) {
|
void setTempSensorAdjC(float f) {
|
||||||
_tempSensorAdjC = f;
|
_tempSensorAdjC = f;
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -80,7 +80,9 @@ void checkSleepMode(float angle, float volt) {
|
|||||||
Log.notice(F("MAIN: Sleep mode disabled from web interface." CR));
|
Log.notice(F("MAIN: Sleep mode disabled from web interface." CR));
|
||||||
#endif
|
#endif
|
||||||
runMode = RunMode::configurationMode;
|
runMode = RunMode::configurationMode;
|
||||||
} else if ((volt < 4.15 && (angle > 85 && angle < 95)) || (volt > 4.15)) {
|
} else if ((volt < myConfig.getVoltageConfig() &&
|
||||||
|
(angle > 85 && angle < 95)) ||
|
||||||
|
(volt > myConfig.getVoltageConfig())) {
|
||||||
runMode = RunMode::configurationMode;
|
runMode = RunMode::configurationMode;
|
||||||
} else if (angle < 5 && myConfig.isStorageSleep()) {
|
} else if (angle < 5 && myConfig.isStorageSleep()) {
|
||||||
runMode = RunMode::storageMode;
|
runMode = RunMode::storageMode;
|
||||||
@ -193,13 +195,15 @@ void setup() {
|
|||||||
|
|
||||||
if (runMode == RunMode::storageMode) {
|
if (runMode == RunMode::storageMode) {
|
||||||
// If we are in storage mode, just go back to sleep
|
// If we are in storage mode, just go back to sleep
|
||||||
Log.notice(F("Main: Storage mode entered, going to sleep for maximum time." CR));
|
Log.notice(F(
|
||||||
|
"Main: Storage mode entered, going to sleep for maximum time." CR));
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
ESP.deepSleep(ESP.deepSleepMax());
|
ESP.deepSleep(ESP.deepSleepMax());
|
||||||
#else
|
#else
|
||||||
#warning "Check and test the max deep sleep for esp32"
|
#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 *
|
||||||
#endif
|
60); // quick search on internet suggest max time is 70 min
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
@ -53,7 +53,8 @@ SOFTWARE.
|
|||||||
#define PARAM_PUSH_MQTT_PORT "mqtt-port"
|
#define PARAM_PUSH_MQTT_PORT "mqtt-port"
|
||||||
#define PARAM_SLEEP_INTERVAL "sleep-interval"
|
#define PARAM_SLEEP_INTERVAL "sleep-interval"
|
||||||
#define PARAM_TEMPFORMAT "temp-format"
|
#define PARAM_TEMPFORMAT "temp-format"
|
||||||
#define PARAM_VOLTAGEFACTOR "voltage-factor"
|
#define PARAM_VOLTAGE_FACTOR "voltage-factor"
|
||||||
|
#define PARAM_VOLTAGE_CONFIG "voltage-config"
|
||||||
#define PARAM_GRAVITY_FORMULA "gravity-formula"
|
#define PARAM_GRAVITY_FORMULA "gravity-formula"
|
||||||
#define PARAM_GRAVITY_FORMAT "gravity-format"
|
#define PARAM_GRAVITY_FORMAT "gravity-format"
|
||||||
#define PARAM_GRAVITY_TEMP_ADJ "gravity-temp-adjustment"
|
#define PARAM_GRAVITY_TEMP_ADJ "gravity-temp-adjustment"
|
||||||
|
@ -605,8 +605,10 @@ void WebServerHandler::webHandleConfigHardware() {
|
|||||||
Log.verbose(F("WEB : %s." CR), getRequestArguments().c_str());
|
Log.verbose(F("WEB : %s." CR), getRequestArguments().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_server->hasArg(PARAM_VOLTAGEFACTOR))
|
if (_server->hasArg(PARAM_VOLTAGE_FACTOR))
|
||||||
myConfig.setVoltageFactor(_server->arg(PARAM_VOLTAGEFACTOR).toFloat());
|
myConfig.setVoltageFactor(_server->arg(PARAM_VOLTAGE_FACTOR).toFloat());
|
||||||
|
if (_server->hasArg(PARAM_VOLTAGE_CONFIG))
|
||||||
|
myConfig.setVoltageConfig(_server->arg(PARAM_VOLTAGE_CONFIG).toFloat());
|
||||||
if (_server->hasArg(PARAM_TEMP_ADJ)) {
|
if (_server->hasArg(PARAM_TEMP_ADJ)) {
|
||||||
if (myConfig.isTempC()) {
|
if (myConfig.isTempC()) {
|
||||||
myConfig.setTempSensorAdjC(_server->arg(PARAM_TEMP_ADJ));
|
myConfig.setTempSensorAdjC(_server->arg(PARAM_TEMP_ADJ));
|
||||||
@ -626,7 +628,8 @@ void WebServerHandler::webHandleConfigHardware() {
|
|||||||
myConfig.setGyroTemp(false);
|
myConfig.setGyroTemp(false);
|
||||||
if (_server->hasArg(PARAM_STORAGE_SLEEP))
|
if (_server->hasArg(PARAM_STORAGE_SLEEP))
|
||||||
myConfig.setStorageSleep(
|
myConfig.setStorageSleep(
|
||||||
_server->arg(PARAM_STORAGE_SLEEP).equalsIgnoreCase("on") ? true : false);
|
_server->arg(PARAM_STORAGE_SLEEP).equalsIgnoreCase("on") ? true
|
||||||
|
: false);
|
||||||
else
|
else
|
||||||
myConfig.setStorageSleep(false);
|
myConfig.setStorageSleep(false);
|
||||||
|
|
||||||
|
@ -233,6 +233,10 @@ Hardware Settings
|
|||||||
|
|
||||||
Factor used to calcualate the battery voltage. If you get a too low/high voltage you can adjust this value.
|
Factor used to calcualate the battery voltage. If you get a too low/high voltage you can adjust this value.
|
||||||
|
|
||||||
|
* **Config voltage:**
|
||||||
|
|
||||||
|
Defines the level of voltage when the device should enter config mode due to charging. This might vary between different battery manufacturers.
|
||||||
|
|
||||||
* **Temperature correction:**
|
* **Temperature correction:**
|
||||||
|
|
||||||
This value will be added to the temperature reading (negative value will reduce temperature reading). This is applied
|
This value will be added to the temperature reading (negative value will reduce temperature reading). This is applied
|
||||||
@ -245,6 +249,13 @@ longer battery life (this is an experimental feature). The value used is the fir
|
|||||||
device is activated, since the gyro should be cool this is reflecting the surronding temperature. After it has
|
device is activated, since the gyro should be cool this is reflecting the surronding temperature. After it has
|
||||||
been running the value would be totally off.
|
been running the value would be totally off.
|
||||||
|
|
||||||
|
* **Enable storage mode when placed on cap**
|
||||||
|
|
||||||
|
Enable storage mode on the device. 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.
|
||||||
|
|
||||||
* **Bluetooth: (Only ESP32)**
|
* **Bluetooth: (Only ESP32)**
|
||||||
|
|
||||||
If the build is using an ESP32 then you can send data over BLE, simulating a Tilt device. Choose the color that you want the device to simulate.
|
If the build is using an ESP32 then you can send data over BLE, simulating a Tilt device. Choose the color that you want the device to simulate.
|
||||||
|
@ -17,6 +17,13 @@ Documentation
|
|||||||
User interface
|
User interface
|
||||||
++++++++++++++
|
++++++++++++++
|
||||||
* Under format options its now possible to select brewfather ispindle format to avoid mixing endpoints.
|
* 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)
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
Issues adressed
|
Issues adressed
|
||||||
++++++++++++++++
|
++++++++++++++++
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
"mqtt-port": 1883,
|
"mqtt-port": 1883,
|
||||||
"mqtt-user": "user",
|
"mqtt-user": "user",
|
||||||
"mqtt-pass": "pass",
|
"mqtt-pass": "pass",
|
||||||
|
"storage-sleep": true,
|
||||||
"sleep-interval": 30,
|
"sleep-interval": 30,
|
||||||
"voltage-factor": 1.59,
|
"voltage-factor": 1.59,
|
||||||
|
"voltage-config": 4.15,
|
||||||
"gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436",
|
"gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436",
|
||||||
"gravity-format": "G",
|
"gravity-format": "G",
|
||||||
"temp-adjustment-value": 0,
|
"temp-adjustment-value": 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user