From c2ad3d826423d2bc68419c6f4166dcf2e5b8b3d6 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Sat, 27 Jul 2019 19:58:17 -0300 Subject: [PATCH 01/10] Initial commit Working fine with MAX3165 and a PT100 probe. Using a modified version of Adafruit MAX31865 library. Added a default constructor in order to allow lazy initialization once GPIO definitions were loaded. Tested on a Sonoff TH PCB Board 2.1 2018-06-15 using the following GPIO mapping: GPIO Orig Func SSPI I/O HEADER HEADER2 S-JACK 15 BOOT MODE CLK O 1 14 MISO I 2 TIP 4 MOSI O 3 RING1 VCC 1 VCC 4 RING3 2 DBG BOOT ~CS O 5 EXP-LOG GND 4 GND RING2 HEADER2 is a 4-pin .1 header glued in the middle of the PCB to connect to several GPIO locations on the Sonoff TH PCB. TODO: Merge with MAX31855 code. --- lib/Adafruit_MAX31865-1.1.0-custom | 1 + platformio.ini | 4 +- sonoff/my_user_config.h | 11 +- sonoff/sonoff_template.h | 10 ++ sonoff/xsns_39_max31855.ino | 183 +++++++++++++++++++++-------- 5 files changed, 154 insertions(+), 55 deletions(-) create mode 160000 lib/Adafruit_MAX31865-1.1.0-custom diff --git a/lib/Adafruit_MAX31865-1.1.0-custom b/lib/Adafruit_MAX31865-1.1.0-custom new file mode 160000 index 000000000..83027ecdd --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom @@ -0,0 +1 @@ +Subproject commit 83027ecdd5c8e059510fcca5f230451c55ad078a diff --git a/platformio.ini b/platformio.ini index 59fab723d..b1142596c 100755 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ build_dir = .pioenvs ;env_default = sonoff-basic ;env_default = sonoff-classic ;env_default = sonoff-knx -;env_default = sonoff-sensors +env_default = sonoff-sensors ;env_default = sonoff-display ;env_default = sonoff-BG ;env_default = sonoff-BR @@ -207,7 +207,7 @@ upload_speed = 115200 upload_resetmethod = nodemcu ; *** Upload Serial reset method for Wemos and NodeMCU -upload_port = COM5 +upload_port = /dev/cu.usbserial-A5XK3RJT extra_scripts = pio/strip-floats.py ; *** Upload file to OTA server using SCP diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index c0130a4b4..079531770 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -44,7 +44,7 @@ \*********************************************************************************************/ // -- Master parameter control -------------------- -#define CFG_HOLDER 4617 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash +#define CFG_HOLDER 4618 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash // -- Project ------------------------------------- #define PROJECT "sonoff" // PROJECT is used as the default topic delimiter @@ -384,7 +384,7 @@ #endif // USE_I2C // -- SPI sensors --------------------------------- -//#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) +#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) #ifdef USE_SPI #ifndef USE_DISPLAY @@ -425,7 +425,12 @@ // -- Low level interface devices ----------------- #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_MAX31855 // Add support for MAX31855 K-Type thermocouple sensor using softSPI +#define USE_MAX318x5 // Add support for MAX31855/31865 K-Type thermocouple / RTD sensors using softSPI + +#ifdef USE_MAX318x5 +#define USE_MAX31855 // Until we move code to its own sourcefile we use 31855 original +#endif // -- IR Remote features -------------------------- #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k3 code, 0k3 mem, 48 iram) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 83ce16f08..155b9c4e0 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -187,6 +187,10 @@ enum UserSelectablePins { GPIO_BUZZER, // Buzzer GPIO_BUZZER_INV, // Inverted buzzer GPIO_OLED_RESET, // OLED Display Reset + GPIO_MAX318x5CS, // MAX318x5 SPI CS + GPIO_MAX318x5CLK, // MAX318x5 SPI CLK + GPIO_MAX318x5MISO, // MAX318x5 SPI MISO + GPIO_MAX318x5MOSI, // MAX318x5 SPI MOSI GPIO_SENSOR_END }; // Programmer selectable GPIO functionality @@ -623,6 +627,12 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_MAX31855CLK, // MAX31855 Serial interface GPIO_MAX31855DO, // MAX31855 Serial interface #endif +#ifdef USE_MAX318x5 + GPIO_MAX318x5CS, // MAX318x5 SPI CS + GPIO_MAX318x5CLK, // MAX318x5 SPI CLK + GPIO_MAX318x5MISO, // MAX318x5 SPI MISO + GPIO_MAX318x5MOSI, // MAX318x5 SPI MOSI +#endif #ifdef USE_LIGHT GPIO_DI, // my92x1 PWM input GPIO_DCKI, // my92x1 CLK input diff --git a/sonoff/xsns_39_max31855.ino b/sonoff/xsns_39_max31855.ino index 4f04c62db..edadeaba0 100644 --- a/sonoff/xsns_39_max31855.ino +++ b/sonoff/xsns_39_max31855.ino @@ -1,7 +1,8 @@ /* - xsns_39_max31855.ino - MAX31855 thermocouple sensor support for Sonoff-Tasmota + xsns_39_max318x5.ino - MAX318x5 thermocouple sensor support for Sonoff-Tasmota - Copyright (C) 2019 Markus Past + Copyright (C) 2019 Alberto Lopez + Based on original code written by Markus Past (2019) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,129 +18,194 @@ along with this program. If not, see . */ +//#if defined(USE_MAX31855) || defined(USE_MAX318x5) + #ifdef USE_MAX31855 +#include "Adafruit_MAX31865.h" #define XSNS_39 39 -bool initialized = false; +#define RTD0 104.0 // Temperature at 0 degrees Celcius +#define RREF 430.0 -struct MAX31855_ResultStruct{ +bool initialized = false; +bool begun = false; +bool toggle = false; + +Adafruit_MAX31865 max31865; +/* +Adafruit_MAX31865 max31865 = Adafruit_MAX31865( + pin[GPIO_SSPI_CS], + pin[GPIO_SSPI_MOSI], + pin[GPIO_SSPI_MISO], + pin[GPIO_SSPI_SCLK] +); +*/ + +union MAX318x5_Result_U { + struct MAX31855_S { uint8_t ErrorCode; // Error Codes: 0 = No Error / 1 = TC open circuit / 2 = TC short to GND / 4 = TC short to VCC float ProbeTemperature; // Measured temperature of the 'hot' TC junction (probe temp) float ReferenceTemperature; // Measured temperature of the 'cold' TC junction (reference temp) -} MAX31855_Result; + } Max31855; -void MAX31855_Init(void){ + struct MAX31865_S { + uint16_t PtdResistance; + float PtdTemp; + } Max31865; + +} MAX318x5_Result; + +void MAX318x5_Init(void){ if(initialized) return; +/************************************************************************ + MAX31855 Original Code. Commented out for now + // Set GPIO modes for SW-SPI - pinMode(pin[GPIO_MAX31855CS], OUTPUT); - pinMode(pin[GPIO_MAX31855CLK], OUTPUT); - pinMode(pin[GPIO_MAX31855DO], INPUT); + pinMode(pin[GPIO_MAX318x5CS], OUTPUT); + pinMode(pin[GPIO_MAX318x5CLK], OUTPUT); + pinMode(pin[GPIO_MAX318x5MISO], INPUT); // Chip not selected / Clock low - digitalWrite(pin[GPIO_MAX31855CS], HIGH); - digitalWrite(pin[GPIO_MAX31855CLK], LOW); + digitalWrite(pin[GPIO_MAX318x5CS], HIGH); + digitalWrite(pin[GPIO_MAX318x5CLK], LOW); initialized = true; +*/ + + // Set GPIO modes for SW-SPI + /* + pinMode(pin[GPIO_SSPI_CS], OUTPUT); + pinMode(pin[GPIO_SSPI_SCLK], OUTPUT); + pinMode(pin[GPIO_SSPI_MISO], INPUT); + pinMode(pin[GPIO_SSPI_MOSI], OUTPUT); + + // Chip not selected / Clock low + digitalWrite(pin[GPIO_SSPI_CS], HIGH); + digitalWrite(pin[GPIO_SSPI_SCLK], LOW); + digitalWrite(pin[GPIO_SSPI_MOSI], HIGH); +**************************************************************************/ + + max31865.setPins( + pin[GPIO_SSPI_CS], + pin[GPIO_SSPI_MOSI], + pin[GPIO_SSPI_MISO], + pin[GPIO_SSPI_SCLK] + ); + + begun = max31865.begin(MAX31865_2WIRE); + + initialized = true; } /* -* MAX31855_GetResult(void) -* Acquires the raw data via SPI, checks for MAX31855 errors and fills result structure +* MAX318x5_GetResult(void) +* Acquires the raw data via SPI, checks for MAX318x5 errors and fills result structure */ -void MAX31855_GetResult(void){ - int32_t RawData = MAX31855_ShiftIn(32); +void MAX318x5_GetResult(void){ +/************************************************************************ + MAX31855 Original Code. Commented out for now + + int32_t RawData = MAX318x5_ShiftIn(32); uint8_t probeerror = RawData & 0x7; - MAX31855_Result.ErrorCode = probeerror; - MAX31855_Result.ReferenceTemperature = MAX31855_GetReferenceTemperature(RawData); + MAX318x5_Result.ErrorCode = probeerror; + MAX318x5_Result.ReferenceTemperature = MAX318x5_GetReferenceTemperature(RawData); if(probeerror) - MAX31855_Result.ProbeTemperature = NAN; // Return NaN if MAX31855 reports an error + MAX318x5_Result.ProbeTemperature = NAN; // Return NaN if MAX318x5 reports an error else - MAX31855_Result.ProbeTemperature = MAX31855_GetProbeTemperature(RawData); + MAX318x5_Result.ProbeTemperature = MAX318x5_GetProbeTemperature(RawData); +**************************************************************************/ + + MAX318x5_Result.Max31865.PtdResistance = max31865.readRTD(); + MAX318x5_Result.Max31865.PtdTemp = max31865.rtd_to_temperature(MAX318x5_Result.Max31865.PtdResistance, RTD0, RREF); } /* -* MAX31855_GetProbeTemperature(int32_t RawData) +* MAX318x5_GetProbeTemperature(int32_t RawData) * Decodes and returns the temperature of TCs 'hot' junction from RawData */ -float MAX31855_GetProbeTemperature(int32_t RawData){ +float MAX318x5_GetProbeTemperature(int32_t RawData){ if(RawData & 0x80000000) RawData = (RawData >> 18) | 0xFFFFC000; // Negative value - Drop lower 18 bits and extend to negative number else RawData >>= 18; // Positiv value - Drop lower 18 bits - float result = (RawData * 0.25); // MAX31855 LSB resolution is 0.25°C for probe temperature + float result = (RawData * 0.25); // MAX318x5 LSB resolution is 0.25°C for probe temperature return (Settings.flag.temperature_conversion) ? ConvertTemp(result) : result; // Check if we have to convert to Fahrenheit } /* -* MAX31855_GetReferenceTemperature(int32_t RawData) +* MAX318x5_GetReferenceTemperature(int32_t RawData) * Decodes and returns the temperature of TCs 'cold' junction from RawData */ -float MAX31855_GetReferenceTemperature(int32_t RawData){ +float MAX318x5_GetReferenceTemperature(int32_t RawData){ if(RawData & 0x8000) RawData = (RawData >> 4) | 0xFFFFF000; // Negative value - Drop lower 4 bits and extend to negative number else RawData = (RawData >> 4) & 0x00000FFF; // Positiv value - Drop lower 4 bits and mask out remaining bits (probe temp, error bit, etc.) - float result = (RawData * 0.0625); // MAX31855 LSB resolution is 0.0625°C for reference temperature + float result = (RawData * 0.0625); // MAX318x5 LSB resolution is 0.0625°C for reference temperature return (Settings.flag.temperature_conversion) ? ConvertTemp(result) : result; // Check if we have to convert to Fahrenheit } /* -* MAX31855_ShiftIn(uint8_t Length) -* Communicates with MAX31855 via SW-SPI and returns the raw data read from the chip +* MAX318x5_ShiftIn(uint8_t Length) +* Communicates with MAX318x5 via SW-SPI and returns the raw data read from the chip */ -int32_t MAX31855_ShiftIn(uint8_t Length){ +int32_t MAX318x5_ShiftIn(uint8_t Length){ int32_t dataIn = 0; - digitalWrite(pin[GPIO_MAX31855CS], LOW); // CS = LOW -> Start SPI communication + digitalWrite(pin[GPIO_MAX318x5CS], LOW); // CS = LOW -> Start SPI communication delayMicroseconds(1); // CS fall to output enable = max. 100ns for (uint32_t i = 0; i < Length; i++) { - digitalWrite(pin[GPIO_MAX31855CLK], LOW); + digitalWrite(pin[GPIO_MAX318x5CLK], LOW); delayMicroseconds(1); // CLK pulse width low = min. 100ns / CLK fall to output valid = max. 40ns dataIn <<= 1; - if(digitalRead(pin[GPIO_MAX31855DO])) + if(digitalRead(pin[GPIO_MAX318x5MISO])) dataIn |= 1; - digitalWrite(pin[GPIO_MAX31855CLK], HIGH); + digitalWrite(pin[GPIO_MAX318x5CLK], HIGH); delayMicroseconds(1); // CLK pulse width high = min. 100ns } - digitalWrite(pin[GPIO_MAX31855CS], HIGH); // CS = HIGH -> End SPI communication - digitalWrite(pin[GPIO_MAX31855CLK], LOW); + digitalWrite(pin[GPIO_MAX318x5CS], HIGH); // CS = HIGH -> End SPI communication + digitalWrite(pin[GPIO_MAX318x5CLK], LOW); return dataIn; } -void MAX31855_Show(bool Json){ - char probetemp[33]; - char referencetemp[33]; - dtostrfd(MAX31855_Result.ProbeTemperature, Settings.flag2.temperature_resolution, probetemp); - dtostrfd(MAX31855_Result.ReferenceTemperature, Settings.flag2.temperature_resolution, referencetemp); +void MAX318x5_Show(bool Json){ + char temperature[33]; + char resistance[33]; + sprintf(resistance, "%ld", MAX318x5_Result.Max31865.PtdResistance); + dtostrfd(MAX318x5_Result.Max31865.PtdTemp, Settings.flag2.temperature_resolution, temperature); + + snprintf_P(log_data, sizeof(log_data), PSTR("MAX318x5_Show(%d), Resistance: %s, Temp: %s"), + Json, resistance, temperature); + AddLog(LOG_LEVEL_INFO); if(Json){ - ResponseAppend_P(PSTR(",\"MAX31855\":{\"" D_JSON_PROBETEMPERATURE "\":%s,\"" D_JSON_REFERENCETEMPERATURE "\":%s,\"" D_JSON_ERROR "\":%d}"), \ - probetemp, referencetemp, MAX31855_Result.ErrorCode); + ResponseAppend_P(PSTR(",\"MAX31865\":{\"" D_JSON_PROBETEMPERATURE "\":%s,\"" D_JSON_REFERENCETEMPERATURE "\":%s,\"" D_JSON_ERROR "\":%d}"), \ + temperature, resistance, 0); #ifdef USE_DOMOTICZ if (0 == tele_period) { - DomoticzSensor(DZ_TEMP, probetemp); + DomoticzSensor(DZ_TEMP, temperature); } #endif // USE_DOMOTICZ #ifdef USE_KNX if (0 == tele_period) { - KnxSensor(KNX_TEMPERATURE, MAX31855_Result.ProbeTemperature); + KnxSensor(KNX_TEMPERATURE, MAX318x5_Result.Max31865.PtdTemp); } #endif // USE_KNX } else { #ifdef USE_WEBSERVER - WSContentSend_PD(HTTP_SNS_TEMP, "MAX31855", probetemp, TempUnit()); + WSContentSend_PD(HTTP_SNS_TEMP, "MAX31865", temperature, TempUnit()); #endif // USE_WEBSERVER } } @@ -151,21 +217,38 @@ void MAX31855_Show(bool Json){ bool Xsns39(uint8_t function) { bool result = false; - if((pin[GPIO_MAX31855CS] < 99) && (pin[GPIO_MAX31855CLK] < 99) && (pin[GPIO_MAX31855DO] < 99)){ + if(1/*(pin[GPIO_MAX318x5CS] < 99) && (pin[GPIO_MAX318x5CLK] < 99) && (pin[GPIO_MAX318x5MISO] < 99) +#ifdef USE_MAX318x5 + && (pin[GPIO_MAX318x5MOSI] < 99) +#endif + */){ switch (function) { case FUNC_INIT: - MAX31855_Init(); + MAX318x5_Init(); + + snprintf_P(log_data, sizeof(log_data), PSTR("MAX318x5_Init(): %d, GPIO_SSPI_CS:%d, GPIO_SSPI_MOSI:%d, GPIO_SSPI_MISO:%d, GPIO_SSPI_SCLK:%d"), + begun, pin[GPIO_SSPI_CS], pin[GPIO_SSPI_MOSI], pin[GPIO_SSPI_MISO], pin[GPIO_SSPI_SCLK]); + AddLog(LOG_LEVEL_INFO); break; + case FUNC_EVERY_SECOND: - MAX31855_GetResult(); + MAX318x5_GetResult(); + + char temperature[33]; + dtostrfd(MAX318x5_Result.Max31865.PtdTemp, Settings.flag2.temperature_resolution, temperature); + snprintf_P(log_data, sizeof(log_data), PSTR("FUNC_EVERY_SECOND. Temp: %s, Resistance: %ld"), + temperature, MAX318x5_Result.Max31865.PtdResistance); + AddLog(LOG_LEVEL_INFO); break; + case FUNC_JSON_APPEND: - MAX31855_Show(true); + MAX318x5_Show(true); break; + #ifdef USE_WEBSERVER case FUNC_WEB_SENSOR: - MAX31855_Show(false); + MAX318x5_Show(false); break; #endif // USE_WEBSERVER } @@ -173,4 +256,4 @@ bool Xsns39(uint8_t function) return result; } -#endif // USE_MAX31855 \ No newline at end of file +#endif // USE_MAX318x5 From 475f208cdc19f0a9ffe59e0959deeb4f0e03aa9c Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Sun, 28 Jul 2019 19:36:22 -0300 Subject: [PATCH 02/10] All code moved to new file (xsnx_47_max31865.ino) Code streamlined. Unused code deleted. New "Resistance" string added to i18n to report PTD reported resistance USE_SPI enabled in my_user_config.h --- platformio.ini | 4 +- sonoff/i18n.h | 1 + sonoff/my_user_config.h | 9 +- sonoff/sonoff_template.h | 10 -- sonoff/xsns_39_max31855.ino | 181 ++++++++++-------------------------- sonoff/xsns_47_max31865.ino | 127 +++++++++++++++++++++++++ 6 files changed, 182 insertions(+), 150 deletions(-) create mode 100644 sonoff/xsns_47_max31865.ino diff --git a/platformio.ini b/platformio.ini index b1142596c..8e937f084 100755 --- a/platformio.ini +++ b/platformio.ini @@ -12,12 +12,12 @@ src_dir = sonoff build_dir = .pioenvs ; *** Uncomment one of the lines below to build/upload only one environment -;env_default = sonoff +env_default = sonoff ;env_default = sonoff-minimal ;env_default = sonoff-basic ;env_default = sonoff-classic ;env_default = sonoff-knx -env_default = sonoff-sensors +;env_default = sonoff-sensors ;env_default = sonoff-display ;env_default = sonoff-BG ;env_default = sonoff-BR diff --git a/sonoff/i18n.h b/sonoff/i18n.h index f72b2036b..c2e1e340f 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -118,6 +118,7 @@ #define D_JSON_PROGRAMSIZE "ProgramSize" #define D_JSON_REFERENCETEMPERATURE "ReferenceTemperature" #define D_JSON_RESET "Reset" +#define D_JSON_RESISTANCE "Resistance" #define D_JSON_RESOLUTION "Resolution" #define D_JSON_RESTARTING "Restarting" #define D_JSON_RESTARTREASON "RestartReason" diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 079531770..ef7e9393a 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -44,7 +44,7 @@ \*********************************************************************************************/ // -- Master parameter control -------------------- -#define CFG_HOLDER 4618 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash +#define CFG_HOLDER 4617 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash // -- Project ------------------------------------- #define PROJECT "sonoff" // PROJECT is used as the default topic delimiter @@ -425,12 +425,9 @@ // -- Low level interface devices ----------------- #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_MAX318x5 // Add support for MAX31855/31865 K-Type thermocouple / RTD sensors using softSPI +//#define USE_MAX31855 // Add support for MAX31855 K-Type thermocouple sensor using softSPI -#ifdef USE_MAX318x5 -#define USE_MAX31855 // Until we move code to its own sourcefile we use 31855 original -#endif +#define USE_MAX31865 // Add support for MAX31865 RTD sensors using softSPI // -- IR Remote features -------------------------- #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k3 code, 0k3 mem, 48 iram) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 155b9c4e0..83ce16f08 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -187,10 +187,6 @@ enum UserSelectablePins { GPIO_BUZZER, // Buzzer GPIO_BUZZER_INV, // Inverted buzzer GPIO_OLED_RESET, // OLED Display Reset - GPIO_MAX318x5CS, // MAX318x5 SPI CS - GPIO_MAX318x5CLK, // MAX318x5 SPI CLK - GPIO_MAX318x5MISO, // MAX318x5 SPI MISO - GPIO_MAX318x5MOSI, // MAX318x5 SPI MOSI GPIO_SENSOR_END }; // Programmer selectable GPIO functionality @@ -627,12 +623,6 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_MAX31855CLK, // MAX31855 Serial interface GPIO_MAX31855DO, // MAX31855 Serial interface #endif -#ifdef USE_MAX318x5 - GPIO_MAX318x5CS, // MAX318x5 SPI CS - GPIO_MAX318x5CLK, // MAX318x5 SPI CLK - GPIO_MAX318x5MISO, // MAX318x5 SPI MISO - GPIO_MAX318x5MOSI, // MAX318x5 SPI MOSI -#endif #ifdef USE_LIGHT GPIO_DI, // my92x1 PWM input GPIO_DCKI, // my92x1 CLK input diff --git a/sonoff/xsns_39_max31855.ino b/sonoff/xsns_39_max31855.ino index edadeaba0..4f04c62db 100644 --- a/sonoff/xsns_39_max31855.ino +++ b/sonoff/xsns_39_max31855.ino @@ -1,8 +1,7 @@ /* - xsns_39_max318x5.ino - MAX318x5 thermocouple sensor support for Sonoff-Tasmota + xsns_39_max31855.ino - MAX31855 thermocouple sensor support for Sonoff-Tasmota - Copyright (C) 2019 Alberto Lopez - Based on original code written by Markus Past (2019) + Copyright (C) 2019 Markus Past This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,194 +17,129 @@ along with this program. If not, see . */ -//#if defined(USE_MAX31855) || defined(USE_MAX318x5) - #ifdef USE_MAX31855 -#include "Adafruit_MAX31865.h" #define XSNS_39 39 -#define RTD0 104.0 // Temperature at 0 degrees Celcius -#define RREF 430.0 - bool initialized = false; -bool begun = false; -bool toggle = false; -Adafruit_MAX31865 max31865; -/* -Adafruit_MAX31865 max31865 = Adafruit_MAX31865( - pin[GPIO_SSPI_CS], - pin[GPIO_SSPI_MOSI], - pin[GPIO_SSPI_MISO], - pin[GPIO_SSPI_SCLK] -); -*/ - -union MAX318x5_Result_U { - struct MAX31855_S { +struct MAX31855_ResultStruct{ uint8_t ErrorCode; // Error Codes: 0 = No Error / 1 = TC open circuit / 2 = TC short to GND / 4 = TC short to VCC float ProbeTemperature; // Measured temperature of the 'hot' TC junction (probe temp) float ReferenceTemperature; // Measured temperature of the 'cold' TC junction (reference temp) - } Max31855; +} MAX31855_Result; - struct MAX31865_S { - uint16_t PtdResistance; - float PtdTemp; - } Max31865; - -} MAX318x5_Result; - -void MAX318x5_Init(void){ +void MAX31855_Init(void){ if(initialized) return; -/************************************************************************ - MAX31855 Original Code. Commented out for now - // Set GPIO modes for SW-SPI - pinMode(pin[GPIO_MAX318x5CS], OUTPUT); - pinMode(pin[GPIO_MAX318x5CLK], OUTPUT); - pinMode(pin[GPIO_MAX318x5MISO], INPUT); + pinMode(pin[GPIO_MAX31855CS], OUTPUT); + pinMode(pin[GPIO_MAX31855CLK], OUTPUT); + pinMode(pin[GPIO_MAX31855DO], INPUT); // Chip not selected / Clock low - digitalWrite(pin[GPIO_MAX318x5CS], HIGH); - digitalWrite(pin[GPIO_MAX318x5CLK], LOW); + digitalWrite(pin[GPIO_MAX31855CS], HIGH); + digitalWrite(pin[GPIO_MAX31855CLK], LOW); initialized = true; -*/ - - // Set GPIO modes for SW-SPI - /* - pinMode(pin[GPIO_SSPI_CS], OUTPUT); - pinMode(pin[GPIO_SSPI_SCLK], OUTPUT); - pinMode(pin[GPIO_SSPI_MISO], INPUT); - pinMode(pin[GPIO_SSPI_MOSI], OUTPUT); - - // Chip not selected / Clock low - digitalWrite(pin[GPIO_SSPI_CS], HIGH); - digitalWrite(pin[GPIO_SSPI_SCLK], LOW); - digitalWrite(pin[GPIO_SSPI_MOSI], HIGH); -**************************************************************************/ - - max31865.setPins( - pin[GPIO_SSPI_CS], - pin[GPIO_SSPI_MOSI], - pin[GPIO_SSPI_MISO], - pin[GPIO_SSPI_SCLK] - ); - - begun = max31865.begin(MAX31865_2WIRE); - - initialized = true; } /* -* MAX318x5_GetResult(void) -* Acquires the raw data via SPI, checks for MAX318x5 errors and fills result structure +* MAX31855_GetResult(void) +* Acquires the raw data via SPI, checks for MAX31855 errors and fills result structure */ -void MAX318x5_GetResult(void){ -/************************************************************************ - MAX31855 Original Code. Commented out for now - - int32_t RawData = MAX318x5_ShiftIn(32); +void MAX31855_GetResult(void){ + int32_t RawData = MAX31855_ShiftIn(32); uint8_t probeerror = RawData & 0x7; - MAX318x5_Result.ErrorCode = probeerror; - MAX318x5_Result.ReferenceTemperature = MAX318x5_GetReferenceTemperature(RawData); + MAX31855_Result.ErrorCode = probeerror; + MAX31855_Result.ReferenceTemperature = MAX31855_GetReferenceTemperature(RawData); if(probeerror) - MAX318x5_Result.ProbeTemperature = NAN; // Return NaN if MAX318x5 reports an error + MAX31855_Result.ProbeTemperature = NAN; // Return NaN if MAX31855 reports an error else - MAX318x5_Result.ProbeTemperature = MAX318x5_GetProbeTemperature(RawData); -**************************************************************************/ - - MAX318x5_Result.Max31865.PtdResistance = max31865.readRTD(); - MAX318x5_Result.Max31865.PtdTemp = max31865.rtd_to_temperature(MAX318x5_Result.Max31865.PtdResistance, RTD0, RREF); + MAX31855_Result.ProbeTemperature = MAX31855_GetProbeTemperature(RawData); } /* -* MAX318x5_GetProbeTemperature(int32_t RawData) +* MAX31855_GetProbeTemperature(int32_t RawData) * Decodes and returns the temperature of TCs 'hot' junction from RawData */ -float MAX318x5_GetProbeTemperature(int32_t RawData){ +float MAX31855_GetProbeTemperature(int32_t RawData){ if(RawData & 0x80000000) RawData = (RawData >> 18) | 0xFFFFC000; // Negative value - Drop lower 18 bits and extend to negative number else RawData >>= 18; // Positiv value - Drop lower 18 bits - float result = (RawData * 0.25); // MAX318x5 LSB resolution is 0.25°C for probe temperature + float result = (RawData * 0.25); // MAX31855 LSB resolution is 0.25°C for probe temperature return (Settings.flag.temperature_conversion) ? ConvertTemp(result) : result; // Check if we have to convert to Fahrenheit } /* -* MAX318x5_GetReferenceTemperature(int32_t RawData) +* MAX31855_GetReferenceTemperature(int32_t RawData) * Decodes and returns the temperature of TCs 'cold' junction from RawData */ -float MAX318x5_GetReferenceTemperature(int32_t RawData){ +float MAX31855_GetReferenceTemperature(int32_t RawData){ if(RawData & 0x8000) RawData = (RawData >> 4) | 0xFFFFF000; // Negative value - Drop lower 4 bits and extend to negative number else RawData = (RawData >> 4) & 0x00000FFF; // Positiv value - Drop lower 4 bits and mask out remaining bits (probe temp, error bit, etc.) - float result = (RawData * 0.0625); // MAX318x5 LSB resolution is 0.0625°C for reference temperature + float result = (RawData * 0.0625); // MAX31855 LSB resolution is 0.0625°C for reference temperature return (Settings.flag.temperature_conversion) ? ConvertTemp(result) : result; // Check if we have to convert to Fahrenheit } /* -* MAX318x5_ShiftIn(uint8_t Length) -* Communicates with MAX318x5 via SW-SPI and returns the raw data read from the chip +* MAX31855_ShiftIn(uint8_t Length) +* Communicates with MAX31855 via SW-SPI and returns the raw data read from the chip */ -int32_t MAX318x5_ShiftIn(uint8_t Length){ +int32_t MAX31855_ShiftIn(uint8_t Length){ int32_t dataIn = 0; - digitalWrite(pin[GPIO_MAX318x5CS], LOW); // CS = LOW -> Start SPI communication + digitalWrite(pin[GPIO_MAX31855CS], LOW); // CS = LOW -> Start SPI communication delayMicroseconds(1); // CS fall to output enable = max. 100ns for (uint32_t i = 0; i < Length; i++) { - digitalWrite(pin[GPIO_MAX318x5CLK], LOW); + digitalWrite(pin[GPIO_MAX31855CLK], LOW); delayMicroseconds(1); // CLK pulse width low = min. 100ns / CLK fall to output valid = max. 40ns dataIn <<= 1; - if(digitalRead(pin[GPIO_MAX318x5MISO])) + if(digitalRead(pin[GPIO_MAX31855DO])) dataIn |= 1; - digitalWrite(pin[GPIO_MAX318x5CLK], HIGH); + digitalWrite(pin[GPIO_MAX31855CLK], HIGH); delayMicroseconds(1); // CLK pulse width high = min. 100ns } - digitalWrite(pin[GPIO_MAX318x5CS], HIGH); // CS = HIGH -> End SPI communication - digitalWrite(pin[GPIO_MAX318x5CLK], LOW); + digitalWrite(pin[GPIO_MAX31855CS], HIGH); // CS = HIGH -> End SPI communication + digitalWrite(pin[GPIO_MAX31855CLK], LOW); return dataIn; } -void MAX318x5_Show(bool Json){ - char temperature[33]; - char resistance[33]; - sprintf(resistance, "%ld", MAX318x5_Result.Max31865.PtdResistance); - dtostrfd(MAX318x5_Result.Max31865.PtdTemp, Settings.flag2.temperature_resolution, temperature); - - snprintf_P(log_data, sizeof(log_data), PSTR("MAX318x5_Show(%d), Resistance: %s, Temp: %s"), - Json, resistance, temperature); - AddLog(LOG_LEVEL_INFO); +void MAX31855_Show(bool Json){ + char probetemp[33]; + char referencetemp[33]; + dtostrfd(MAX31855_Result.ProbeTemperature, Settings.flag2.temperature_resolution, probetemp); + dtostrfd(MAX31855_Result.ReferenceTemperature, Settings.flag2.temperature_resolution, referencetemp); if(Json){ - ResponseAppend_P(PSTR(",\"MAX31865\":{\"" D_JSON_PROBETEMPERATURE "\":%s,\"" D_JSON_REFERENCETEMPERATURE "\":%s,\"" D_JSON_ERROR "\":%d}"), \ - temperature, resistance, 0); + ResponseAppend_P(PSTR(",\"MAX31855\":{\"" D_JSON_PROBETEMPERATURE "\":%s,\"" D_JSON_REFERENCETEMPERATURE "\":%s,\"" D_JSON_ERROR "\":%d}"), \ + probetemp, referencetemp, MAX31855_Result.ErrorCode); #ifdef USE_DOMOTICZ if (0 == tele_period) { - DomoticzSensor(DZ_TEMP, temperature); + DomoticzSensor(DZ_TEMP, probetemp); } #endif // USE_DOMOTICZ #ifdef USE_KNX if (0 == tele_period) { - KnxSensor(KNX_TEMPERATURE, MAX318x5_Result.Max31865.PtdTemp); + KnxSensor(KNX_TEMPERATURE, MAX31855_Result.ProbeTemperature); } #endif // USE_KNX } else { #ifdef USE_WEBSERVER - WSContentSend_PD(HTTP_SNS_TEMP, "MAX31865", temperature, TempUnit()); + WSContentSend_PD(HTTP_SNS_TEMP, "MAX31855", probetemp, TempUnit()); #endif // USE_WEBSERVER } } @@ -217,38 +151,21 @@ void MAX318x5_Show(bool Json){ bool Xsns39(uint8_t function) { bool result = false; - if(1/*(pin[GPIO_MAX318x5CS] < 99) && (pin[GPIO_MAX318x5CLK] < 99) && (pin[GPIO_MAX318x5MISO] < 99) -#ifdef USE_MAX318x5 - && (pin[GPIO_MAX318x5MOSI] < 99) -#endif - */){ + if((pin[GPIO_MAX31855CS] < 99) && (pin[GPIO_MAX31855CLK] < 99) && (pin[GPIO_MAX31855DO] < 99)){ switch (function) { case FUNC_INIT: - MAX318x5_Init(); - - snprintf_P(log_data, sizeof(log_data), PSTR("MAX318x5_Init(): %d, GPIO_SSPI_CS:%d, GPIO_SSPI_MOSI:%d, GPIO_SSPI_MISO:%d, GPIO_SSPI_SCLK:%d"), - begun, pin[GPIO_SSPI_CS], pin[GPIO_SSPI_MOSI], pin[GPIO_SSPI_MISO], pin[GPIO_SSPI_SCLK]); - AddLog(LOG_LEVEL_INFO); + MAX31855_Init(); break; - case FUNC_EVERY_SECOND: - MAX318x5_GetResult(); - - char temperature[33]; - dtostrfd(MAX318x5_Result.Max31865.PtdTemp, Settings.flag2.temperature_resolution, temperature); - snprintf_P(log_data, sizeof(log_data), PSTR("FUNC_EVERY_SECOND. Temp: %s, Resistance: %ld"), - temperature, MAX318x5_Result.Max31865.PtdResistance); - AddLog(LOG_LEVEL_INFO); + MAX31855_GetResult(); break; - case FUNC_JSON_APPEND: - MAX318x5_Show(true); + MAX31855_Show(true); break; - #ifdef USE_WEBSERVER case FUNC_WEB_SENSOR: - MAX318x5_Show(false); + MAX31855_Show(false); break; #endif // USE_WEBSERVER } @@ -256,4 +173,4 @@ bool Xsns39(uint8_t function) return result; } -#endif // USE_MAX318x5 +#endif // USE_MAX31855 \ No newline at end of file diff --git a/sonoff/xsns_47_max31865.ino b/sonoff/xsns_47_max31865.ino new file mode 100644 index 000000000..00e0d8dd8 --- /dev/null +++ b/sonoff/xsns_47_max31865.ino @@ -0,0 +1,127 @@ +/* + xsns_39_MAX31865.ino - MAX31865 thermocouple sensor support for Sonoff-Tasmota + + Copyright (C) 2019 Alberto Lopez + Based on original code for MAx31855 written by Markus Past + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//#if defined(USE_MAX31855) || defined(USE_MAX31865) + +#ifdef USE_MAX31865 +#include "Adafruit_MAX31865.h" + +#define XSNS_47 47 + +#define RTD0 104.0 // Temperature at 0 degrees Celcius +#define RREF 430.0 + +int8_t init_status = 0; + +Adafruit_MAX31865 max31865; + +struct MAX31865_Result_Struct { + uint8_t ErrorCode; + uint16_t PtdResistance; + float PtdTemp; +} MAX31865_Result; + +void MAX31865_Init(void){ + if(init_status) + return; + + max31865.setPins( + pin[GPIO_SSPI_CS], + pin[GPIO_SSPI_MOSI], + pin[GPIO_SSPI_MISO], + pin[GPIO_SSPI_SCLK] + ); + + if(max31865.begin(MAX31865_2WIRE)) + init_status = 1; + else + init_status = -1; +} + +/* +* MAX31865_GetResult(void) +* Acquires the raw data via SPI, checks for MAX31865 errors and fills result structure +*/ +void MAX31865_GetResult(void){ + MAX31865_Result.PtdResistance = max31865.readRTD(); + MAX31865_Result.PtdTemp = max31865.rtd_to_temperature(MAX31865_Result.PtdResistance, RTD0, RREF); +} + +void MAX31865_Show(bool Json){ + char temperature[33]; + char resistance[33]; + + sprintf(resistance, "%ld", MAX31865_Result.PtdResistance); + dtostrfd(MAX31865_Result.PtdTemp, Settings.flag2.temperature_resolution, temperature); + + if(Json){ + 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); + } +#endif // USE_DOMOTICZ +#ifdef USE_KNX + if (0 == tele_period) { + KnxSensor(KNX_TEMPERATURE, MAX31865_Result.Max31865.PtdTemp); + } +#endif // USE_KNX + } else { +#ifdef USE_WEBSERVER + WSContentSend_PD(HTTP_SNS_TEMP, "MAX31865", temperature, TempUnit()); +#endif // USE_WEBSERVER + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xsns47(uint8_t function) +{ + bool result = false; + if((pin[GPIO_SSPI_MISO] < 99) && (pin[GPIO_SSPI_MOSI] < 99) && + (pin[GPIO_SSPI_SCLK] < 99) && (pin[GPIO_SSPI_CS] < 99)) { + + switch (function) { + case FUNC_INIT: + MAX31865_Init(); + break; + + case FUNC_EVERY_SECOND: + MAX31865_GetResult(); + break; + + case FUNC_JSON_APPEND: + MAX31865_Show(true); + break; + +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + MAX31865_Show(false); + break; +#endif // USE_WEBSERVER + } + } + return result; +} + +#endif // USE_MAX31865 From 2b4d2f5bba73461c61b153be5a5be5453c7b2928 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Mon, 29 Jul 2019 12:44:49 -0300 Subject: [PATCH 03/10] Added configuration variables as #defines in my_user_config.h Code in driver changed to se new config vars. --- sonoff/my_user_config.h | 6 ++++++ sonoff/xsns_47_max31865.ino | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index ef7e9393a..0f6e07e5f 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -429,6 +429,12 @@ #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) +#endif + // -- IR Remote features -------------------------- #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k3 code, 0k3 mem, 48 iram) // #define USE_IR_SEND_AIWA // Support IRsend Aiwa protocol diff --git a/sonoff/xsns_47_max31865.ino b/sonoff/xsns_47_max31865.ino index 00e0d8dd8..e3574fe12 100644 --- a/sonoff/xsns_47_max31865.ino +++ b/sonoff/xsns_47_max31865.ino @@ -1,8 +1,7 @@ /* xsns_39_MAX31865.ino - MAX31865 thermocouple sensor support for Sonoff-Tasmota - Copyright (C) 2019 Alberto Lopez - Based on original code for MAx31855 written by Markus Past + Copyright (C) 2019 Alberto Lopez Siemens This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,15 +17,18 @@ along with this program. If not, see . */ -//#if defined(USE_MAX31855) || defined(USE_MAX31865) - #ifdef USE_MAX31865 #include "Adafruit_MAX31865.h" #define XSNS_47 47 -#define RTD0 104.0 // Temperature at 0 degrees Celcius -#define RREF 430.0 +#if MAX31865_PTD_WIRES == 4 + #define PTD_WIRES MAX31865_4WIRE +#elif MAX31865_PTD_WIRES == 3 + #define PTD_WIRES MAX31865_3WIRE +#else + #define PTD_WIRES MAX31865_2WIRE +#endif int8_t init_status = 0; @@ -49,7 +51,7 @@ void MAX31865_Init(void){ pin[GPIO_SSPI_SCLK] ); - if(max31865.begin(MAX31865_2WIRE)) + if(max31865.begin(PTD_WIRES)) init_status = 1; else init_status = -1; @@ -61,7 +63,7 @@ void MAX31865_Init(void){ */ void MAX31865_GetResult(void){ MAX31865_Result.PtdResistance = max31865.readRTD(); - MAX31865_Result.PtdTemp = max31865.rtd_to_temperature(MAX31865_Result.PtdResistance, RTD0, RREF); + MAX31865_Result.PtdTemp = max31865.rtd_to_temperature(MAX31865_Result.PtdResistance, MAX31865_PTD_RES, MAX31865_REF_RES); } void MAX31865_Show(bool Json){ From 60198127ba24e3a1375a6bc377be6eb08edf67f5 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Mon, 29 Jul 2019 17:54:28 -0300 Subject: [PATCH 04/10] Added Adafruit MX31865 Library to Repo Added a #define to compensate for low quality PTD probes --- lib/Adafruit_MAX31865-1.1.0-custom | 1 - .../Adafruit_MAX31865.cpp | 286 ++++++++++++++++++ .../Adafruit_MAX31865.h | 99 ++++++ lib/Adafruit_MAX31865-1.1.0-custom/README.md | 2 + lib/Adafruit_MAX31865-1.1.0-custom/README.txt | 16 + .../examples/max31865/max31865.ino | 74 +++++ .../library.properties | 9 + sonoff/my_user_config.h | 1 + sonoff/xsns_47_max31865.ino | 19 +- 9 files changed, 500 insertions(+), 7 deletions(-) delete mode 160000 lib/Adafruit_MAX31865-1.1.0-custom create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/Adafruit_MAX31865.cpp create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/Adafruit_MAX31865.h create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/README.md create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/README.txt create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/examples/max31865/max31865.ino create mode 100644 lib/Adafruit_MAX31865-1.1.0-custom/library.properties diff --git a/lib/Adafruit_MAX31865-1.1.0-custom b/lib/Adafruit_MAX31865-1.1.0-custom deleted file mode 160000 index 83027ecdd..000000000 --- a/lib/Adafruit_MAX31865-1.1.0-custom +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 83027ecdd5c8e059510fcca5f230451c55ad078a diff --git a/lib/Adafruit_MAX31865-1.1.0-custom/Adafruit_MAX31865.cpp b/lib/Adafruit_MAX31865-1.1.0-custom/Adafruit_MAX31865.cpp new file mode 100644 index 000000000..984e5572a --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom/Adafruit_MAX31865.cpp @@ -0,0 +1,286 @@ +/*************************************************** + This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + + Designed specifically to work with the Adafruit RTD Sensor + ----> https://www.adafruit.com/products/3328 + + This sensor uses SPI to communicate, 4 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + BSD license, all text above must be included in any redistribution + ****************************************************/ + +#include "Adafruit_MAX31865.h" +#ifdef __AVR + #include +#elif defined(ESP8266) + #include +#endif + +#include +#include + +static SPISettings max31865_spisettings = SPISettings(500000, MSBFIRST, SPI_MODE1); + + + +// Software (bitbang) SPI +Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) { + setPins( spi_cs, spi_mosi, spi_miso, spi_clk); +} + +void Adafruit_MAX31865::setPins(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) { + _sclk = spi_clk; + _cs = spi_cs; + _miso = spi_miso; + _mosi = spi_mosi; +} + +// Hardware SPI init +Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs) { + _cs = spi_cs; + _sclk = _miso = _mosi = -1; +} + +// Default constructor +Adafruit_MAX31865::Adafruit_MAX31865(void) { + _cs = _sclk = _miso = _mosi = -1; +} + +boolean Adafruit_MAX31865::begin(max31865_numwires_t wires) { + pinMode(_cs, OUTPUT); + digitalWrite(_cs, HIGH); + + if (_sclk != -1) { + //define pin modes + pinMode(_sclk, OUTPUT); + digitalWrite(_sclk, LOW); + pinMode(_mosi, OUTPUT); + pinMode(_miso, INPUT); + } else { + //start and configure hardware SPI + SPI.begin(); + } + + for (uint8_t i=0; i<16; i++) { + // readRegister8(i); + } + + setWires(wires); + enableBias(false); + autoConvert(false); + clearFault(); + + //Serial.print("config: "); Serial.println(readRegister8(MAX31856_CONFIG_REG), HEX); + return true; +} + + +uint8_t Adafruit_MAX31865::readFault(void) { + return readRegister8(MAX31856_FAULTSTAT_REG); +} + +void Adafruit_MAX31865::clearFault(void) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + t &= ~0x2C; + t |= MAX31856_CONFIG_FAULTSTAT; + writeRegister8(MAX31856_CONFIG_REG, t); +} + +void Adafruit_MAX31865::enableBias(boolean b) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (b) { + t |= MAX31856_CONFIG_BIAS; // enable bias + } else { + t &= ~MAX31856_CONFIG_BIAS; // disable bias + } + writeRegister8(MAX31856_CONFIG_REG, t); +} + +void Adafruit_MAX31865::autoConvert(boolean b) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (b) { + t |= MAX31856_CONFIG_MODEAUTO; // enable autoconvert + } else { + t &= ~MAX31856_CONFIG_MODEAUTO; // disable autoconvert + } + writeRegister8(MAX31856_CONFIG_REG, t); +} + +void Adafruit_MAX31865::setWires(max31865_numwires_t wires ) { + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + if (wires == MAX31865_3WIRE) { + t |= MAX31856_CONFIG_3WIRE; + } else { + // 2 or 4 wire + t &= ~MAX31856_CONFIG_3WIRE; + } + writeRegister8(MAX31856_CONFIG_REG, t); +} + +float Adafruit_MAX31865::rtd_to_temperature(uint16_t rtd, float RTDnominal, float refResistor) { +//float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) { + // http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf + + float Z1, Z2, Z3, Z4, Rt, temp; + + Rt = rtd; + Rt /= 32768; + Rt *= refResistor; + + // Serial.print("\nResistance: "); Serial.println(Rt, 8); + + Z1 = -RTD_A; + Z2 = RTD_A * RTD_A - (4 * RTD_B); + Z3 = (4 * RTD_B) / RTDnominal; + Z4 = 2 * RTD_B; + + temp = Z2 + (Z3 * Rt); + temp = (sqrt(temp) + Z1) / Z4; + + if (temp >= 0) return temp; + + // ugh. + Rt /= RTDnominal; + Rt *= 100; // normalize to 100 ohm + + float rpoly = Rt; + + temp = -242.02; + temp += 2.2228 * rpoly; + rpoly *= Rt; // square + temp += 2.5859e-3 * rpoly; + rpoly *= Rt; // ^3 + temp -= 4.8260e-6 * rpoly; + rpoly *= Rt; // ^4 + temp -= 2.8183e-8 * rpoly; + rpoly *= Rt; // ^5 + temp += 1.5243e-10 * rpoly; + + return temp; +} + +float Adafruit_MAX31865::rtd_to_resistance(uint16_t rtd, float refResistor) { + float Rt; + + Rt = rtd; + Rt /= 32768; + Rt *= refResistor; + + return Rt; +} + +float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) { + uint16_t rtd = readRTD(); + return rtd_to_temperature(rtd, RTDnominal, refResistor); +} + +uint16_t Adafruit_MAX31865::readRTD (void) { + clearFault(); + enableBias(true); + delay(10); + uint8_t t = readRegister8(MAX31856_CONFIG_REG); + t |= MAX31856_CONFIG_1SHOT; + writeRegister8(MAX31856_CONFIG_REG, t); + delay(65); + + uint16_t rtd = readRegister16(MAX31856_RTDMSB_REG); + + // remove fault + rtd >>= 1; + + return rtd; +} + +/**********************************************/ + +uint8_t Adafruit_MAX31865::readRegister8(uint8_t addr) { + uint8_t ret = 0; + readRegisterN(addr, &ret, 1); + + return ret; +} + +uint16_t Adafruit_MAX31865::readRegister16(uint8_t addr) { + uint8_t buffer[2] = {0, 0}; + readRegisterN(addr, buffer, 2); + + uint16_t ret = buffer[0]; + ret <<= 8; + ret |= buffer[1]; + + return ret; +} + + +void Adafruit_MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { + addr &= 0x7F; // make sure top bit is not set + + if (_sclk == -1) + SPI.beginTransaction(max31865_spisettings); + else + digitalWrite(_sclk, LOW); + + digitalWrite(_cs, LOW); + + spixfer(addr); + + //Serial.print("$"); Serial.print(addr, HEX); Serial.print(": "); + while (n--) { + buffer[0] = spixfer(0xFF); + //Serial.print(" 0x"); Serial.print(buffer[0], HEX); + buffer++; + } + //Serial.println(); + + if (_sclk == -1) + SPI.endTransaction(); + + digitalWrite(_cs, HIGH); +} + + +void Adafruit_MAX31865::writeRegister8(uint8_t addr, uint8_t data) { + if (_sclk == -1) + SPI.beginTransaction(max31865_spisettings); + else + digitalWrite(_sclk, LOW); + + digitalWrite(_cs, LOW); + + spixfer(addr | 0x80); // make sure top bit is set + spixfer(data); + + //Serial.print("$"); Serial.print(addr, HEX); Serial.print(" = 0x"); Serial.println(data, HEX); + + if (_sclk == -1) + SPI.endTransaction(); + + digitalWrite(_cs, HIGH); +} + + + +uint8_t Adafruit_MAX31865::spixfer(uint8_t x) { + if (_sclk == -1) + return SPI.transfer(x); + + // software spi + //Serial.println("Software SPI"); + uint8_t reply = 0; + + for (int i=7; i>=0; i--) { + reply <<= 1; + digitalWrite(_sclk, HIGH); + digitalWrite(_mosi, x & (1< https://www.adafruit.com/products/3328 + + This sensor uses SPI to communicate, 4 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + BSD license, all text above must be included in any redistribution + ****************************************************/ + +#ifndef ADAFRUIT_MAX31865_H +#define ADAFRUIT_MAX31865_H + +#define MAX31856_CONFIG_REG 0x00 +#define MAX31856_CONFIG_BIAS 0x80 +#define MAX31856_CONFIG_MODEAUTO 0x40 +#define MAX31856_CONFIG_MODEOFF 0x00 +#define MAX31856_CONFIG_1SHOT 0x20 +#define MAX31856_CONFIG_3WIRE 0x10 +#define MAX31856_CONFIG_24WIRE 0x00 +#define MAX31856_CONFIG_FAULTSTAT 0x02 +#define MAX31856_CONFIG_FILT50HZ 0x01 +#define MAX31856_CONFIG_FILT60HZ 0x00 + +#define MAX31856_RTDMSB_REG 0x01 +#define MAX31856_RTDLSB_REG 0x02 +#define MAX31856_HFAULTMSB_REG 0x03 +#define MAX31856_HFAULTLSB_REG 0x04 +#define MAX31856_LFAULTMSB_REG 0x05 +#define MAX31856_LFAULTLSB_REG 0x06 +#define MAX31856_FAULTSTAT_REG 0x07 + + +#define MAX31865_FAULT_HIGHTHRESH 0x80 +#define MAX31865_FAULT_LOWTHRESH 0x40 +#define MAX31865_FAULT_REFINLOW 0x20 +#define MAX31865_FAULT_REFINHIGH 0x10 +#define MAX31865_FAULT_RTDINLOW 0x08 +#define MAX31865_FAULT_OVUV 0x04 + + +#define RTD_A 3.9083e-3 +#define RTD_B -5.775e-7 + +#if (ARDUINO >= 100) + #include "Arduino.h" +#else + #include "WProgram.h" +#endif + +typedef enum max31865_numwires { + MAX31865_2WIRE = 0, + MAX31865_3WIRE = 1, + MAX31865_4WIRE = 0 +} max31865_numwires_t; + + +class Adafruit_MAX31865 { + public: + Adafruit_MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk); + Adafruit_MAX31865(int8_t spi_cs); + Adafruit_MAX31865(void); + + void setPins(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk); + boolean begin(max31865_numwires_t x = MAX31865_2WIRE); + + uint8_t readFault(void); + void clearFault(void); + uint16_t readRTD(); + + + void setWires(max31865_numwires_t wires); + void autoConvert(boolean b); + void enableBias(boolean b); + + float temperature(float RTDnominal, float refResistor); + float rtd_to_temperature(uint16_t rtd, float RTDnominal, float refResistor); + float rtd_to_resistance(uint16_t rtd, float refResistor); + + private: + int8_t _sclk, _miso, _mosi, _cs; + + void readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n); + + uint8_t readRegister8(uint8_t addr); + uint16_t readRegister16(uint8_t addr); + + void writeRegister8(uint8_t addr, uint8_t reg); + uint8_t spixfer(uint8_t addr); +}; + + +#endif diff --git a/lib/Adafruit_MAX31865-1.1.0-custom/README.md b/lib/Adafruit_MAX31865-1.1.0-custom/README.md new file mode 100644 index 000000000..d3b9d2369 --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom/README.md @@ -0,0 +1,2 @@ +# Adafruit_MAX31865 +Arduino Library for Adafruit MAX31865 RTD Sensor diff --git a/lib/Adafruit_MAX31865-1.1.0-custom/README.txt b/lib/Adafruit_MAX31865-1.1.0-custom/README.txt new file mode 100644 index 000000000..edace57fd --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom/README.txt @@ -0,0 +1,16 @@ +This is the Adafruit MAX31856 Arduino Library + +Tested and works great with the Adafruit Thermocouple Breakout w/MAX31856 + + * http://www.adafruit.com/products/3328 + +These sensors use SPI to communicate, 4 pins are required to +interface + +Adafruit invests time and resources providing this open source code, +please support Adafruit and open-source hardware by purchasing +products from Adafruit! + +Written by Limor Fried/Ladyada for Adafruit Industries. +BSD license, check license.txt for more information +All text above must be included in any redistribution \ No newline at end of file diff --git a/lib/Adafruit_MAX31865-1.1.0-custom/examples/max31865/max31865.ino b/lib/Adafruit_MAX31865-1.1.0-custom/examples/max31865/max31865.ino new file mode 100644 index 000000000..5fc872f54 --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom/examples/max31865/max31865.ino @@ -0,0 +1,74 @@ +/*************************************************** + This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 + + Designed specifically to work with the Adafruit RTD Sensor + ----> https://www.adafruit.com/products/3328 + + This sensor uses SPI to communicate, 4 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + BSD license, all text above must be included in any redistribution + ****************************************************/ + +#include + +// Use software SPI: CS, DI, DO, CLK +Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13); +// use hardware SPI, just pass in the CS pin +//Adafruit_MAX31865 max = Adafruit_MAX31865(10); + +// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000 +#define RREF 430.0 +// The 'nominal' 0-degrees-C resistance of the sensor +// 100.0 for PT100, 1000.0 for PT1000 +#define RNOMINAL 100.0 + +void setup() { + Serial.begin(115200); + Serial.println("Adafruit MAX31865 PT100 Sensor Test!"); + + max.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary +} + + +void loop() { + uint16_t rtd = max.readRTD(); + + Serial.print("RTD value: "); Serial.println(rtd); + float ratio = rtd; + ratio /= 32768; + Serial.print("Ratio = "); Serial.println(ratio,8); + Serial.print("Resistance = "); Serial.println(RREF*ratio,8); + Serial.print("Temperature = "); Serial.println(max.temperature(RNOMINAL, RREF)); + + // Check and print any faults + uint8_t fault = max.readFault(); + if (fault) { + Serial.print("Fault 0x"); Serial.println(fault, HEX); + if (fault & MAX31865_FAULT_HIGHTHRESH) { + Serial.println("RTD High Threshold"); + } + if (fault & MAX31865_FAULT_LOWTHRESH) { + Serial.println("RTD Low Threshold"); + } + if (fault & MAX31865_FAULT_REFINLOW) { + Serial.println("REFIN- > 0.85 x Bias"); + } + if (fault & MAX31865_FAULT_REFINHIGH) { + Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); + } + if (fault & MAX31865_FAULT_RTDINLOW) { + Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); + } + if (fault & MAX31865_FAULT_OVUV) { + Serial.println("Under/Over voltage"); + } + max.clearFault(); + } + Serial.println(); + delay(1000); +} diff --git a/lib/Adafruit_MAX31865-1.1.0-custom/library.properties b/lib/Adafruit_MAX31865-1.1.0-custom/library.properties new file mode 100644 index 000000000..f132a890a --- /dev/null +++ b/lib/Adafruit_MAX31865-1.1.0-custom/library.properties @@ -0,0 +1,9 @@ +name=Adafruit MAX31865 library +version=1.0.1 +author=Adafruit +maintainer=Adafruit +sentence=Library for the Adafruit RTD Amplifier breakout with MAX31865 +paragraph=Library for the Adafruit RTD Amplifier breakout with MAX31865 +category=Sensors +url=https://github.com/adafruit/Adafruit_MAX31865 +architectures=* diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 0f6e07e5f..1db4ce969 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -433,6 +433,7 @@ #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 #endif // -- IR Remote features -------------------------- diff --git a/sonoff/xsns_47_max31865.ino b/sonoff/xsns_47_max31865.ino index e3574fe12..e5d18b609 100644 --- a/sonoff/xsns_47_max31865.ino +++ b/sonoff/xsns_47_max31865.ino @@ -36,7 +36,8 @@ Adafruit_MAX31865 max31865; struct MAX31865_Result_Struct { uint8_t ErrorCode; - uint16_t PtdResistance; + uint16_t Rtd; + float PtdResistance; float PtdTemp; } MAX31865_Result; @@ -62,20 +63,26 @@ void MAX31865_Init(void){ * Acquires the raw data via SPI, checks for MAX31865 errors and fills result structure */ void MAX31865_GetResult(void){ - MAX31865_Result.PtdResistance = max31865.readRTD(); - MAX31865_Result.PtdTemp = max31865.rtd_to_temperature(MAX31865_Result.PtdResistance, MAX31865_PTD_RES, MAX31865_REF_RES); + uint16_t rtd; + + rtd = max31865.readRTD(); + MAX31865_Result.Rtd = rtd; + MAX31865_Result.PtdResistance = max31865.rtd_to_resistance(rtd, MAX31865_REF_RES); + MAX31865_Result.PtdTemp = max31865.rtd_to_temperature(rtd, MAX31865_PTD_RES, MAX31865_REF_RES) + MAX31865_PTD_BIAS; } void MAX31865_Show(bool Json){ char temperature[33]; char resistance[33]; + char srtd[33]; - sprintf(resistance, "%ld", MAX31865_Result.PtdResistance); + 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,\"" D_JSON_ERROR "\":%d}"), \ - temperature, resistance, MAX31865_Result.ErrorCode); + ResponseAppend_P(PSTR(",\"MAX31865\":{\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_RESISTANCE "\":%s,\"RTD\":%s,\"" D_JSON_ERROR "\":%d}"), \ + temperature, resistance, srtd, MAX31865_Result.ErrorCode); #ifdef USE_DOMOTICZ if (0 == tele_period) { DomoticzSensor(DZ_TEMP, temperature); From b3727316519973edd6d08dfb9575df4bd2f25c5b Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Mon, 29 Jul 2019 19:57:32 -0300 Subject: [PATCH 05/10] Revergted platformio.ini to default prior to PR --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8e937f084..59fab723d 100755 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,7 @@ src_dir = sonoff build_dir = .pioenvs ; *** Uncomment one of the lines below to build/upload only one environment -env_default = sonoff +;env_default = sonoff ;env_default = sonoff-minimal ;env_default = sonoff-basic ;env_default = sonoff-classic @@ -207,7 +207,7 @@ upload_speed = 115200 upload_resetmethod = nodemcu ; *** Upload Serial reset method for Wemos and NodeMCU -upload_port = /dev/cu.usbserial-A5XK3RJT +upload_port = COM5 extra_scripts = pio/strip-floats.py ; *** Upload file to OTA server using SCP From 509b9c6dead559cf7b21c96e480a09c0723a8e73 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 12:57:08 -0300 Subject: [PATCH 06/10] Commented USE_SPI and USE_MAX31865 by default. Fixed bad struct member usage. --- sonoff/my_user_config.h | 5 ++--- sonoff/xsns_47_max31865.ino | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 1db4ce969..488d05765 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -384,7 +384,7 @@ #endif // USE_I2C // -- SPI sensors --------------------------------- -#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) +//#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) #ifdef USE_SPI #ifndef USE_DISPLAY @@ -427,13 +427,12 @@ //#define USE_MAX31855 // Add support for MAX31855 K-Type thermocouple sensor using softSPI -#define USE_MAX31865 // Add support for MAX31865 RTD sensors 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 #endif // -- IR Remote features -------------------------- diff --git a/sonoff/xsns_47_max31865.ino b/sonoff/xsns_47_max31865.ino index e5d18b609..d823a382d 100644 --- a/sonoff/xsns_47_max31865.ino +++ b/sonoff/xsns_47_max31865.ino @@ -90,7 +90,7 @@ void MAX31865_Show(bool Json){ #endif // USE_DOMOTICZ #ifdef USE_KNX if (0 == tele_period) { - KnxSensor(KNX_TEMPERATURE, MAX31865_Result.Max31865.PtdTemp); + KnxSensor(KNX_TEMPERATURE, MAX31865_Result.PtdTemp); } #endif // USE_KNX } else { From bc95f11c99951491b03a641812cb7d686d9f6fee Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 15:38:40 -0300 Subject: [PATCH 07/10] Added missing #define MAX31865_PTD_BIAS lost in branch switching --- platformio.ini | 613 ---------------------------------------- sonoff/my_user_config.h | 1 + 2 files changed, 1 insertion(+), 613 deletions(-) delete mode 100755 platformio.ini diff --git a/platformio.ini b/platformio.ini deleted file mode 100755 index 59fab723d..000000000 --- a/platformio.ini +++ /dev/null @@ -1,613 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter, extra scripting -; Upload options: custom port, speed and extra flags -; Library options: dependencies, extra library storages -; -; Please visit documentation for the other options and examples -; http://docs.platformio.org/en/stable/projectconf.html - -[platformio] -src_dir = sonoff -build_dir = .pioenvs - -; *** Uncomment one of the lines below to build/upload only one environment -;env_default = sonoff -;env_default = sonoff-minimal -;env_default = sonoff-basic -;env_default = sonoff-classic -;env_default = sonoff-knx -;env_default = sonoff-sensors -;env_default = sonoff-display -;env_default = sonoff-BG -;env_default = sonoff-BR -;env_default = sonoff-CN -;env_default = sonoff-CZ -;env_default = sonoff-DE -;env_default = sonoff-ES -;env_default = sonoff-FR -;env_default = sonoff-GR -;env_default = sonoff-HE -;env_default = sonoff-HU -;env_default = sonoff-IT -;env_default = sonoff-KO -;env_default = sonoff-NL -;env_default = sonoff-PL -;env_default = sonoff-PT -;env_default = sonoff-RU -;env_default = sonoff-SE -;env_default = sonoff-SK -;env_default = sonoff-TR -;env_default = sonoff-TW -;env_default = sonoff-UK - -[esp82xx_defaults] -build_flags = -D NDEBUG - -mtarget-align - -Wl,-Map,firmware.map - -[core_2_3_0] -; *** Esp8266 core for Arduino version 2.3.0 -platform = espressif8266@1.5.0 -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Tesp8266.flash.1m0.ld - -[core_2_4_2] -; *** Esp8266 core for Arduino version 2.4.2 -platform = espressif8266@1.8.0 -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Teagle.flash.1m0.ld - -lstdc++ -lsupc++ -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -; lwIP 2 - Low Memory -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -; lwIP 2 - Higher Bandwidth (Tasmota default) - -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH - -DVTABLES_IN_FLASH - -[core_2_5_2] -; *** Esp8266 core for Arduino version 2.5.2 -platform = espressif8266@~2.2.2 -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Teagle.flash.1m.ld -; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473 - -O2 - -DBEARSSL_SSL_BASIC -; nonos-sdk 22x - -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x -; nonos-sdk-pre-v3 -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -; lwIP 2 - Low Memory -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -; lwIP 2 - Higher Bandwidth -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -; lwIP 2 - Higher Bandwidth Low Memory no Features -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH -; lwIP 2 - Higher Bandwidth no Features (Tasmota default) - -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH - -DVTABLES_IN_FLASH - -fno-exceptions - -lstdc++ - -[core_stage] -; *** Esp8266 core for Arduino version latest beta -platform = https://github.com/platformio/platform-espressif8266.git#feature/stage -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Teagle.flash.1m.ld -; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473 - -O2 - -DBEARSSL_SSL_BASIC -; nonos-sdk 22y - -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y -; nonos-sdk 22x -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x -; nonos-sdk-pre-v3 -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -; lwIP 2 - Low Memory -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -; lwIP 2 - Higher Bandwidth -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -; lwIP 2 - Higher Bandwitdh Low Memory no Features -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH -; lwIP 2 - Higher Bandwitdh no Features - -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -; VTABLES in Flash (default) - -DVTABLES_IN_FLASH -; VTABLES in Heap -; -DVTABLES_IN_DRAM -; VTABLES in IRAM -; -DVTABLES_IN_IRAM -; enable one option set -> No exception recommended -; No exception code in firmware - -fno-exceptions - -lstdc++ -; Exception code in firmware /needs much space! 90k -; -fexceptions -; -lstdc++-exc - -[core_pre] -; *** Arduino Esp8266 core pre 2.6.x for Tasmota (mqtt reconnects fixed) -platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota -build_flags = ${esp82xx_defaults.build_flags} - -Wl,-Tesp8266.flash.1m.ld - -O2 - -DBEARSSL_SSL_BASIC -; nonos-sdk 22y - -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y -; nonos-sdk 22x -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x -; nonos-sdk-pre-v3 -; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -; lwIP 2 - Low Memory -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -; lwIP 2 - Higher Bandwidth -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -; lwIP 2 - Higher Bandwitdh Low Memory no Features -; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH -; lwIP 2 - Higher Bandwitdh no Features - -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -; VTABLES in Flash (default) - -DVTABLES_IN_FLASH -; VTABLES in Heap -; -DVTABLES_IN_DRAM -; VTABLES in IRAM -; -DVTABLES_IN_IRAM -; enable one option set -> No exception recommended -; No exception code in firmware - -fno-exceptions - -lstdc++ -; Exception code in firmware /needs much space! -; -fexceptions -; -lstdc++-exc - -[core_active] -; Select one core set for platform and build_flags -;platform = ${core_2_3_0.platform} -;build_flags = ${core_2_3_0.build_flags} -;platform = ${core_2_4_2.platform} -;build_flags = ${core_2_4_2.build_flags} -platform = ${core_2_5_2.platform} -build_flags = ${core_2_5_2.build_flags} -;platform = ${core_stage.platform} -;build_flags = ${core_stage.build_flags} -;platform = ${core_pre.platform} -;build_flags = ${core_pre.build_flags} - -[common] -framework = arduino -board = esp01_1m -board_build.flash_mode = dout - -platform = ${core_active.platform} -build_flags = ${core_active.build_flags} -; -DFIRMWARE_CLASSIC -; -DFIRMWARE_MINIMAL -; -DFIRMWARE_SENSORS -; -DFIRMWARE_BASIC -; -DFIRMWARE_KNX_NO_EMULATION -; -DFIRMWARE_DISPLAYS -; -DUSE_CONFIG_OVERRIDE - -; *** Fix espressif8266@1.7.0 induced undesired all warnings -build_unflags = -Wall - -; set CPU frequency to 80MHz (default) or 160MHz -board_build.f_cpu = 80000000L -;board_build.f_cpu = 160000000L - -monitor_speed = 115200 -upload_speed = 115200 -upload_resetmethod = nodemcu - -; *** Upload Serial reset method for Wemos and NodeMCU -upload_port = COM5 -extra_scripts = pio/strip-floats.py - -; *** Upload file to OTA server using SCP -;upload_port = user@host:/path -;extra_scripts = pio/strip-floats.py, pio/sftp-uploader.py - -; *** Upload file to OTA server in folder api/arduino using HTTP -;upload_port = domus1:80/api/upload-arduino.php -;extra_scripts = pio/strip-floats.py, pio/http-uploader.py - -; ********************************************************************* - -[env:sonoff] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-minimal] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-basic] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_BASIC -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-classic] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_CLASSIC -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-knx] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-sensors] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_SENSORS -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-display] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-BG] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=bg-BG -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-BR] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=pt-BR -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-CN] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-CN -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-CZ] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=cs-CZ -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-DE] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-ES] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=es-ES -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-FR] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=fr-FR -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-GR] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=el-GR -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-HE] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=he-HE -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-HU] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=hu-HU -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-IT] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=it-IT -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-KO] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=ko-KO -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-NL] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-PL] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=pl-PL -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-PT] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=pt-PT -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-RU] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=ru-RU -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-SE] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=sv-SE -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-SK] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=sk-SK -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-TR] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=tr-TR -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-TW] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-TW -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} - -[env:sonoff-UK] -platform = ${common.platform} -framework = ${common.framework} -board = ${common.board} -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_cpu = ${common.board_build.f_cpu} -build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} -DMY_LANGUAGE=uk-UK -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = ${common.upload_speed} -extra_scripts = ${common.extra_scripts} diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 488d05765..e612e51d8 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -433,6 +433,7 @@ #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 #endif // -- IR Remote features -------------------------- From db4170e84dc743e4e2306b7221e3a9ce7713d249 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 15:42:46 -0300 Subject: [PATCH 08/10] Reverted original platformio.ini --- platformio.ini | 571 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 571 insertions(+) create mode 100644 platformio.ini diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 000000000..f4be6ad3f --- /dev/null +++ b/platformio.ini @@ -0,0 +1,571 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[platformio] +src_dir = sonoff + +; *** Uncomment one of the lines below to build/upload only one environment +;env_default = sonoff +;env_default = sonoff-minimal +;env_default = sonoff-basic +;env_default = sonoff-classic +;env_default = sonoff-knx +;env_default = sonoff-sensors +;env_default = sonoff-display +;env_default = sonoff-BG +;env_default = sonoff-BR +;env_default = sonoff-CN +;env_default = sonoff-CZ +;env_default = sonoff-DE +;env_default = sonoff-ES +;env_default = sonoff-FR +;env_default = sonoff-GR +;env_default = sonoff-HE +;env_default = sonoff-HU +;env_default = sonoff-IT +;env_default = sonoff-KO +;env_default = sonoff-NL +;env_default = sonoff-PL +;env_default = sonoff-PT +;env_default = sonoff-RU +;env_default = sonoff-SE +;env_default = sonoff-SK +;env_default = sonoff-TR +;env_default = sonoff-TW +;env_default = sonoff-UK + +[esp82xx_defaults] +build_flags = -D NDEBUG + -mtarget-align + -Wl,-Map,firmware.map + +[core_2_3_0] +; *** Esp8266 core for Arduino version 2.3.0 +platform = espressif8266@1.5.0 +build_flags = ${esp82xx_defaults.build_flags} + -Wl,-Tesp8266.flash.1m0.ld + +[core_2_4_2] +; *** Esp8266 core for Arduino version 2.4.2 +platform = espressif8266@1.8.0 +build_flags = ${esp82xx_defaults.build_flags} + -Wl,-Teagle.flash.1m0.ld + -lstdc++ -lsupc++ +; lwIP 1.4 +; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH +; lwIP 2 - Low Memory +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY +; lwIP 2 - Higher Bandwidth (Tasmota default) + -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH + -DVTABLES_IN_FLASH + +[core_2_5_2] +; *** Esp8266 core for Arduino version 2.5.2 +platform = espressif8266@~2.2.2 +build_flags = ${esp82xx_defaults.build_flags} + -Wl,-Teagle.flash.1m.ld +; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473 + -O2 + -DBEARSSL_SSL_BASIC +; nonos-sdk 22x + -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x +; nonos-sdk-pre-v3 +; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 +; lwIP 1.4 +; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH +; lwIP 2 - Low Memory +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY +; lwIP 2 - Higher Bandwidth +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH +; lwIP 2 - Higher Bandwidth Low Memory no Features +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH +; lwIP 2 - Higher Bandwidth no Features (Tasmota default) + -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH + -DVTABLES_IN_FLASH + -fno-exceptions + -lstdc++ + +[core_stage] +; *** Esp8266 core for Arduino version latest beta +platform = https://github.com/platformio/platform-espressif8266.git#feature/stage +build_flags = ${esp82xx_defaults.build_flags} + -Wl,-Teagle.flash.1m.ld +; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473 + -O2 + -DBEARSSL_SSL_BASIC +; nonos-sdk 22x + -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x +; nonos-sdk-pre-v3 +; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 +; lwIP 1.4 +; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH +; lwIP 2 - Low Memory +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY +; lwIP 2 - Higher Bandwidth +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH +; lwIP 2 - Higher Bandwitdh Low Memory no Features +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH +; lwIP 2 - Higher Bandwitdh no Features + -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH +; VTABLES in Flash (default) + -DVTABLES_IN_FLASH +; VTABLES in Heap +; -DVTABLES_IN_DRAM +; VTABLES in IRAM +; -DVTABLES_IN_IRAM +; enable one option set -> No exception recommended +; No exception code in firmware + -fno-exceptions + -lstdc++ +; Exception code in firmware /needs much space! 90k +; -fexceptions +; -lstdc++-exc + +[core_active] +; Select one core set for platform and build_flags +platform = ${core_2_3_0.platform} +build_flags = ${core_2_3_0.build_flags} +;platform = ${core_2_4_2.platform} +;build_flags = ${core_2_4_2.build_flags} +;platform = ${core_2_5_2.platform} +;build_flags = ${core_2_5_2.build_flags} +;platform = ${core_stage.platform} +;build_flags = ${core_stage.build_flags} + +[common] +framework = arduino +board = esp01_1m +board_build.flash_mode = dout + +platform = ${core_active.platform} +build_flags = ${core_active.build_flags} +; -DFIRMWARE_CLASSIC +; -DFIRMWARE_MINIMAL +; -DFIRMWARE_SENSORS +; -DFIRMWARE_BASIC +; -DFIRMWARE_KNX_NO_EMULATION +; -DFIRMWARE_DISPLAYS +; -DUSE_CONFIG_OVERRIDE + +; *** Fix espressif8266@1.7.0 induced undesired all warnings +build_unflags = -Wall + +; set CPU frequency to 80MHz (default) or 160MHz +board_build.f_cpu = 80000000L +;board_build.f_cpu = 160000000L + +monitor_speed = 115200 +upload_speed = 115200 +upload_resetmethod = nodemcu + +; *** Upload Serial reset method for Wemos and NodeMCU +upload_port = COM5 +extra_scripts = pio/strip-floats.py + +; *** Upload file to OTA server using SCP +;upload_port = user@host:/path +;extra_scripts = pio/strip-floats.py, pio/sftp-uploader.py + +; *** Upload file to OTA server in folder api/arduino using HTTP +;upload_port = domus1:80/api/upload-arduino.php +;extra_scripts = pio/strip-floats.py, pio/http-uploader.py + +; ********************************************************************* + +[env:sonoff] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-minimal] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-basic] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_BASIC +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-classic] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_CLASSIC +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-knx] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-sensors] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_SENSORS +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-display] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-BG] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=bg-BG +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-BR] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=pt-BR +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-CN] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-CN +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-CZ] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=cs-CZ +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-DE] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-ES] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=es-ES +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-FR] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=fr-FR +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-GR] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=el-GR +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-HE] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=he-HE +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-HU] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=hu-HU +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-IT] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=it-IT +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-KO] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=ko-KO +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-NL] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-PL] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=pl-PL +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-PT] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=pt-PT +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-RU] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=ru-RU +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-SE] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=sv-SE +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-SK] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=sk-SK +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-TR] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=tr-TR +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-TW] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-TW +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} + +[env:sonoff-UK] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board} +board_build.flash_mode = ${common.board_build.flash_mode} +board_build.f_cpu = ${common.board_build.f_cpu} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} -DMY_LANGUAGE=uk-UK +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_resetmethod = ${common.upload_resetmethod} +upload_speed = ${common.upload_speed} +extra_scripts = ${common.extra_scripts} From 768ba48dbb72b7690933cb9164ea02ae0f17def8 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 15:48:12 -0300 Subject: [PATCH 09/10] Sorry... wrong platformio.ini used (it should be dev branch instead master) --- platformio.ini | 52 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) mode change 100644 => 100755 platformio.ini diff --git a/platformio.ini b/platformio.ini old mode 100644 new mode 100755 index f4be6ad3f..59fab723d --- a/platformio.ini +++ b/platformio.ini @@ -9,6 +9,7 @@ [platformio] src_dir = sonoff +build_dir = .pioenvs ; *** Uncomment one of the lines below to build/upload only one environment ;env_default = sonoff @@ -99,8 +100,10 @@ build_flags = ${esp82xx_defaults.build_flags} ; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473 -O2 -DBEARSSL_SSL_BASIC +; nonos-sdk 22y + -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y ; nonos-sdk 22x - -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x +; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x ; nonos-sdk-pre-v3 ; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 ; lwIP 1.4 @@ -127,16 +130,55 @@ build_flags = ${esp82xx_defaults.build_flags} ; -fexceptions ; -lstdc++-exc +[core_pre] +; *** Arduino Esp8266 core pre 2.6.x for Tasmota (mqtt reconnects fixed) +platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota +build_flags = ${esp82xx_defaults.build_flags} + -Wl,-Tesp8266.flash.1m.ld + -O2 + -DBEARSSL_SSL_BASIC +; nonos-sdk 22y + -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y +; nonos-sdk 22x +; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x +; nonos-sdk-pre-v3 +; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 +; lwIP 1.4 +; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH +; lwIP 2 - Low Memory +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY +; lwIP 2 - Higher Bandwidth +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH +; lwIP 2 - Higher Bandwitdh Low Memory no Features +; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH +; lwIP 2 - Higher Bandwitdh no Features + -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH +; VTABLES in Flash (default) + -DVTABLES_IN_FLASH +; VTABLES in Heap +; -DVTABLES_IN_DRAM +; VTABLES in IRAM +; -DVTABLES_IN_IRAM +; enable one option set -> No exception recommended +; No exception code in firmware + -fno-exceptions + -lstdc++ +; Exception code in firmware /needs much space! +; -fexceptions +; -lstdc++-exc + [core_active] ; Select one core set for platform and build_flags -platform = ${core_2_3_0.platform} -build_flags = ${core_2_3_0.build_flags} +;platform = ${core_2_3_0.platform} +;build_flags = ${core_2_3_0.build_flags} ;platform = ${core_2_4_2.platform} ;build_flags = ${core_2_4_2.build_flags} -;platform = ${core_2_5_2.platform} -;build_flags = ${core_2_5_2.build_flags} +platform = ${core_2_5_2.platform} +build_flags = ${core_2_5_2.build_flags} ;platform = ${core_stage.platform} ;build_flags = ${core_stage.build_flags} +;platform = ${core_pre.platform} +;build_flags = ${core_pre.build_flags} [common] framework = arduino From 6b4f0fd8ecc7968db3ed6ca985e63e54192db56e Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Tue, 30 Jul 2019 20:20:17 -0300 Subject: [PATCH 10/10] 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);