mirror of https://github.com/arendst/Tasmota.git
Add support for EZO HUM
Adds suppotr for EZO humidity&temp sensor.
This commit is contained in:
parent
bb7f93ea98
commit
a70bebe0ad
|
@ -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) || defined(USE_EZORTD)
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM)
|
||||
|
||||
#define D_EZO_DELAY 300 // Minimum delay for any instruction
|
||||
#define D_EZO_MAX_BUF 40 // Maximum response
|
||||
|
|
|
@ -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) || defined(USE_EZORTD)
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM)
|
||||
|
||||
#define XI2C_55 55 // See I2CDEVICES.md
|
||||
|
||||
|
@ -62,7 +62,9 @@ const char EZO_RTD_NAME[] PROGMEM = "RTD";
|
|||
//const char EZO_CO2_NAME[] PROGMEM = "CO2";
|
||||
//const char EZO_PRS_NAME[] PROGMEM = "PRS";
|
||||
//const char EZO_O2_NAME[] PROGMEM = "O2";
|
||||
//const char EZO_HUM_NAME[] PROGMEM = "HUM";
|
||||
#ifdef USE_EZOHUM
|
||||
const char EZO_HUM_NAME[] PROGMEM = "HUM";
|
||||
#endif
|
||||
//const char EZO_RGB_NAME[] PROGMEM = "RGB";
|
||||
|
||||
const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
||||
|
@ -97,7 +99,13 @@ const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
|||
EZO_EMPTY,
|
||||
EZO_EMPTY,
|
||||
EZO_EMPTY,
|
||||
|
||||
#ifdef USE_EZOHUM
|
||||
EZO_HUM_NAME,
|
||||
#else
|
||||
EZO_EMPTY,
|
||||
#endif
|
||||
|
||||
EZO_EMPTY,
|
||||
};
|
||||
|
||||
|
|
|
@ -565,6 +565,7 @@
|
|||
// #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_EZOHUM // [I2cDriver55] Enable support for EZO's HUM 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
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
xsns_81_ezortd.ino - EZO HUM I2C HUM 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_EZOHUM
|
||||
|
||||
#define XSNS_81 81
|
||||
|
||||
#define EZO_HUM_READ_LATENCY 300
|
||||
|
||||
struct EZOHUM : public EZOStruct {
|
||||
void ProcessMeasurement(void)
|
||||
{
|
||||
char data[D_EZO_MAX_BUF];
|
||||
// Hum, Temp, Dew
|
||||
|
||||
EZOStruct::ProcessMeasurement(data, sizeof(data), EZO_HUM_READ_LATENCY);
|
||||
|
||||
humidity = CharToFloat(data);
|
||||
|
||||
char *next = strchr(data, ',');
|
||||
if (next) {
|
||||
temperature = CharToFloat(next + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Show(bool json, uint32_t index)
|
||||
{
|
||||
if (valid) {
|
||||
char name[10];
|
||||
snprintf_P(name, sizeof(name), PSTR("%s%c%X"), EZOHUM::name, IndexSeparator(), index + 1);
|
||||
|
||||
if (count == 1) {
|
||||
name[sizeof("EZOHUM") - 1] = 0;
|
||||
}
|
||||
|
||||
if (isnan(temperature)) {
|
||||
char parameter[FLOATSZ];
|
||||
|
||||
dtostrfd(humidity, Settings.flag2.humidity_resolution, parameter);
|
||||
WSContentSend_PD(HTTP_SNS_HUM, name, parameter);
|
||||
} else {
|
||||
TempHumDewShow(json, (0 == tele_period), name, temperature, humidity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t count;
|
||||
static EZOHUM *list;
|
||||
|
||||
private:
|
||||
static const char name[];
|
||||
|
||||
float humidity = NAN;
|
||||
float temperature = NAN;
|
||||
};
|
||||
|
||||
int8_t EZOHUM::count = -1;
|
||||
EZOHUM *EZOHUM::list = NULL;
|
||||
const char EZOHUM::name[] PROGMEM = "EZOHUM";
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
#define Xsns81 XsnsEZO<EZOHUM, EZO_HUM>
|
||||
|
||||
#endif // USE_EZOHUM
|
||||
#endif // USE_I2C
|
Loading…
Reference in New Issue