mirror of https://github.com/arendst/Tasmota.git
Merge pull request #9619 from tichris0/development
Add support for EZO CO2 sensor
This commit is contained in:
commit
37e68db05a
|
@ -77,7 +77,9 @@ Index | Define | Driver | Device | Address(es) | Description
|
|||
52 | USE_HP303B | xsns_73 | HP303B | 0x76 - 0x77 | Pressure and temperature sensor
|
||||
53 | USE_MLX90640 | xdrv_84 | MLX90640 | 0x33 | IR array temperature sensor
|
||||
54 | USE_VL53L1X | xsns_77 | VL53L1X | 0x29 | Time-of-flight (ToF) distance sensor
|
||||
55 | USE_EZOPH | xsns_78 | EZOPH | 0x61 - 0x70 | pH Sensor
|
||||
55 | USE_EZOORP | xsns_78 | EZOORP | 0x61 - 0x70 | ORP Sensor
|
||||
55 | USE_EZORTD | xsns_78 | EZORTD | 0x61 - 0x70 | Temperature Sensor
|
||||
55 | USE_EZOHUM | xsns_78 | EZORTD | 0x61 - 0x70 | Humidity Sensor
|
||||
55 | USE_EZOPH | xsns_78 | EZOPH | 0x61 - 0x70 | pH sensor
|
||||
55 | USE_EZOORP | xsns_78 | EZOORP | 0x61 - 0x70 | ORP sensor
|
||||
55 | USE_EZORTD | xsns_78 | EZORTD | 0x61 - 0x70 | Temperature sensor
|
||||
55 | USE_EZOHUM | xsns_78 | EZOHUM | 0x61 - 0x70 | Humidity sensor
|
||||
55 | USE_EZOEC | xsns_78 | EZOEC | 0x61 - 0x70 | Electric conductivity sensor
|
||||
55 | USE_EZOCO2 | xsns_78 | EZOCO2 | 0x61 - 0x70 | CO2 sensor
|
||||
|
|
|
@ -567,6 +567,11 @@
|
|||
// #define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
// #define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
// #define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
// #define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC) || defined(USE_EZOCO2)
|
||||
#define USE_EZO
|
||||
#endif
|
||||
|
||||
// #define USE_DISPLAY // Add I2C Display Support (+2k code)
|
||||
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0
|
||||
|
|
|
@ -642,8 +642,9 @@ void GetFeatures(void)
|
|||
#if defined(USE_I2C) && defined(USE_EZOEC)
|
||||
feature7 |= 0x00000008; // xsns_78_ezoec.ino
|
||||
#endif
|
||||
|
||||
// feature7 |= 0x00000010;
|
||||
#if defined(USE_I2C) && defined(USE_EZOCO2)
|
||||
feature7 |= 0x00000010;
|
||||
#endif
|
||||
// feature7 |= 0x00000020;
|
||||
// feature7 |= 0x00000040;
|
||||
// feature7 |= 0x00000080;
|
||||
|
|
|
@ -132,6 +132,11 @@
|
|||
//#define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
//#define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
//#define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
//#define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC) || defined(USE_EZOCO2)
|
||||
#define USE_EZO
|
||||
#endif
|
||||
|
||||
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
|
||||
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
||||
|
|
|
@ -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) || defined(USE_EZOHUM) || defined(USE_EZOEC)
|
||||
#if defined(USE_EZO)
|
||||
|
||||
#define D_EZO_DELAY 300 // Minimum delay for any instruction
|
||||
#define D_EZO_MAX_BUF 40 // Maximum response
|
||||
|
@ -106,5 +106,5 @@ protected:
|
|||
|
||||
|
||||
|
||||
#endif // USE_EZO*
|
||||
#endif // USE_EZO
|
||||
#endif // USE_I2C
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
xsns_78_ezoco2.ino - EZO CO2 I2C CO2 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_EZOCO2
|
||||
|
||||
#define EZO_CO2_READ_LATENCY 900
|
||||
|
||||
struct EZOCO2 : public EZOStruct {
|
||||
EZOCO2(uint32_t addr) : EZOStruct(addr), CO2(0) {}
|
||||
|
||||
virtual void ProcessMeasurement(void)
|
||||
{
|
||||
char data[D_EZO_MAX_BUF];
|
||||
|
||||
EZOStruct::ProcessMeasurement(data, sizeof(data), EZO_CO2_READ_LATENCY);
|
||||
|
||||
// sensor has a 10s warmup period
|
||||
if (uptime >= 10) {
|
||||
CO2 = atoi(data);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Show(bool json, const char *name)
|
||||
{
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_CO2 "\":%d}" ), name, CO2);
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
else {
|
||||
WSContentSend_PD(HTTP_SNS_CO2, name, CO2);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t CO2;
|
||||
};
|
||||
|
||||
#endif // USE_EZOCO2
|
||||
#endif // USE_I2C
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#ifdef USE_I2C
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC)
|
||||
#if defined(USE_EZO)
|
||||
|
||||
#define XSNS_78 78
|
||||
#define XI2C_55 55 // See I2CDEVICES.md
|
||||
|
@ -65,7 +65,7 @@ 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";
|
||||
const char EZO_CO2_NAME[] PROGMEM = "CO2";
|
||||
//const char EZO_PRS_NAME[] PROGMEM = "PRS";
|
||||
//const char EZO_O2_NAME[] PROGMEM = "O2";
|
||||
#ifdef USE_EZOHUM
|
||||
|
@ -104,7 +104,13 @@ const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
|||
|
||||
EZO_EMPTY,
|
||||
EZO_EMPTY,
|
||||
|
||||
#ifdef USE_EZOCO2
|
||||
EZO_CO2_NAME,
|
||||
#else
|
||||
EZO_EMPTY,
|
||||
#endif
|
||||
|
||||
EZO_EMPTY,
|
||||
EZO_EMPTY,
|
||||
EZO_EMPTY,
|
||||
|
@ -265,6 +271,11 @@ private:
|
|||
sensor[count] = new EZORTD(addr);
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_EZOCO2
|
||||
case EZO_CO2:
|
||||
sensor[count] = new EZOCO2(addr);
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_EZOHUM
|
||||
case EZO_HUM:
|
||||
sensor[count] = new EZOHUM(addr);
|
||||
|
@ -324,5 +335,5 @@ bool Xsns78(uint8_t function)
|
|||
return false;
|
||||
}
|
||||
|
||||
#endif // USE_EZO*
|
||||
#endif // USE_EZO
|
||||
#endif // USE_I2C
|
||||
|
|
Loading…
Reference in New Issue