From 6b4f0fd8ecc7968db3ed6ca985e63e54192db56e Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 20:20:17 -0300 Subject: [PATCH] Added check for USE_SPI enabled Reset MAX31865_PTD_BIAS to 0 by default --- sonoff/my_user_config.h | 3 +-- sonoff/xsns_47_max31865.ino | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index e612e51d8..c3a4afa72 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -426,14 +426,13 @@ #define USE_DHT // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor (1k6 code) //#define USE_MAX31855 // Add support for MAX31855 K-Type thermocouple sensor using softSPI - //#define USE_MAX31865 // Add support for MAX31865 RTD sensors using softSPI #ifdef USE_MAX31865 #define MAX31865_PTD_WIRES 2 // PTDs come in several flavors. Pick yours #define MAX31865_PTD_RES 100 // Nominal PTD resistance at 0°C (100Ω for a PT100, 1000Ω for a PT1000, YMMV!) #define MAX31865_REF_RES 430 // Reference resistor (Usually 430Ω for a PT100, 4300Ω for a PT1000) - #define MAX31865_PTD_BIAS -6.6 // To calibrate your not-so-good PTD + #define MAX31865_PTD_BIAS 0 // To calibrate your not-so-good PTD #endif // -- IR Remote features -------------------------- diff --git a/sonoff/xsns_47_max31865.ino b/sonoff/xsns_47_max31865.ino index d823a382d..6383ecaa3 100644 --- a/sonoff/xsns_47_max31865.ino +++ b/sonoff/xsns_47_max31865.ino @@ -18,6 +18,11 @@ */ #ifdef USE_MAX31865 + +#ifndef USE_SPI +#error "MAX31865 requires USE_SPI enabled" +#endif + #include "Adafruit_MAX31865.h" #define XSNS_47 47 @@ -74,15 +79,13 @@ void MAX31865_GetResult(void){ void MAX31865_Show(bool Json){ char temperature[33]; char resistance[33]; - char srtd[33]; - sprintf(srtd, "%d", MAX31865_Result.Rtd); dtostrfd(MAX31865_Result.PtdResistance, Settings.flag2.temperature_resolution, resistance); dtostrfd(MAX31865_Result.PtdTemp, Settings.flag2.temperature_resolution, temperature); if(Json){ - ResponseAppend_P(PSTR(",\"MAX31865\":{\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_RESISTANCE "\":%s,\"RTD\":%s,\"" D_JSON_ERROR "\":%d}"), \ - temperature, resistance, srtd, MAX31865_Result.ErrorCode); + ResponseAppend_P(PSTR(",\"MAX31865\":{\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_RESISTANCE "\":%s,\"" D_JSON_ERROR "\":%d}"), \ + temperature, resistance, MAX31865_Result.ErrorCode); #ifdef USE_DOMOTICZ if (0 == tele_period) { DomoticzSensor(DZ_TEMP, temperature);