mirror of https://github.com/arendst/Tasmota.git
Merge pull request #9659 from tichris0/development
Add support for EZO PRS
This commit is contained in:
commit
8cc11c89ae
|
@ -84,3 +84,4 @@ Index | Define | Driver | Device | Address(es) | Description
|
|||
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
|
||||
55 | USE_EZOPRS | xsns_78 | EZOPRS | 0x61 - 0x70 | Pressure sensor
|
||||
|
|
|
@ -569,6 +569,7 @@
|
|||
// #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_EZOPRS // [I2cDriver55] Enable support for EZO's PRS sensor (+0k7 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
|
||||
|
|
|
@ -726,6 +726,14 @@ float ConvertPressure(float p)
|
|||
return result;
|
||||
}
|
||||
|
||||
float ConvertPressureForSeaLevel(float pressure)
|
||||
{
|
||||
if (pressure == 0.0f)
|
||||
return pressure;
|
||||
|
||||
return ConvertPressure((pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0f), 5.255f)) - 21.6f);
|
||||
}
|
||||
|
||||
String PressureUnit(void)
|
||||
{
|
||||
return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE);
|
||||
|
|
|
@ -134,6 +134,7 @@
|
|||
//#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_EZOPRS // [I2cDriver55] Enable support for EZO's PRS sensor (+0k7 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)
|
||||
|
|
|
@ -517,11 +517,7 @@ void BmpShow(bool json)
|
|||
{
|
||||
for (uint32_t bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
|
||||
if (bmp_sensors[bmp_idx].bmp_type) {
|
||||
float bmp_sealevel = 0.0;
|
||||
if (bmp_sensors[bmp_idx].bmp_pressure != 0.0) {
|
||||
bmp_sealevel = (bmp_sensors[bmp_idx].bmp_pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0), 5.255)) - 21.6;
|
||||
bmp_sealevel = ConvertPressure(bmp_sealevel);
|
||||
}
|
||||
float bmp_sealevel = ConvertPressureForSeaLevel(bmp_sensors[bmp_idx].bmp_pressure);
|
||||
float bmp_temperature = ConvertTemp(bmp_sensors[bmp_idx].bmp_temperature);
|
||||
float bmp_pressure = ConvertPressure(bmp_sensors[bmp_idx].bmp_pressure);
|
||||
|
||||
|
|
|
@ -105,11 +105,7 @@ void HP303B_Show(bool json) {
|
|||
snprintf_P(sensor_name, sizeof(sensor_name), PSTR("%s%c%02X"), sensor_name, IndexSeparator(), hp303b_sensor[i].address); // HP303B-76, HP303B-77
|
||||
}
|
||||
|
||||
float sealevel = 0.0;
|
||||
if (hp303b_sensor[i].pressure != 0.0) {
|
||||
sealevel = (hp303b_sensor[i].pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0), 5.255)) - 21.6;
|
||||
sealevel = ConvertPressure(sealevel);
|
||||
}
|
||||
float sealevel = ConvertPressureForSeaLevel(hp303b_sensor[i].pressure);
|
||||
|
||||
char str_temperature[33];
|
||||
dtostrfd(hp303b_sensor[i].temperature, Settings.flag2.temperature_resolution, str_temperature);
|
||||
|
|
|
@ -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) || defined(USE_EZOO2)
|
||||
#if defined(USE_EZOPH) || defined(USE_EZOORP) || defined(USE_EZORTD) || defined(USE_EZOHUM) || defined(USE_EZOEC) || defined(USE_EZOCO2) || defined(USE_EZOO2) || defined(USE_EZOPRS)
|
||||
#define USE_EZO
|
||||
#endif
|
||||
#if defined(USE_EZO)
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
xsns_78_ezoprs.ino - EZO PRS I2C PRS 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_EZOPRS
|
||||
|
||||
#define EZO_PRS_READ_LATENCY 900
|
||||
|
||||
struct EZOPRS : public EZOStruct {
|
||||
EZOPRS(uint32_t addr) : EZOStruct(addr), pressure(NAN) {}
|
||||
|
||||
virtual void ProcessMeasurement(void)
|
||||
{
|
||||
char data[D_EZO_MAX_BUF];
|
||||
|
||||
EZOStruct::ProcessMeasurement(data, sizeof(data), EZO_PRS_READ_LATENCY);
|
||||
pressure = CharToFloat(data) * 68.9476f; // Convert to hPa
|
||||
}
|
||||
|
||||
virtual void Show(bool json, const char *name)
|
||||
{
|
||||
char str[33];
|
||||
char sealevelstr[33];
|
||||
dtostrfd(ConvertPressure(pressure), Settings.flag2.pressure_resolution, str);
|
||||
dtostrfd(ConvertPressureForSeaLevel(pressure), Settings.flag2.pressure_resolution, sealevelstr);
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_PRESSURE "\":%s"), name, str);
|
||||
if (Settings.altitude != 0) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_PRESSUREATSEALEVEL "\":%s"), sealevelstr);
|
||||
}
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
else {
|
||||
WSContentSend_PD(HTTP_SNS_PRESSURE, name, str, PressureUnit().c_str());
|
||||
if (Settings.altitude != 0) {
|
||||
WSContentSend_PD(HTTP_SNS_SEAPRESSURE, name, sealevelstr, PressureUnit().c_str());
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
||||
static const char id[] PROGMEM;
|
||||
|
||||
private:
|
||||
float pressure;
|
||||
};
|
||||
|
||||
const char EZOPRS::id[] PROGMEM = "PRS";
|
||||
|
||||
#endif // USE_EZOPRS
|
||||
#endif // USE_I2C
|
|
@ -80,7 +80,11 @@ const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
|||
#else
|
||||
EZOStruct::id,
|
||||
#endif
|
||||
EZOStruct::id, // "PRS"
|
||||
#ifdef USE_EZOPRS
|
||||
EZOPRS::id,
|
||||
#else
|
||||
EZOStruct::id,
|
||||
#endif
|
||||
EZOStruct::id,
|
||||
#ifdef USE_EZOO2
|
||||
EZOO2::id,
|
||||
|
@ -241,6 +245,9 @@ private:
|
|||
#ifdef USE_EZOCO2
|
||||
CREATE_EZO_CLASS(CO2)
|
||||
#endif
|
||||
#ifdef USE_EZOPRS
|
||||
CREATE_EZO_CLASS(PRS)
|
||||
#endif
|
||||
#ifdef USE_EZOO2
|
||||
CREATE_EZO_CLASS(O2)
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue