diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 0ceec1c6c..c572f50a1 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -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 diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 50414dba7..aedd2024d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -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 diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 3ed654ebf..f4ee77603 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -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; diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 358defe4e..2a9aeed50 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -132,6 +132,12 @@ //#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) diff --git a/tasmota/xsns_78_ezo.ino b/tasmota/xsns_78_ezo.ino index 1507a36c4..72d22cf6f 100644 --- a/tasmota/xsns_78_ezo.ino +++ b/tasmota/xsns_78_ezo.ino @@ -17,7 +17,7 @@ along with this program. If not, see . */ #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 diff --git a/tasmota/xsns_78_ezoco2.ino b/tasmota/xsns_78_ezoco2.ino new file mode 100644 index 000000000..df23a05cf --- /dev/null +++ b/tasmota/xsns_78_ezoco2.ino @@ -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 . +*/ + +#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 diff --git a/tasmota/xsns_78_xezo.ino b/tasmota/xsns_78_xezo.ino index 659d3efa3..2284410de 100644 --- a/tasmota/xsns_78_xezo.ino +++ b/tasmota/xsns_78_xezo.ino @@ -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 = "pH"; //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