Browse Source

added option to correct temperature value read from ds18b20 or dth22 sensor

fastled
Pawel Raszewski 7 years ago
parent
commit
581b97ad3f
8 changed files with 2795 additions and 2771 deletions
  1. +1
    -0
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +2
    -1
      code/espurna/dht.ino
  4. +5
    -1
      code/espurna/ds18b20.ino
  5. +2774
    -2768
      code/espurna/static/index.html.gz.h
  6. +1
    -0
      code/espurna/web.ino
  7. +3
    -1
      code/html/custom.js
  8. +9
    -0
      code/html/index.html

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

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


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


+ 2
- 1
code/espurna/dht.ino View File

@ -171,7 +171,8 @@ void dhtLoop() {
if (readDHT(DHT_PIN, DHT_TYPE) == DHT_OK) { if (readDHT(DHT_PIN, DHT_TYPE) == DHT_OK) {
unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt(); unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt();
double t = getDHTTemperature(tmpUnits == TMP_CELSIUS);
double tmpCorrection = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
double t = getDHTTemperature(tmpUnits == TMP_CELSIUS) + tmpCorrection;
unsigned int h = getDHTHumidity(); unsigned int h = getDHTHumidity();
char temperature[6]; char temperature[6];


+ 5
- 1
code/espurna/ds18b20.ino View File

@ -74,17 +74,21 @@ void dsLoop() {
last_update = millis(); last_update = millis();
unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt(); unsigned char tmpUnits = getSetting("tmpUnits", TMP_UNITS).toInt();
double tmpCorrection = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
// Read sensor data // Read sensor data
double t = (tmpUnits == TMP_CELSIUS) ? ds18b20.getTempCByIndex(0) : ds18b20.getTempFByIndex(0); double t = (tmpUnits == TMP_CELSIUS) ? ds18b20.getTempCByIndex(0) : ds18b20.getTempFByIndex(0);
// apply temperature reading correction
t = t + tmpCorrection;
// Check if readings are valid // Check if readings are valid
if (isnan(t) || t < -50) { if (isnan(t) || t < -50) {
DEBUG_MSG_P(PSTR("[DS18B20] Error reading sensor\n")); DEBUG_MSG_P(PSTR("[DS18B20] Error reading sensor\n"));
} else { } else {
//If the new temperature is different from the last //If the new temperature is different from the last
if (fabs(t - last_temperature) >= DS18B20_UPDATE_ON_CHANGE) { if (fabs(t - last_temperature) >= DS18B20_UPDATE_ON_CHANGE) {
last_temperature = t; last_temperature = t;


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


+ 1
- 0
code/espurna/web.ino View File

@ -564,6 +564,7 @@ void _wsStart(uint32_t client_id) {
root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1; root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
root["tmpUnits"] = getSetting("tmpUnits", TMP_UNITS).toInt(); root["tmpUnits"] = getSetting("tmpUnits", TMP_UNITS).toInt();
root["tmpCorrection"] = getSetting("tmpCorrection", TMP_CORRECTION).toFloat();
#if HOMEASSISTANT_SUPPORT #if HOMEASSISTANT_SUPPORT
root["haVisible"] = 1; root["haVisible"] = 1;


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

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


+ 9
- 0
code/html/index.html View File

@ -436,6 +436,15 @@
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="15" value="1"> Fahrenheit (&deg;F)</input></div> <div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="15" value="1"> Fahrenheit (&deg;F)</input></div>
</div> </div>
<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" />
<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.
</div>
</div>
</fieldset> </fieldset>
</div> </div>
</div> </div>


Loading…
Cancel
Save