mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Add support for Honeywell I2C HIH series
Add support for Honeywell I2C HIH series Humidity and Temperetaure sensor (#6808)
This commit is contained in:
parent
b4e3b9703c
commit
6395db9963
@ -1,6 +1,7 @@
|
|||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* 7.0.0.2 20191102
|
* 7.0.0.2 20191102
|
||||||
* Add command WebColor19 to control color of Module and Name (#6811)
|
* Add command WebColor19 to control color of Module and Name (#6811)
|
||||||
|
* Add support for Honeywell I2C HIH series Humidity and Temperetaure sensor (#6808)
|
||||||
*
|
*
|
||||||
* 7.0.0.1 20191027
|
* 7.0.0.1 20191027
|
||||||
* Remove references to versions before 6.0
|
* Remove references to versions before 6.0
|
||||||
|
@ -402,6 +402,7 @@
|
|||||||
// #define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
// #define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
||||||
// #define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
// #define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
||||||
// #define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code)
|
// #define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code)
|
||||||
|
// #define USE_HIH6 // Enable Honeywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6)
|
||||||
|
|
||||||
// #define USE_DISPLAY // Add I2C Display Support (+2k 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
|
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0
|
||||||
|
@ -480,7 +480,9 @@ void GetFeatures(void)
|
|||||||
#ifdef USE_ARDUINO_SLAVE
|
#ifdef USE_ARDUINO_SLAVE
|
||||||
feature5 |= 0x00010000; // xdrv_31_arduino_slave.ino
|
feature5 |= 0x00010000; // xdrv_31_arduino_slave.ino
|
||||||
#endif
|
#endif
|
||||||
// feature5 |= 0x00020000;
|
#ifdef USE_HIH6
|
||||||
|
feature5 |= 0x00020000; // xsns_55_hih_series.ino
|
||||||
|
#endif
|
||||||
// feature5 |= 0x00040000;
|
// feature5 |= 0x00040000;
|
||||||
// feature5 |= 0x00080000;
|
// feature5 |= 0x00080000;
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||||||
//#define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
//#define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
||||||
//#define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
//#define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
||||||
//#define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code)
|
//#define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code)
|
||||||
|
//#define USE_HIH6 // Enable Honywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6)
|
||||||
|
|
||||||
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k 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)
|
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
||||||
|
162
tasmota/xsns_55_hih_series.ino
Normal file
162
tasmota/xsns_55_hih_series.ino
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
xsns_55_hih_series.ino - Honeywell HIH series temperature and humidity sensor support for Tasmota
|
||||||
|
|
||||||
|
Copyright (C) 2019 Theo Arends
|
||||||
|
|
||||||
|
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_HIH6
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* HIH6130 - Temperature and Humidity
|
||||||
|
*
|
||||||
|
* https://sensing.honeywell.com/HIH6130-021-001-humidity-sensors
|
||||||
|
* https://sensing.honeywell.com/i2c-comms-humidicon-tn-009061-2-en-final-07jun12.pdf
|
||||||
|
* https://github.com/ControlEverythingCommunity/HIH6130/blob/master/Arduino/HIH6130.ino
|
||||||
|
*
|
||||||
|
* I2C Address: 0x27
|
||||||
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
#define XSNS_55 55
|
||||||
|
|
||||||
|
#define HIH6_ADDR 0x27
|
||||||
|
|
||||||
|
struct HIH6 {
|
||||||
|
float temperature = 0;
|
||||||
|
float humidity = 0;
|
||||||
|
uint8_t valid = 0;
|
||||||
|
uint8_t type = 0;
|
||||||
|
char types[4] = "HIH";
|
||||||
|
} Hih6;
|
||||||
|
|
||||||
|
bool Hih6Read(void)
|
||||||
|
{
|
||||||
|
Wire.beginTransmission(HIH6_ADDR);
|
||||||
|
Wire.write(0x00); // Select data register
|
||||||
|
if (Wire.endTransmission() != 0) { return false; } // In case of error
|
||||||
|
|
||||||
|
// delay(40); // Wait for Valid data or use Stale data
|
||||||
|
|
||||||
|
uint8_t data[4];
|
||||||
|
Wire.requestFrom(HIH6_ADDR, 4);
|
||||||
|
if (4 == Wire.available()) {
|
||||||
|
data[0] = Wire.read(); // Status and Humidity msb
|
||||||
|
data[1] = Wire.read(); // Humidity lsb
|
||||||
|
data[2] = Wire.read(); // Temp msb
|
||||||
|
data[3] = Wire.read(); // Temp lsb
|
||||||
|
} else { return false; }
|
||||||
|
|
||||||
|
// uint8_t status = data[0] >> 6; // 0 = Valid data, 1 = Stale data, 2 = Command mode, 3 = Not used
|
||||||
|
|
||||||
|
// Convert the data to 14-bits
|
||||||
|
int temp = ((data[2] * 256) + (data[3] & 0xFC)) / 4;
|
||||||
|
Hih6.temperature = ConvertTemp((temp / 16384.0) * 165.0 - 40.0);
|
||||||
|
Hih6.humidity = ConvertHumidity(((((data[0] & 0x3F) * 256) + data[1]) * 100.0) / 16383.0);
|
||||||
|
|
||||||
|
Hih6.valid = SENSOR_MAX_MISS;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************************************/
|
||||||
|
|
||||||
|
void Hih6Detect(void)
|
||||||
|
{
|
||||||
|
if (Hih6.type) { return; }
|
||||||
|
|
||||||
|
Hih6.type = Hih6Read();
|
||||||
|
if (Hih6.type) {
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, Hih6.types, HIH6_ADDR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hih6EverySecond(void)
|
||||||
|
{
|
||||||
|
if ((100 - XSNS_55) == (uptime %100)) {
|
||||||
|
// 1mS
|
||||||
|
Hih6Detect();
|
||||||
|
}
|
||||||
|
else if (uptime &1) {
|
||||||
|
// HIH6130: 30mS
|
||||||
|
if (Hih6.type) {
|
||||||
|
if (!Hih6Read()) {
|
||||||
|
AddLogMissed(Hih6.types, Hih6.valid);
|
||||||
|
// if (!Hih6.valid) { Hih6.type = 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hih6Show(bool json)
|
||||||
|
{
|
||||||
|
if (Hih6.valid) {
|
||||||
|
char temperature[33];
|
||||||
|
dtostrfd(Hih6.temperature, Settings.flag2.temperature_resolution, temperature);
|
||||||
|
char humidity[33];
|
||||||
|
dtostrfd(Hih6.humidity, Settings.flag2.humidity_resolution, humidity);
|
||||||
|
|
||||||
|
if (json) {
|
||||||
|
ResponseAppend_P(JSON_SNS_TEMPHUM, Hih6.types, temperature, humidity);
|
||||||
|
#ifdef USE_DOMOTICZ
|
||||||
|
if (0 == tele_period) {
|
||||||
|
DomoticzTempHumSensor(temperature, humidity);
|
||||||
|
}
|
||||||
|
#endif // USE_DOMOTICZ
|
||||||
|
#ifdef USE_KNX
|
||||||
|
if (0 == tele_period) {
|
||||||
|
KnxSensor(KNX_TEMPERATURE, Hih6.temperature);
|
||||||
|
KnxSensor(KNX_HUMIDITY, Hih6.humidity);
|
||||||
|
}
|
||||||
|
#endif // USE_KNX
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
} else {
|
||||||
|
WSContentSend_PD(HTTP_SNS_TEMP, Hih6.types, temperature, TempUnit());
|
||||||
|
WSContentSend_PD(HTTP_SNS_HUM, Hih6.types, humidity);
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* Interface
|
||||||
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
bool Xsns55(uint8_t function)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
if (i2c_flg) {
|
||||||
|
switch (function) {
|
||||||
|
case FUNC_EVERY_SECOND:
|
||||||
|
Hih6EverySecond();
|
||||||
|
break;
|
||||||
|
case FUNC_JSON_APPEND:
|
||||||
|
Hih6Show(1);
|
||||||
|
break;
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
case FUNC_WEB_SENSOR:
|
||||||
|
Hih6Show(0);
|
||||||
|
break;
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
case FUNC_INIT:
|
||||||
|
Hih6Detect();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_HIH6
|
||||||
|
#endif // USE_I2C
|
||||||
|
|
@ -185,7 +185,7 @@ a_features = [[
|
|||||||
"USE_INA226","USE_A4988_STEPPER","USE_DDS2382","USE_SM2135",
|
"USE_INA226","USE_A4988_STEPPER","USE_DDS2382","USE_SM2135",
|
||||||
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","USE_DEEPSLEEP",
|
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","USE_DEEPSLEEP",
|
||||||
"USE_SONOFF_SC","USE_SONOFF_RF","USE_SONOFF_L1","USE_EXS_DIMMER",
|
"USE_SONOFF_SC","USE_SONOFF_RF","USE_SONOFF_L1","USE_EXS_DIMMER",
|
||||||
"USE_ARDUINO_SLAVE","","","",
|
"USE_ARDUINO_SLAVE","USE_HIH6","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","",""
|
"","","",""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user