From b373342a2a03c26033dfae3f2bd2294079cdb6a5 Mon Sep 17 00:00:00 2001 From: Luc Boudreau Date: Wed, 10 Nov 2021 13:11:40 -0500 Subject: [PATCH 1/6] Add driver for Texas Instruments HDC2010 --- I2CDEVICES.md | 1 + tasmota/my_user_config.h | 1 + tasmota/tasmota_configurations.h | 1 + tasmota/xsns_94_hdc2010.ino | 215 +++++++++++++++++++++++++++++++ 4 files changed, 218 insertions(+) create mode 100755 tasmota/xsns_94_hdc2010.ino diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 07094954b..65b38dae9 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -97,3 +97,4 @@ Index | Define | Driver | Device | Address(es) | Description 61 | USE_T67XX | xsns_89 | T67XX | 0x15 | CO2 sensor 62 | USE_SCD40 | xsns_92 | SCD40 | 0x62 | CO2 sensor Sensirion SCD40/SCD41 63 | USE_HM330X | xsns_93 | HM330X | 0x40 | Particule sensor + 64 | USE_HDC2010 | xsns_94 | HDC2010 | 0x40 | Temperature and Humidity sensor diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 2640d3de5..6f708f58b 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -658,6 +658,7 @@ // #define USE_AM2320 // [I2cDriver60] Enable AM2320 temperature and humidity Sensor (I2C address 0x5C) (+1k code) // #define USE_T67XX // [I2cDriver61] Enable Telaire T67XX CO2 sensor (I2C address 0x15) (+1k3 code) // #define USE_HM330X // [I2cDriver63] Enable support for SeedStudio Grove Particule sensor (I2C address 0x40) (+1k5 code) +// #define USE_HDC2010 // [I2cDriver64] Enable HDC2010 temperature/humidity sensor (I2C address 0x40) (+1k5 code) // #define HM330X_DEFAULT_ADDRESS 0x40 // Option: change default I2C address for HM330X used in SeedSTudio Particucle Sensor // #define HM330X_WARMUP_DELAY 30 // Option: change warmup delay during which data are not read from sensor after a power up // #define HM330X_HIDE_OUT_OF_DATE false // Option: change to true to hide data from web GUI and SENSOR while sensor is asleep diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 59810fccd..f2fe27392 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -148,6 +148,7 @@ //#define USE_BM8563 // [I2cDriver59] Enable BM8563 RTC - found in M5Stack - support both I2C buses on ESP32 (I2C address 0x51) (+2k5 code) //#define USE_AM2320 // [I2cDriver60] Enable AM2320 temperature and humidity Sensor (I2C address 0x5C) (+1k code) //#define USE_T67XX // [I2cDriver61] Enable Telaire T67XX CO2 sensor (I2C address 0x15) (+1k3 code) +//#define USE_HDC2010 // [I2cDriver64] Enable HDC2010 temperature/humidity sensor (I2C address 0x40) (+1k5 code) //#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) //#define USE_RC522 // Add support for MFRC522 13.56Mhz Rfid reader (+6k code) diff --git a/tasmota/xsns_94_hdc2010.ino b/tasmota/xsns_94_hdc2010.ino new file mode 100755 index 000000000..edacc2adf --- /dev/null +++ b/tasmota/xsns_94_hdc2010.ino @@ -0,0 +1,215 @@ +/* + xsns_94_hdc2010.ino - Texas Instruments HDC1080 temperature and humidity sensor support for Tasmota + + Copyright (C) 2021 Luc Boudreau + + 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_HDC2010 + +/*********************************************************************************************\ + * HDC2010 - Temperature and Humidity sensor + * + * Source: Luc Boudreau + * Other sources: Luis Teixeira from the HDC1080 code (GPL3+) + * sSense arduino library (Public Domain) + * + * I2C Address: 0x40 +\*********************************************************************************************/ + +#define XSNS_94 94 +#define XI2C_64 64 // See I2CDEVICES.md + +#define HDC2010_ADDR 0x40 + +// Registers: + +#define HDC2010_REG_TEMP_LSB 0x00 // Temperature register LSB +#define HDC2010_REG_TEMP_MSB 0x01 // Temperature register MSB +#define HDC2010_REG_RH_LSB 0x02 // Humidity register LSB +#define HDC2010_REG_RH_MSB 0x03 // Humidity register MSB +#define HDC2010_REG_INTR_DRDY 0x04 // Interrupt / Data Ready register +#define HDC2010_REG_CONFIG 0x0F // Configuration register +#define HDC2010_REG_RESET 0x0E // Reset register +#define HDC2010_REG_MAN_LSB 0xFC // Manufacturer LSB +#define HDC2010_REG_MAN_MSB 0xFD // Manufacturer MSB +#define HDC2010_REG_DEV_LSB 0xFE // Device ID LSB +#define HDC2010_REG_DEV_MSB 0xFF // Device ID MSB + +// Note: These are bit flipped. Actual IDs need to shift byte 0 and 1 +#define HDC2010_MAN_ID 0x4954 // Manufacturer ID (Texas Instruments) +#define HDC2010_DEV_ID 0xD007 // Device ID (valid for the HDC2010) + +#define HDC2010_CONV_TIME 50 + +struct HDC2010 { + const char* hdc_type_name = "HDC2010"; + uint16_t hdc_manufacturer_id = 0; + uint16_t hdc_device_id = 0; + float hdc_temperature = 0.0; + float hdc_humidity = 0.0; + uint8_t hdc_valid = 0; +} HDC2010; + +/** + * Reads the device ID register. + */ +uint16_t Hdc2010ReadDeviceId(void) { + return I2cRead16(HDC2010_ADDR, HDC2010_REG_DEV_LSB); +} + +/** + * Reads the manufacturer ID register. + */ +uint16_t Hdc2010ReadManufacturerId(void) { + return I2cRead16(HDC2010_ADDR, HDC2010_REG_MAN_LSB); +} + +/** + * The various initialization steps for this sensor. + */ +void Hdc2010Init(void) { + Hdc2010Reset(); + Hdc2010SetMeasurementConfig(); + HDC2010.hdc_valid = 1; +} + +/** + * Performs a temp and humidity read + */ +void Hdc2010Read(void) { + uint8_t byte[2]; + uint16_t temp; + uint16_t humidity; + byte[0] = I2cRead8(HDC2010_ADDR, HDC2010_REG_TEMP_LSB); + byte[1] = I2cRead8(HDC2010_ADDR, HDC2010_REG_TEMP_MSB); + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature raw data: 0x%02x 0x%02x"), byte[0], byte[1]); + temp = (unsigned int)(byte[1]) << 8 | (unsigned int) byte[0]; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature shifted data: %d"), temp); + HDC2010.hdc_temperature = (float)(temp) * 165 / 65536 - 40; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature : %f"), hdc_temperature); + + byte[0] = I2cRead8(HDC2010_ADDR, HDC2010_REG_RH_LSB); + byte[1] = I2cRead8(HDC2010_ADDR, HDC2010_REG_RH_MSB); + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: humidity raw data: 0x%02x 0x%02x"), byte[0], byte[1]); + humidity = (unsigned int)byte[1] << 8 | byte[0]; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: humidity shifted data: %d"), humidity); + HDC2010.hdc_humidity = (float)(humidity)/( 65536 )* 100; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: humidity : %f"), hdc_humidity); +} + +/** + * Performs a reset of the sensor (slow oper) + */ +void Hdc2010Reset(void) { + uint8_t current = I2cRead8(HDC2010_ADDR, HDC2010_REG_RESET); + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcReset: current reset registry value = %d"), current); + current |= 0x80; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcReset: new reset registry value = %d"), current); + I2cWrite8(HDC2010_ADDR, HDC2010_REG_RESET, current); + delay(HDC2010_CONV_TIME); +} + +/** + * Detects the sensor + */ +bool Hdc2010Detect(void) { + if (!I2cSetDevice(HDC2010_ADDR)) { return false; } + + HDC2010.hdc_manufacturer_id = Hdc2010ReadManufacturerId(); + HDC2010.hdc_device_id = Hdc2010ReadDeviceId(); + + AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: detected device with manufacturerId = 0x%04X and deviceId = 0x%04X"), HDC2010.hdc_manufacturer_id, HDC2010.hdc_device_id); + + if (HDC2010.hdc_device_id == HDC2010_DEV_ID && HDC2010.hdc_manufacturer_id == HDC2010_MAN_ID) { + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: adding device HDC2010")); + Hdc2010Init(); + I2cSetActiveFound(HDC2010_ADDR, HDC2010.hdc_type_name); + return true; + } + return false; +} + +/** + * Shows the sensor in the ui + */ +void Hdc2010Show(bool json) { + if (HDC2010.hdc_valid) { + TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), HDC2010.hdc_type_name, HDC2010.hdc_temperature, HDC2010.hdc_humidity); + } +} + +/** + * Configures measurement settings + */ +void Hdc2010SetMeasurementConfig() { + uint8_t resetContents = I2cRead8(HDC2010_ADDR, HDC2010_REG_RESET); + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcSetMeasureRate: current reset registry value = %d"), resetContents); + // Measure twice per second + resetContents |= 0x60; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcSetMeasureRate: new reset registry value = %d"), resetContents); + I2cWrite8(HDC2010_ADDR, HDC2010_REG_RESET, resetContents); + + uint8_t configContents = I2cRead8(HDC2010_ADDR, HDC2010_REG_CONFIG); + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcSetMeasureRate: current config registry value = %d"), configContents); + // Measure both temp and humidity + configContents |= 0x01; + //AddLog(LOG_LEVEL_DEBUG, PSTR("HdcSetMeasureRate: new config registry value = %d"), configContents); + I2cWrite8(HDC2010_ADDR, HDC2010_REG_CONFIG, configContents); +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xsns94(uint8_t function) +{ + if (!I2cEnabled(XI2C_64)) { + return false; + } + + bool result = false; + + if (FUNC_INIT == function) { + result = Hdc2010Detect(); + } + else if (HDC2010.hdc_device_id) { + switch (function) { + case FUNC_EVERY_SECOND: + if (HDC2010.hdc_valid) { + Hdc2010Read(); + result = true; + } + break; + case FUNC_JSON_APPEND: + if (HDC2010.hdc_valid) { + Hdc2010Show(1); + } + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + Hdc2010Show(0); + result = true; + break; +#endif // USE_WEBSERVER + } + } + return result; +} + +#endif // USE_HDC2010 +#endif // USE_I2C + From e69522f70b0bfa50aa55eda1d44ca45b25f09fa0 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Wed, 10 Nov 2021 20:58:06 +0100 Subject: [PATCH 2/6] Berry `tasmota.arch()` (#13635) * Berry `tasmota.arch()` * Fix typo --- lib/libesp32/Berry/default/be_tasmotalib.c | 2 + lib/libesp32/Berry/generate/be_const_strtab.h | 1 + .../Berry/generate/be_const_strtab_def.h | 5 +- .../generate/be_fixed_be_class_tasmota.h | 137 +++++++++--------- tasmota/support_esp.ino | 13 ++ tasmota/xdrv_52_3_berry_tasmota.ino | 8 + 6 files changed, 96 insertions(+), 70 deletions(-) diff --git a/lib/libesp32/Berry/default/be_tasmotalib.c b/lib/libesp32/Berry/default/be_tasmotalib.c index a1094079e..dd5c986d8 100644 --- a/lib/libesp32/Berry/default/be_tasmotalib.c +++ b/lib/libesp32/Berry/default/be_tasmotalib.c @@ -12,6 +12,7 @@ extern struct dummy_struct be_tasmota_global_struct; extern struct dummy_struct be_tasmota_settings_struct; extern int l_getFreeHeap(bvm *vm); +extern int l_arch(bvm *vm); extern int l_publish(bvm *vm); extern int l_publish_result(bvm *vm); extern int l_cmd(bvm *vm); @@ -1865,6 +1866,7 @@ class be_class_tasmota (scope: global, name: Tasmota) { kv, closure(kv_closure) get_free_heap, func(l_getFreeHeap) + arch, func(l_arch) publish, func(l_publish) publish_result, func(l_publish_result) _cmd, func(l_cmd) diff --git a/lib/libesp32/Berry/generate/be_const_strtab.h b/lib/libesp32/Berry/generate/be_const_strtab.h index d574c12ed..aaf1a94a3 100644 --- a/lib/libesp32/Berry/generate/be_const_strtab.h +++ b/lib/libesp32/Berry/generate/be_const_strtab.h @@ -293,6 +293,7 @@ extern const bcstring be_const_str_print; extern const bcstring be_const_str_run_deferred; extern const bcstring be_const_str_scan; extern const bcstring be_const_str_settings; +extern const bcstring be_const_str_arch; extern const bcstring be_const_str_open; extern const bcstring be_const_str_cmd; extern const bcstring be_const_str_loop; diff --git a/lib/libesp32/Berry/generate/be_const_strtab_def.h b/lib/libesp32/Berry/generate/be_const_strtab_def.h index b3bac44ab..792cbd7f6 100644 --- a/lib/libesp32/Berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/Berry/generate/be_const_strtab_def.h @@ -293,6 +293,7 @@ be_define_const_str(print, "print", 372738696u, 0, 5, &be_const_str_run_deferred be_define_const_str(run_deferred, "run_deferred", 371594696u, 0, 12, &be_const_str_scan); be_define_const_str(scan, "scan", 3974641896u, 0, 4, &be_const_str_settings); be_define_const_str(settings, "settings", 1745255176u, 0, 8, NULL); +be_define_const_str(arch, "arch", 2952804297u, 0, 4, &be_const_str_open); be_define_const_str(open, "open", 3546203337u, 0, 4, NULL); be_define_const_str(cmd, "cmd", 4136785899u, 0, 3, &be_const_str_loop); be_define_const_str(loop, "loop", 3723446379u, 0, 4, &be_const_str_wire1); @@ -479,7 +480,7 @@ static const bstring* const m_string_table[] = { (const bstring *)&be_const_str_SERIAL_7O2, NULL, (const bstring *)&be_const_str__ptr, - (const bstring *)&be_const_str_open, + (const bstring *)&be_const_str_arch, NULL, (const bstring *)&be_const_str_cmd, (const bstring *)&be_const_str_nil, @@ -506,6 +507,6 @@ static const bstring* const m_string_table[] = { static const struct bconststrtab m_const_string_table = { .size = 160, - .count = 320, + .count = 321, .table = m_string_table }; diff --git a/lib/libesp32/Berry/generate/be_fixed_be_class_tasmota.h b/lib/libesp32/Berry/generate/be_fixed_be_class_tasmota.h index a9f54b4b4..34b9c0a05 100644 --- a/lib/libesp32/Berry/generate/be_fixed_be_class_tasmota.h +++ b/lib/libesp32/Berry/generate/be_fixed_be_class_tasmota.h @@ -1,85 +1,86 @@ #include "be_constobj.h" static be_define_const_map_slots(be_class_tasmota_map) { - { be_const_key(set_light, -1), be_const_closure(set_light_closure) }, - { be_const_key(gc, -1), be_const_closure(gc_closure) }, - { be_const_key(remove_cmd, -1), be_const_closure(remove_cmd_closure) }, - { be_const_key(set_timer, 42), be_const_closure(set_timer_closure) }, - { be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) }, - { be_const_key(set_power, -1), be_const_func(l_setpower) }, - { be_const_key(remove_driver, -1), be_const_closure(remove_driver_closure) }, - { be_const_key(try_rule, -1), be_const_closure(try_rule_closure) }, - { be_const_key(find_op, 58), be_const_closure(find_op_closure) }, - { be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) }, - { be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) }, - { be_const_key(_cb, 3), be_const_var(0) }, - { be_const_key(web_send, -1), be_const_func(l_webSend) }, - { be_const_key(log, 1), be_const_func(l_logInfo) }, - { be_const_key(get_switch, 50), be_const_func(l_getswitch) }, - { be_const_key(_ccmd, 19), be_const_var(1) }, - { be_const_key(eth, -1), be_const_func(l_eth) }, - { be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) }, - { be_const_key(init, 39), be_const_closure(init_closure) }, - { be_const_key(strftime, -1), be_const_func(l_strftime) }, - { be_const_key(kv, -1), be_const_closure(kv_closure) }, { be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) }, - { be_const_key(cmd_res, 67), be_const_var(2) }, - { be_const_key(wire1, 43), be_const_var(3) }, - { be_const_key(get_light, -1), be_const_closure(get_light_closure) }, - { be_const_key(resp_cmnd_error, 62), be_const_func(l_respCmndError) }, - { be_const_key(publish_result, 9), be_const_func(l_publish_result) }, - { be_const_key(gen_cb, -1), be_const_closure(gen_cb_closure) }, - { be_const_key(yield, -1), be_const_func(l_yield) }, - { be_const_key(add_rule, -1), be_const_closure(add_rule_closure) }, - { be_const_key(settings, -1), be_const_var(4) }, - { be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) }, - { be_const_key(resp_cmnd, 31), be_const_func(l_respCmnd) }, - { be_const_key(exec_tele, 68), be_const_closure(exec_tele_closure) }, - { be_const_key(exec_rules, 51), be_const_closure(exec_rules_closure) }, - { be_const_key(load, -1), be_const_closure(load_closure) }, - { be_const_key(remove_rule, 22), be_const_closure(remove_rule_closure) }, - { be_const_key(_rules, 18), be_const_var(5) }, - { be_const_key(publish, -1), be_const_func(l_publish) }, - { be_const_key(get_option, 15), be_const_func(l_getoption) }, - { be_const_key(global, -1), be_const_var(6) }, - { be_const_key(add_driver, 33), be_const_closure(add_driver_closure) }, - { be_const_key(cmd, -1), be_const_closure(cmd_closure) }, + { be_const_key(settings, 70), be_const_var(0) }, + { be_const_key(set_light, -1), be_const_closure(set_light_closure) }, + { be_const_key(gc, 35), be_const_closure(gc_closure) }, { be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) }, - { be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) }, - { be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) }, - { be_const_key(wifi, -1), be_const_func(l_wifi) }, - { be_const_key(time_dump, -1), be_const_func(l_time_dump) }, - { be_const_key(rtc, 24), be_const_func(l_rtc) }, - { be_const_key(cb_dispatch, -1), be_const_closure(cb_dispatch_closure) }, - { be_const_key(_get_cb, -1), be_const_func(l_get_cb) }, - { be_const_key(resp_cmnd_failed, 72), be_const_func(l_respCmndFailed) }, - { be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) }, - { be_const_key(exec_cmd, -1), be_const_closure(exec_cmd_closure) }, - { be_const_key(_cmd, 46), be_const_func(l_cmd) }, - { be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) }, - { be_const_key(time_str, 34), be_const_closure(time_str_closure) }, - { be_const_key(response_append, -1), be_const_func(l_respAppend) }, - { be_const_key(web_send_decimal, 60), be_const_func(l_webSendDecimal) }, - { be_const_key(_drivers, 71), be_const_var(7) }, + { be_const_key(try_rule, -1), be_const_closure(try_rule_closure) }, + { be_const_key(publish, 20), be_const_func(l_publish) }, + { be_const_key(_settings_ptr, 28), be_const_comptr(&Settings) }, + { be_const_key(exec_tele, 36), be_const_closure(exec_tele_closure) }, { be_const_key(delay, -1), be_const_func(l_delay) }, + { be_const_key(_drivers, -1), be_const_var(1) }, + { be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) }, + { be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) }, + { be_const_key(wire2, 64), be_const_var(2) }, + { be_const_key(gen_cb, 56), be_const_closure(gen_cb_closure) }, + { be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) }, + { be_const_key(_timers, 25), be_const_var(3) }, + { be_const_key(kv, -1), be_const_closure(kv_closure) }, + { be_const_key(set_power, -1), be_const_func(l_setpower) }, + { be_const_key(cmd, 38), be_const_closure(cmd_closure) }, + { be_const_key(global, -1), be_const_var(4) }, + { be_const_key(response_append, -1), be_const_func(l_respAppend) }, + { be_const_key(_get_cb, -1), be_const_func(l_get_cb) }, { be_const_key(time_reached, -1), be_const_func(l_timereached) }, + { be_const_key(wifi, 19), be_const_func(l_wifi) }, + { be_const_key(rtc, -1), be_const_func(l_rtc) }, + { be_const_key(i2c_enabled, 8), be_const_func(l_i2cenabled) }, + { be_const_key(publish_result, 34), be_const_func(l_publish_result) }, + { be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) }, + { be_const_key(yield, 6), be_const_func(l_yield) }, + { be_const_key(init, -1), be_const_closure(init_closure) }, + { be_const_key(eth, -1), be_const_func(l_eth) }, + { be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) }, + { be_const_key(get_option, -1), be_const_func(l_getoption) }, + { be_const_key(get_power, -1), be_const_func(l_getpower) }, + { be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) }, + { be_const_key(get_light, 11), be_const_closure(get_light_closure) }, + { be_const_key(cmd_res, -1), be_const_var(5) }, + { be_const_key(event, -1), be_const_closure(event_closure) }, + { be_const_key(load, -1), be_const_closure(load_closure) }, + { be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) }, + { be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) }, + { be_const_key(_cb, 50), be_const_var(6) }, + { be_const_key(remove_driver, 67), be_const_closure(remove_driver_closure) }, + { be_const_key(wire1, 61), be_const_var(7) }, + { be_const_key(memory, -1), be_const_func(l_memory) }, + { be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) }, + { be_const_key(time_dump, -1), be_const_func(l_time_dump) }, + { be_const_key(_ccmd, -1), be_const_var(8) }, + { be_const_key(exec_cmd, 39), be_const_closure(exec_cmd_closure) }, + { be_const_key(exec_rules, 68), be_const_closure(exec_rules_closure) }, + { be_const_key(resp_cmnd, 14), be_const_func(l_respCmnd) }, + { be_const_key(remove_cmd, -1), be_const_closure(remove_cmd_closure) }, + { be_const_key(remove_rule, 69), be_const_closure(remove_rule_closure) }, + { be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) }, + { be_const_key(_rules, 41), be_const_var(9) }, + { be_const_key(strftime, 59), be_const_func(l_strftime) }, + { be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) }, + { be_const_key(set_timer, -1), be_const_closure(set_timer_closure) }, { be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) }, { be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) }, - { be_const_key(_timers, -1), be_const_var(8) }, - { be_const_key(event, 7), be_const_closure(event_closure) }, - { be_const_key(wire2, -1), be_const_var(9) }, { be_const_key(scale_uint, -1), be_const_func(l_scaleuint) }, - { be_const_key(get_power, 73), be_const_func(l_getpower) }, - { be_const_key(millis, -1), be_const_func(l_millis) }, - { be_const_key(save, 44), be_const_func(l_save) }, - { be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) }, - { be_const_key(memory, -1), be_const_func(l_memory) }, - { be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) }, + { be_const_key(time_str, -1), be_const_closure(time_str_closure) }, + { be_const_key(millis, 48), be_const_func(l_millis) }, + { be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) }, + { be_const_key(arch, -1), be_const_func(l_arch) }, + { be_const_key(log, -1), be_const_func(l_logInfo) }, + { be_const_key(add_rule, -1), be_const_closure(add_rule_closure) }, + { be_const_key(_cmd, 17), be_const_func(l_cmd) }, + { be_const_key(get_switch, -1), be_const_func(l_getswitch) }, + { be_const_key(find_op, -1), be_const_closure(find_op_closure) }, + { be_const_key(add_driver, 3), be_const_closure(add_driver_closure) }, + { be_const_key(save, 65), be_const_func(l_save) }, + { be_const_key(web_send, -1), be_const_func(l_webSend) }, + { be_const_key(cb_dispatch, -1), be_const_closure(cb_dispatch_closure) }, }; static be_define_const_map( be_class_tasmota_map, - 74 + 75 ); BE_EXPORT_VARIABLE be_define_const_class( diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index 87db014c0..93abe9daa 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -103,6 +103,19 @@ String GetDeviceHardware(void) { #ifdef ESP32 +// ESP32_ARCH contains the name of the architecture (used by autoconf) +#if CONFIG_IDF_TARGET_ESP32 + #define ESP32_ARCH "esp32" +#elif CONFIG_IDF_TARGET_ESP32S2 + #define ESP32_ARCH "esp32s2" +#elif CONFIG_IDF_TARGET_ESP32S3 + #define ESP32_ARCH "esp32s3" +#elif CONFIG_IDF_TARGET_ESP32C3 + #define ESP32_ARCH "esp32c3" +#else + #define ESP32_ARCH "" +#endif + // Handle 20k of NVM #include diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index f98a5820a..573298789 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -519,6 +519,14 @@ extern "C" { be_return(vm); } + // Berry: `arvh() -> string` + // ESP object + int32_t l_arch(bvm *vm); + int32_t l_arch(bvm *vm) { + be_pushstring(vm, ESP32_ARCH); + be_return(vm); + } + // Berry: `save(file:string, f:closure) -> bool` int32_t l_save(struct bvm *vm); int32_t l_save(struct bvm *vm) { From 568726be6f530147e0a679fdba19b70a9a40c06a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 11 Nov 2021 11:20:56 +0100 Subject: [PATCH 3/6] Add TSettings assert --- tasmota/settings.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasmota/settings.h b/tasmota/settings.h index b1cefb803..de77a0390 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -763,6 +763,8 @@ typedef struct { uint32_t cfg_crc32; // FFC } TSettings; +static_assert(sizeof(TSettings) == 4096, "TSettings Size is not correct"); + typedef struct { uint16_t valid; // 280 (RTC memory offset 100 - sizeof(RTCRBT)) uint8_t fast_reboot_count; // 282 From ae275d984f109d3690944502058a0a9b99f95c1b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 11 Nov 2021 11:33:08 +0100 Subject: [PATCH 4/6] Add support for HDC2010 temperature/humidity sensor Add support for HDC2010 temperature/humidity sensor by Luc Boudreau (#13633) --- CHANGELOG.md | 3 +++ RELEASENOTES.md | 1 + tasmota/support_features.ino | 6 ++++-- tools/decode-status.py | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 540535ab9..cd72e5052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development ## [10.0.0.2] +### Added +- Support for HDC2010 temperature/humidity sensor by Luc Boudreau (#13633) + ### Changed - ESP32 core library from v1.0.7.5 to v2.0.1 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index e996c63f9..af4c13ba3 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -105,6 +105,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - 1 second heartbeat GPIO - ESP32 Berry add module ``python_compat`` to be closer to Python syntax [#13428](https://github.com/arendst/Tasmota/issues/13428) - Command ``TcpConfig`` for TCPBridge protocol configuration [#13565](https://github.com/arendst/Tasmota/issues/13565) +- Support for HDC2010 temperature/humidity sensor by Luc Boudreau [#13633](https://github.com/arendst/Tasmota/issues/13633) ### Breaking Changed diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 6a2d73b37..6ed9eff6f 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -772,10 +772,12 @@ void ResponseAppendFeatures(void) feature8 |= 0x00004000; // xsns_92_scd40.ino #endif #if defined(USE_I2C) && defined(USE_HM330X) - feature8 |= 0x00008000; + feature8 |= 0x00008000; // xsns_93_hm330x.ino #endif -// feature8 |= 0x00010000; +#if defined(USE_I2C) && defined(USE_HDC2010) + feature8 |= 0x00010000; // xsns_94_hdc2010.ino +#endif // feature8 |= 0x00020000; // feature8 |= 0x00040000; // feature8 |= 0x00080000; diff --git a/tools/decode-status.py b/tools/decode-status.py index 0fef90db9..f6d8a9b36 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -259,7 +259,7 @@ a_features = [[ "USE_BM8563","USE_ENERGY_DUMMY","USE_AM2320","USE_T67XX", "USE_MCP2515","USE_TASMESH","USE_WIFI_RANGE_EXTENDER","USE_INFLUXDB", "USE_HRG15","USE_VINDRIKTNING","USE_SCD40","USE_HM330X", - "","","","", + "USE_HDC2010","","","", "","","","", "","","","", "","","","" @@ -290,7 +290,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20211008 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20211111 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj)) From be86d270c016985040bfd3df401e893e672cc778 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 11 Nov 2021 17:55:22 +0100 Subject: [PATCH 5/6] Silence compiler warnings, try 2 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 660bf4d96..4cde16fa4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -64,11 +64,11 @@ lib_extra_dirs = [scripts_defaults] extra_scripts = pio-tools/strip-floats.py - pio-tools/add_c_flags.py pio-tools/name-firmware.py pio-tools/gzip-firmware.py pio-tools/override_copy.py pio-tools/download_fs.py + pre:pio-tools/add_c_flags.py [esp_defaults] ; *** remove undesired all warnings From a08ec243925ad7af9076227b10cc52a1e882290e Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Thu, 11 Nov 2021 17:18:02 +0000 Subject: [PATCH 6/6] Next try to silence compiler --- platformio.ini | 1 - platformio_tasmota32.ini | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 4cde16fa4..fdb0e328a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,7 +68,6 @@ extra_scripts = pio-tools/strip-floats.py pio-tools/gzip-firmware.py pio-tools/override_copy.py pio-tools/download_fs.py - pre:pio-tools/add_c_flags.py [esp_defaults] ; *** remove undesired all warnings diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index e89969b3f..ace874df4 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -30,6 +30,8 @@ build_flags = ${esp_defaults.build_flags} -include "esp32x_fixes.h" ; wrappers for the crash-recorder -Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception +extra_scripts = ${common.extra_scripts} + pre:pio-tools/add_c_flags.py [core32] platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master