Browse Source

Small fixes to temperature correction code

fastled
Xose Pérez 7 years ago
parent
commit
f5c247c4c0
9 changed files with 2410 additions and 2411 deletions
  1. +0
    -1
      code/espurna/config/general.h
  2. +3
    -1
      code/espurna/config/sensors.h
  3. BIN
      code/espurna/data/index.html.gz
  4. +3
    -3
      code/espurna/dht.ino
  5. +3
    -4
      code/espurna/ds18b20.ino
  6. +2396
    -2396
      code/espurna/static/index.html.gz.h
  7. +1
    -1
      code/espurna/ws.ino
  8. +1
    -3
      code/html/custom.js
  9. +3
    -2
      code/html/index.html

+ 0
- 1
code/espurna/config/general.h View File

@ -246,7 +246,6 @@ PROGMEM const char* const custom_reset_string[] = {
#define TMP_CELSIUS 0
#define TMP_FAHRENHEIT 1
#define TMP_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
#define TMP_CORRECTION 0.0
//------------------------------------------------------------------------------
// LED


+ 3
- 1
code/espurna/config/sensors.h View File

@ -38,13 +38,15 @@
#define DHT_TEMPERATURE_TOPIC "temperature"
#define DHT_HUMIDITY_TOPIC "humidity"
#define DHT_TEMPERATURE_DECIMALS 1 // Decimals for temperature values
#define DHT_TEMPERATURE_DECIMALS 1 // Decimals for temperature values
#define HUMIDITY_NORMAL 0
#define HUMIDITY_COMFORTABLE 1
#define HUMIDITY_DRY 2
#define HUMIDITY_WET 3
#define TEMPERATURE_CORRECTION 0.0 // This is both for DHT and DS18B20
//--------------------------------------------------------------------------------
// Analog sensor
// Enable support by passing ANALOG_SUPPORT=1 build flag


BIN
code/espurna/data/index.html.gz View File


+ 3
- 3
code/espurna/dht.ino View File

@ -147,7 +147,8 @@ void _dhtWebSocketOnSend(JsonObject& root) {
double getDHTTemperature(bool celsius) {
double value = celsius ? _dhtTemperature : _dhtTemperature * 1.8 + 32;
return roundTo(value, DHT_TEMPERATURE_DECIMALS);
double correction = getSetting("tmpCorrection", TEMPERATURE_CORRECTION).toFloat();
return roundTo(value + correction, DHT_TEMPERATURE_DECIMALS);
}
double getDHTTemperature() {
@ -187,8 +188,7 @@ void dhtLoop() {
if (readDHT(DHT_PIN, DHT_TYPE) == DHT_OK) {
unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt();
double tmpCorrection = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
double t = getDHTTemperature(tmpUnits == TMP_CELSIUS) + tmpCorrection;
double t = getDHTTemperature(tmpUnits == TMP_CELSIUS);
unsigned int h = getDHTHumidity();
char temperature[6];


+ 3
- 4
code/espurna/ds18b20.ino View File

@ -86,14 +86,13 @@ void dsLoop() {
requested = false;
last_update = millis();
unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt();
double tmpCorrection = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
// Read sensor data
unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt();
double t = (tmpUnits == TMP_CELSIUS) ? ds18b20.getTempCByIndex(0) : ds18b20.getTempFByIndex(0);
// apply temperature reading correction
t = t + tmpCorrection;
double correction = getSetting("tmpCorrection", TEMPERATURE_CORRECTION).toFloat();
t = t + correction;
// Check if readings are valid
if (isnan(t) || t < -50) {


+ 2396
- 2396
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 1
- 1
code/espurna/ws.ino View File

@ -296,7 +296,7 @@ void _wsStart(uint32_t client_id) {
root["btnDelay"] = getSetting("btnDelay", BUTTON_DBLCLICK_DELAY).toInt();
root["webPort"] = getSetting("webPort", WEB_PORT).toInt();
root["tmpUnits"] = getSetting("tmpUnits", TMP_UNITS).toInt();
root["tmpCorrection"] = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
root["tmpCorrection"] = getSetting("tmpCorrection", TEMPERATURE_CORRECTION).toFloat();
// Callbacks
for (unsigned char i = 0; i < _ws_on_send_callbacks.size(); i++) {


+ 1
- 3
code/html/custom.js View File

@ -734,9 +734,7 @@ function processData(data) {
if (key == "tmpUnits") {
$("span#tmpUnit").html(data[key] == 1 ? "ºF" : "ºC");
}
if (key == "tmpCorrection") {
$("span#tmpCorrection").val(data[key]);
}
// Look for INPUTs
var element = $("input[name=" + key + "]");
if (element.length > 0) {


+ 3
- 2
code/html/index.html View File

@ -430,10 +430,11 @@
<div class="pure-g module module-ds module-dht">
<label class="pure-u-1 pure-u-md-1-4" for="tmpCorrection">Temperature correction</label>
<input name="tmpCorrection" class="pure-u-1 pure-u-md-3-4" type="number" action="reset" min="-100" step="0.1" max="100" tabindex="6" />
<input name="tmpCorrection" class="pure-u-1 pure-u-md-1-4" type="number" action="reset" min="-100" step="0.1" max="100" tabindex="17" />
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">
Temperature correction value is added to the measured value which may be inaccurate due to many factors. The value can be negative.
Temperature correction value is added to the measured value which may be inaccurate due to many factors. The value can be negative.
</div>
</div>


Loading…
Cancel
Save