Add support for HDC1080

Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888)
This commit is contained in:
Theo Arends 2020-03-14 12:43:02 +01:00
parent af1e2f73a5
commit 5235ad1757
7 changed files with 35 additions and 33 deletions

View File

@ -117,3 +117,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders by Jon Little (#7814)
- Add support for Romanian language translations by Augustin Marti
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
- Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888)

View File

@ -3,6 +3,7 @@
### 8.1.0.11 20200313
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
- Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888)
### 8.1.0.10 20200227

View File

@ -494,10 +494,9 @@
// #define USE_DS1624 // [I2cDriver42] Enable DS1624, DS1621 temperature sensor (I2C addresses 0x48 - 0x4F) (+1k2 code)
// #define USE_AHT1x // [I2cDriver43] Enable AHT10/15 humidity and temperature sensor (I2C address 0x38) (+0k8 code)
// #define USE_WEMOS_MOTOR_V1 // [I2cDriver44] Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code)
// #define USE_HDC1080 // [I2cDriver92] Enable HDC1080 temperature/humidity sensor
// #define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30
// #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency
// #define USE_HDC1080 // [I2cDriver45] Enable HDC1080 temperature/humidity sensor (I2C address 0x40) (+1k5 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

@ -323,6 +323,7 @@ void GetFeatures(void)
#ifdef USE_TM1638
feature_sns1 |= 0x80000000; // xsns_28_tm1638.ino
#endif
/*********************************************************************************************/
feature_sns2 = 0x00000000;
@ -538,7 +539,9 @@ void GetFeatures(void)
#ifdef USE_SONOFF_D1
feature6 |= 0x00000004; // xdrv_37_sonoff_d1.ino
#endif
// feature6 |= 0x00000008;
#ifdef USE_HDC1080
feature6 |= 0x00000008; // xsns_65_hdc1080.ino
#endif
// feature6 |= 0x00000010;
// feature6 |= 0x00000020;

View File

@ -182,12 +182,10 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack
#define USE_DHT12 // Add I2C code for DHT12 temperature and humidity sensor (+0k7 code)
#define USE_DS1624 // Add I2C code for DS1624, DS1621 sensor
//#define USE_AHT1x // Enable AHT10/15 humidity and temperature sensor (I2C address 0x38) (+0k8 code)
//#define USE_HDC1080 // Enable HDC1080 temperature/humidity sensor
#define USE_WEMOS_MOTOR_V1 // Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code)
#define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30
#define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency
//#define USE_HDC1080 // Enable HDC1080 temperature/humidity sensor
#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

@ -1,5 +1,5 @@
/*
xsns_92_hdc1080.ino - Texas Instruments HDC1080 temperature and humidity sensor support for Tasmota
xsns_65_hdc1080.ino - Texas Instruments HDC1080 temperature and humidity sensor support for Tasmota
Copyright (C) 2020 Luis Teixeira
@ -79,7 +79,7 @@ uint32_t hdc_next_read;
/**
* Reads the device ID register.
*
*
*/
uint16_t HdcReadDeviceId(void) {
return I2cRead16(HDC1080_ADDR, HDC_REG_DEV_ID);
@ -87,7 +87,7 @@ uint16_t HdcReadDeviceId(void) {
/**
* Reads the manufacturer ID register.
*
*
*/
uint16_t HdcReadManufacturerId(void) {
return I2cRead16(HDC1080_ADDR, HDC_REG_MAN_ID);
@ -102,13 +102,13 @@ void HdcConfig(uint16_t config) {
/**
* Performs a soft reset on the device.
*
*
* RST = 1 -> software reset
*
*
*/
void HdcReset(void) {
uint16_t current = I2cRead16(HDC1080_ADDR, HDC_REG_CONFIG);
// bit 15 of the configuration register contains the RST flag
// so we set it to 1:
@ -120,13 +120,13 @@ void HdcReset(void) {
}
/**
* Performs the write portion of the HDC1080 sensor transaction. This
* Performs the write portion of the HDC1080 sensor transaction. This
* action of writing to a register signals the beginning of the operation
* (e.g. data acquisition).
*
*
* addr: the address of the I2C device we are talking to.
* reg: the register where we are writing to.
*
*
* returns: 0 if the transmission was successfully completed, != 0 otherwise.
*/
int8_t HdcTransactionOpen(uint8_t addr, uint8_t reg) {
@ -137,11 +137,11 @@ int8_t HdcTransactionOpen(uint8_t addr, uint8_t reg) {
/**
* Performs the read portion of the HDC1080 sensor transaction.
*
*
* addr: the address of the I2C device we are talking to.
* reg_data: the pointer to the memory location where we will place the bytes that were read from the device
* len: the number of bytes we expect to read
*
*
* returns: if the read operation was successful. != 0 otherwise.
*/
int8_t HdcTransactionClose(uint8_t addr, uint8_t *reg_data, uint16_t len) {
@ -159,7 +159,7 @@ int8_t HdcTransactionClose(uint8_t addr, uint8_t *reg_data, uint16_t len) {
/**
* The various initialization steps for this sensor.
*
*
*/
void HdcInit(void) {
HdcReset();
@ -168,7 +168,7 @@ void HdcInit(void) {
/**
* Triggers the single transaction read of the T/RH sensor.
*
*
*/
bool HdcTriggerRead(void) {
int8_t status = HdcTransactionOpen(HDC1080_ADDR, HDC_REG_TEMP);
@ -190,9 +190,9 @@ bool HdcTriggerRead(void) {
* Performs a temperature and humidity measurement, and calls
* the conversion function providing the results in the correct
* unit according to the device settings.
*
*
* returns: false if something failed during the read process.
*
*
*/
bool HdcRead(void) {
int8_t status = 0;
@ -233,14 +233,14 @@ bool HdcRead(void) {
/**
* Performs the detection of the HTC1080 sensor.
*
*
*/
void HdcDetect(void) {
if (I2cActive(HDC1080_ADDR)) {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR);
if (I2cActive(HDC1080_ADDR)) {
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR);
return;
return;
}
hdc_manufacturer_id = HdcReadManufacturerId();
@ -257,7 +257,7 @@ void HdcDetect(void) {
/**
* As the name suggests, this function is called every second
* for performing driver related logic.
*
*
*/
void HdcEverySecond(void) {
if (uptime &1) { // Every 2 seconds
@ -268,9 +268,9 @@ void HdcEverySecond(void) {
}
/**
* Tasmota boilerplate for presenting the sensor data in the web UI, JSON for
* Tasmota boilerplate for presenting the sensor data in the web UI, JSON for
* the MQTT messages, and so on.
*
*
*/
void HdcShow(bool json) {
if (hdc_valid) {
@ -308,10 +308,10 @@ void HdcShow(bool json) {
bool Xsns65(uint8_t function)
{
if (!I2cEnabled(XI2C_45)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device."));
if (!I2cEnabled(XI2C_45)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device."));
return false;
return false;
}
bool result = false;

View File

@ -198,7 +198,7 @@ a_features = [[
"USE_NRF24","USE_MIBLE","USE_HM10","USE_LE01MR",
"USE_AHT1x","USE_WEMOS_MOTOR_V1","USE_DEVICE_GROUPS","USE_PWM_DIMMER"
],[
"USE_KEELOQ","USE_HRXL","USE_SONOFF_D1","",
"USE_KEELOQ","USE_HRXL","USE_SONOFF_D1","USE_HDC1080",
"","","","",
"","","","",
"","","","",
@ -239,7 +239,7 @@ else:
obj = json.load(fp)
def StartDecode():
print ("\n*** decode-status.py v20200305 by Theo Arends and Jacek Ziolkowski ***")
print ("\n*** decode-status.py v20200314 by Theo Arends and Jacek Ziolkowski ***")
# print("Decoding\n{}".format(obj))