Merge pull request #9585 from tichris0/development

Add support for EZORTD
This commit is contained in:
Theo Arends 2020-10-20 13:55:08 +02:00 committed by GitHub
commit 0ceb5879bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 96 additions and 5 deletions

View File

@ -79,3 +79,4 @@ Index | Define | Driver | Device | Address(es) | Description
54 | USE_VL53L1X | xsns_77 | VL53L1X | 0x29 | Time-of-flight (ToF) distance sensor
55 | USE_EZO_PH | xsns_78 | EZOPH | 0x61 - 0x70 | pH Sensor
55 | USE_EZO_ORP | xsns_79 | EZOORP | 0x61 - 0x70 | ORP Sensor
55 | USE_EZO_RTD | xsns_80 | EZORTD | 0x61 - 0x70 | Temperature Sensor

View File

@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_I2C
#if defined(USE_EZOPH) || defined(USE_EZOORP)
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD)
#define D_EZO_DELAY 300 // Minimum delay for any instruction
#define D_EZO_MAX_BUF 40 // Maximum response

View File

@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_I2C
#if defined(USE_EZOPH) || defined(USE_EZOORP)
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD)
#define XI2C_55 55 // See I2CDEVICES.md
@ -54,7 +54,9 @@ const char EZO_ORP_NAME[] PROGMEM = "ORP";
const char EZO_PH_NAME[] PROGMEM = "pH";
#endif
//const char EZO_EC_NAME[] PROGMEM = "EC";
//const char EZO_RTD_NAME[] PROGMEM = "RTD";
#ifdef USE_EZORTD
const char EZO_RTD_NAME[] PROGMEM = "RTD";
#endif
//const char EZO_PMP_NAME[] PROGMEM = "PMP";
//const char EZO_FLO_NAME[] PROGMEM = "FLO";
//const char EZO_CO2_NAME[] PROGMEM = "CO2";
@ -80,7 +82,13 @@ const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
EZO_EMPTY,
EZO_EMPTY,
#ifdef USE_EZORTD
EZO_RTD_NAME,
#else
EZO_EMPTY,
#endif
EZO_EMPTY,
EZO_EMPTY,
EZO_EMPTY,
@ -181,7 +189,7 @@ private:
data[0] = 'E';
data[1] = 'Z';
data[2] = 'O';
I2cSetActiveFound(addr, data);
I2cSetActiveFound(addr + EZO_ADDR_0, data);
devices[addr >> 3] |= j << ((addr & 7) * 4);
}
}

View File

@ -564,6 +564,7 @@
// #define USE_MLX90640 // [I2cDriver53] Enable MLX90640 IR array temperature sensor (I2C address 0x33) (+20k code)
// #define USE_EZOPH // [I2cDriver55] Enable support for EZO's pH sensor (+0k6 code) - Shared EZO code required for any EZO device (+1k0 code)
// #define USE_EZOORP // [I2cDriver55] Enable support for EZO's ORP sensor (+0k6 code) - Shared EZO code required for any EZO device (+1k0 code)
// #define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k6 code) - Shared EZO code required for any EZO device (+1k0 code)
// #define USE_DISPLAY // Add I2C Display Support (+2k code)
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0

View File

@ -633,7 +633,9 @@ void GetFeatures(void)
#if defined(USE_I2C) && defined(USE_EZOORP)
feature7 |= 0x00000001; // xsns_79_ezoorp.ino
#endif
// feature7 |= 0x00000002;
#if defined(USE_I2C) && defined(USE_EZORTD)
feature7 |= 0x00000002; // xsns_80_ezortd.ino
#endif
// feature7 |= 0x00000004;
// feature7 |= 0x00000008;

View File

@ -0,0 +1,79 @@
/*
xsns_80_ezortd.ino - EZO RTD I2C RTD sensor support for Tasmota
Copyright (C) 2020 Christopher Tremblay
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 <http://www.gnu.org/licenses/>.
*/
#ifdef USE_I2C
#ifdef USE_EZORTD
#define XSNS_80 80
#define EZO_RTD_READ_LATENCY 600
struct EZORTD : public EZOStruct {
void ProcessMeasurement(void)
{
char data[D_EZO_MAX_BUF];
EZOStruct::ProcessMeasurement(data, sizeof(data), EZO_RTD_READ_LATENCY);
RTD = CharToFloat(data);
}
void Show(bool json, uint32_t index)
{
if (valid) {
char str[10];
dtostrfd(ConvertTemp(RTD), 2, str);
char name[10];
snprintf_P(name, sizeof(name), PSTR("%s%c%X"), EZORTD::name, IndexSeparator(), index + 1);
if (count == 1) {
name[sizeof("EZORTD") - 1] = 0;
}
if (json) {
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s}"), name, str);
}
#ifdef USE_WEBSERVER
else {
WSContentSend_PD(HTTP_SNS_TEMP, name, str, TempUnit());
#endif // USE_WEBSERVER
}
}
}
static int8_t count;
static EZORTD *list;
static const char name[];
private:
float RTD = NAN;
};
int8_t EZORTD::count = -1;
EZORTD *EZORTD::list = NULL;
const char EZORTD::name[] PROGMEM = "EZORTD";
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
#define Xsns80 XsnsEZO<EZORTD, EZO_RTD>
#endif // USE_EZORTD
#endif // USE_I2C