From 2b4d2f5bba73461c61b153be5a5be5453c7b2928 Mon Sep 17 00:00:00 2001 From: Alberto Lopez Date: Mon, 29 Jul 2019 12:44:49 -0300 Subject: [PATCH] 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){