Add support for EZO O2

Adds support for EZO O2 sensor
This commit is contained in:
Christopher Tremblay 2020-10-27 03:38:54 -07:00
parent b4dc2600c5
commit db338f1d81
31 changed files with 128 additions and 15 deletions

View File

@ -83,3 +83,4 @@ Index | Define | Driver | Device | Address(es) | Description
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
55 | USE_EZOO2 | xsns_78 | EZOO2 | 0x61 - 0x70 | O2 sensor

View File

@ -113,6 +113,7 @@
#define D_JSON_NONE "None"
#define D_JSON_OR "or"
#define D_JSON_ORP "ORP"
#define D_JSON_O2 "Oxygen"
#define D_JSON_PERIOD "Period"
#define D_JSON_PH "pH"
#define D_JSON_PHASE_ANGLE "PhaseAngle"
@ -775,6 +776,7 @@ const char HTTP_SNS_ENERGY_TOTAL[] PROGMEM = "{s}" D_ENERGY_TOTAL "{
const char HTTP_SNS_PH[] PROGMEM = "{s}%s " D_PH "{m}%s " "{e}";
const char HTTP_SNS_ORP[] PROGMEM = "{s}%s " D_ORP "{m}%s " D_UNIT_MILLIVOLT "{e}";
const char HTTP_SNS_EC[] PROGMEM = "{s}%s " D_EC "{m}%s " D_UNIT_MICROSIEMENS_PER_CM "{e}";
const char HTTP_SNS_O2[] PROGMEM = "{s}%s " D_O2 "{m}%s " D_UNIT_PERCENT "{e}";
const char S_MAIN_MENU[] PROGMEM = D_MAIN_MENU;
const char S_CONFIGURATION[] PROGMEM = D_CONFIGURATION;

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "неколкократно натискане"
#define D_NOISE "Шум"
#define D_NONE "Няма"
#define D_O2 "Oxygen"
#define D_OFF "Изкл."
#define D_OFFLINE "Офлайн"
#define D_OK "Ок"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "několikeré-stisknutí"
#define D_NOISE "Hluk"
#define D_NONE "Žádný"
#define D_O2 "Oxygen"
#define D_OFF "Vyp."
#define D_OFFLINE "Offline" // Don't translate, LWT message! Nepředkládat, LWT zpráva!
#define D_OK "OK"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "Mehrfachdruck"
#define D_NOISE "Lautstärke"
#define D_NONE "keine"
#define D_O2 "Oxygen"
#define D_OFF "aus"
#define D_OFFLINE "Offline"
#define D_OK "OK"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "ανίχνευση για πολλαπλά πατήματα"
#define D_NOISE "Θόρυβος"
#define D_NONE "Κανένα"
#define D_O2 "Oxygen"
#define D_OFF "Off"
#define D_OFFLINE "Offline"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-press"
#define D_NOISE "Noise"
#define D_NONE "None"
#define D_O2 "Oxygen"
#define D_OFF "Off"
#define D_OFFLINE "Offline"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-press"
#define D_NOISE "Ruido"
#define D_NONE "Ninguno"
#define D_O2 "Oxygen"
#define D_OFF "Apagado"
#define D_OFFLINE "Offline"
#define D_OK "Ok"

View File

@ -121,6 +121,7 @@
#define D_MULTI_PRESS "multi-pression"
#define D_NOISE "Bruit"
#define D_NONE "Aucun"
#define D_O2 "Oxygen"
#define D_OFF "Arrêt"
#define D_OFFLINE "Déconnecté"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "לחיצה מרובה"
#define D_NOISE "רעש"
#define D_NONE "כלום"
#define D_O2 "Oxygen"
#define D_OFF "כבוי"
#define D_OFFLINE "מנותק"
#define D_OK "אוקיי"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "több lenyomás"
#define D_NOISE "Zaj"
#define D_NONE "nincs"
#define D_O2 "Oxygen"
#define D_OFF "Ki"
#define D_OFFLINE "Offline"
#define D_OK "OK"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-pressione"
#define D_NOISE "Rumore"
#define D_NONE "Nessuno"
#define D_O2 "Oxygen"
#define D_OFF "OFF"
#define D_OFFLINE "Offline"
#define D_OK "OK"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-press"
#define D_NOISE "소음"
#define D_NONE "없음"
#define D_O2 "Oxygen"
#define D_OFF "꺼짐"
#define D_OFFLINE "오프라인"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "meervoudig"
#define D_NOISE "Lawaai"
#define D_NONE "Geen"
#define D_O2 "Oxygen"
#define D_OFF "Uit"
#define D_OFFLINE "Offline"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "Wielokrotne naciśnięcie"
#define D_NOISE "Szum"
#define D_NONE "Brak"
#define D_O2 "Oxygen"
#define D_OFF "Wyłączony"
#define D_OFFLINE "Nieaktywny"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-pressão"
#define D_NOISE "Ruído"
#define D_NONE "Nenhum"
#define D_O2 "Oxygen"
#define D_OFF "Desligado"
#define D_OFFLINE "Desconectado"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-pressão"
#define D_NOISE "Ruído"
#define D_NONE "Nenhum"
#define D_O2 "Oxygen"
#define D_OFF "Off"
#define D_OFFLINE "Desconetado"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "selectare multiplă"
#define D_NOISE "Zgomot"
#define D_NONE "Lipsă"
#define D_O2 "Oxygen"
#define D_OFF "Închis"
#define D_OFFLINE "Offline"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "многократное нажатие"
#define D_NOISE "Шум"
#define D_NONE "Нет"
#define D_O2 "Oxygen"
#define D_OFF "Выкл"
#define D_OFFLINE "Офф-лайн"
#define D_OK "Ок"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-stlačenie"
#define D_NOISE "Hluk"
#define D_NONE "Žiadny"
#define D_O2 "Oxygen"
#define D_OFF "Vyp."
#define D_OFFLINE "Neaktívny"
#define D_OK "OK"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "fler tryck"
#define D_NOISE "Oväsen"
#define D_NONE "Ingen"
#define D_O2 "Oxygen"
#define D_OFF "Av"
#define D_OFFLINE "Off-line"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "multi-press"
#define D_NOISE "Noise"
#define D_NONE "None"
#define D_O2 "Oxygen"
#define D_OFF "Off"
#define D_OFFLINE "Çevirimdışı"
#define D_OK "Tamam"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "Багаторазове натискання"
#define D_NOISE "Шум"
#define D_NONE "Нічого"
#define D_O2 "Oxygen"
#define D_OFF "Вимкнено"
#define D_OFFLINE "Неактивний"
#define D_OK "Ок"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "bấm nhiều lần"
#define D_NOISE "Nhiễu"
#define D_NONE "Không"
#define D_O2 "Oxygen"
#define D_OFF "Tắt"
#define D_OFFLINE "Ngoại tuyến"
#define D_OK "Ok"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "多次按键"
#define D_NOISE "嘈杂"
#define D_NONE "无"
#define D_O2 "Oxygen"
#define D_OFF "关"
#define D_OFFLINE "离线"
#define D_OK "好"

View File

@ -125,6 +125,7 @@
#define D_MULTI_PRESS "多重點擊"
#define D_NOISE "雜訊"
#define D_NONE "無"
#define D_O2 "Oxygen"
#define D_OFF "關閉"
#define D_OFFLINE "離線"
#define D_OK "好"

View File

@ -568,6 +568,7 @@
// #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 (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
// #define USE_EZOO2 // [I2cDriver55] Enable support for EZO's O2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 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

@ -133,6 +133,7 @@
//#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 (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
//#define USE_EZOO2 // [I2cDriver55] Enable support for EZO's O2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
#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)

View File

@ -18,7 +18,7 @@
*/
#ifdef USE_I2C
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC) || defined(USE_EZOCO2)
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC) || defined(USE_EZOCO2) || defined(USE_EZOO2)
#define USE_EZO
#endif
#if defined(USE_EZO)

60
tasmota/xsns_78_ezoo2.ino Normal file
View File

@ -0,0 +1,60 @@
/*
xsns_78_ezoo2.ino - EZO O2 I2C O2 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_EZOO2
#define EZO_O2_READ_LATENCY 900
struct EZOO2 : public EZOStruct {
EZOO2(uint32_t addr) : EZOStruct(addr), O2(0) {}
virtual void ProcessMeasurement(void)
{
char data[D_EZO_MAX_BUF];
EZOStruct::ProcessMeasurement(data, sizeof(data), EZO_O2_READ_LATENCY);
O2 = CharToFloat(data);
}
virtual void Show(bool json, const char *name)
{
char str[8];
dtostrfd(O2, 2, str);
if (json) {
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_O2 "\":%d}" ), name, str);
}
#ifdef USE_WEBSERVER
else {
WSContentSend_PD(HTTP_SNS_O2, name, str);
#endif // USE_WEBSERVER
}
}
static const char id[] PROGMEM;
private:
float O2;
};
const char EZOO2::id[] PROGMEM = "O2";
#endif // USE_EZOO2
#endif // USE_I2C

View File

@ -49,29 +49,51 @@ enum {
// Creates a complex preprocessor macro to fetch a specified class OR EZOStruct if it wasn't defined
template <class T, class = void> struct IsComplete : std::false_type {};
template <class T> struct IsComplete< T, decltype(void(sizeof(T))) > : std::true_type {};
#define GET_EZO_CLASS(CLASS) std::conditional<IsComplete<CLASS>::value, CLASS, EZOStruct>::type
// The order of the EZO devices must map with the enum declared above
const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
EZOStruct::id, // "DO"
GET_EZO_CLASS(EZOORP)::id,
GET_EZO_CLASS(EZOPH)::id,
GET_EZO_CLASS(EZOEC)::id,
#ifdef USE_EZOORP
EZOORP::id,
#else
EZOStruct::id,
GET_EZO_CLASS(EZORTD)::id,
#endif
#ifdef USE_EZOPH
EZOPH::id,
#else
EZOStruct::id,
#endif
#ifdef USE_EZOEC
EZOEC::id,
#else
EZOStruct::id,
#endif
EZOStruct::id,
#ifdef USE_EZORTD
EZORTD::id,
#else
EZOStruct::id,
#endif
EZOStruct::id, // "PMP"
EZOStruct::id, // "FLO"
GET_EZO_CLASS(EZOCO2)::id,
#ifdef USE_EZOCO2
EZOCO2::id,
#else
EZOStruct::id,
#endif
EZOStruct::id, // "PRS"
EZOStruct::id,
EZOStruct::id, // "O2"
#ifdef USE_EZOO2
EZOO2::id,
#else
EZOStruct::id,
#endif
EZOStruct::id,
EZOStruct::id,
GET_EZO_CLASS(EZOHUM)::id,
#ifdef USE_EZOHUM
EZOHUM::id,
#else
EZOStruct::id,
#endif
EZOStruct::id, // "RGB"
};
@ -219,11 +241,13 @@ private:
#ifdef USE_EZOCO2
CREATE_EZO_CLASS(CO2)
#endif
#ifdef USE_EZOO2
CREATE_EZO_CLASS(O2)
#endif
#ifdef USE_EZOHUM
CREATE_EZO_CLASS(HUM)
#endif
}
count++;
}
}