From af5df84067876b99ac53d969a287a4de8a275d14 Mon Sep 17 00:00:00 2001 From: chrfriese123 Date: Fri, 8 Sep 2023 20:59:33 +0000 Subject: [PATCH] Disable USE_ENS16x and USE_ENS210 by default --- BUILDS.md | 4 +- .../src/ScioSense_ENS16x.cpp.bak | 449 ------------------ .../src/ScioSense_ENS16x.h.bak | 201 -------- tasmota/include/tasmota_configurations.h | 4 +- .../include/tasmota_configurations_ESP32.h | 4 +- 5 files changed, 6 insertions(+), 656 deletions(-) delete mode 100644 lib/lib_i2c/ScioSense_ENS16x/src/ScioSense_ENS16x.cpp.bak delete mode 100644 lib/lib_i2c/ScioSense_ENS16x/src/ScioSense_ENS16x.h.bak diff --git a/BUILDS.md b/BUILDS.md index 8ef7dd924d59..1c1824a584db 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -132,8 +132,8 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up | USE_MPR121 | - | - / - | - | - | - | - | | USE_CCS811 | - | - / - | - | x | - | - | | USE_CCS811_V2 | - | - / x | - | - | - | - | -| USE_ENS16x | - | - / x | - | x | - | - | -| USE_ENS210 | - | - / x | - | x | - | - | +| USE_ENS16x | - | - / - | - | - | - | - | +| USE_ENS210 | - | - / - | - | - | - | - | | USE_MPU6050 | - | - / - | - | - | - | - | | USE_DS3231 | - | - / - | - | - | - | - | | USE_MGC3130 | - | - / - | - | - | - | - | diff --git a/lib/lib_i2c/ScioSense_ENS16x/src/ScioSense_ENS16x.cpp.bak b/lib/lib_i2c/ScioSense_ENS16x/src/ScioSense_ENS16x.cpp.bak deleted file mode 100644 index 5cda73d6d1ea..000000000000 --- a/lib/lib_i2c/ScioSense_ENS16x/src/ScioSense_ENS16x.cpp.bak +++ /dev/null @@ -1,449 +0,0 @@ -/* - ScioSense_ENS16x.h - Library for the ENS160 & ENS161 sensor with I2C interface from ScioSense - 2023 Jul 03 v8 Christoph Friese Update to cover ENS160 and ENS161 - 2023 Mar 23 v7 Christoph Friese Bugfix measurement routine, prepare next release - 2021 Nov 25 v6 Martin Herold Custom mode timing fixed - 2021 July 29 v5 Christoph Friese Changed nomenclature to ScioSense as product shifted from ams - 2021 Feb 04 v4 Giuseppe de Pinto Custom mode fixed - 2020 Apr 06 v3 Christoph Friese Changed nomenclature to ScioSense as product shifted from ams - 2020 Feb 15 v2 Giuseppe Pasetti Corrected firmware flash option - 2019 May 05 v1 Christoph Friese Created - - based on application note "ENS160 Software Integration.pdf" rev 0.01 -*/ - -#include "ScioSense_ENS16x.h" -#include "math.h" - -ScioSense_ENS16x::ScioSense_ENS16x(uint8_t slaveaddr) { - this->_slaveaddr = slaveaddr; - - this->_ADDR = 0; - this->_nINT = 0; - this->_nCS = 0; -} - -ScioSense_ENS16x::ScioSense_ENS16x(uint8_t ADDR, uint8_t nCS, uint8_t nINT) { - this->_slaveaddr = ENS16x_I2CADDR_0; - - this->_ADDR = ADDR; - this->_nINT = nINT; - this->_nCS = nCS; -} - -ScioSense_ENS16x::ScioSense_ENS16x(uint8_t slaveaddr, uint8_t ADDR, uint8_t nCS, uint8_t nINT) { - this->_slaveaddr = slaveaddr; - - this->_ADDR = ADDR; - this->_nINT = nINT; - this->_nCS = nCS; -} - -// Function to redefine I2C pins -void ScioSense_ENS16x::setI2C(uint8_t sda, uint8_t scl) { - this->_sdaPin = sda; - this->_sclPin = scl; -} - -// Init I2C communication, resets ENS16x and checks its PART_ID. Returns false on I2C problems or wrong PART_ID. -bool ScioSense_ENS16x::begin(bool debug) -{ - debugENS16x = debug; - - //Set pin levels - if (this->_ADDR > 0) { - pinMode(this->_ADDR, OUTPUT); - digitalWrite(this->_ADDR, LOW); - } - if (this->_nINT > 0) pinMode(this->_nINT, INPUT_PULLUP); - if (this->_nCS > 0) { - pinMode(this->_nCS, OUTPUT); - digitalWrite(this->_nCS, HIGH); - } - - //init I2C - _i2c_init(); - if (debugENS16x) { - Serial.println("begin() - I2C init done"); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - this->_available = false; - this->_available = this->reset(); - - this->_available = this->checkPartID(); - - if (this->_available) { - this->_available = this->setMode(ENS16x_OPMODE_IDLE); - this->_available = this->clearCommand(); - this->_available = this->getFirmware(); - } - if (debugENS16x) { - Serial.println("ENS16x in idle mode"); - } - return this->_available; -} - -// Sends a reset to the ENS16x. Returns false on I2C problems. -bool ScioSense_ENS16x::reset(void) -{ - uint8_t result = this->write8(_slaveaddr, ENS16x_REG_OPMODE, ENS16x_OPMODE_RESET); - - if (debugENS16x) { - Serial.print("reset() result: "); - Serial.println(result == 0 ? "ok" : "nok"); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - return result == 0; -} - -// Reads the part ID and confirms valid sensor -bool ScioSense_ENS16x::checkPartID(void) { - uint8_t i2cbuf[2]; - uint16_t part_id; - bool result = false; - - this->read(_slaveaddr, ENS16x_REG_PART_ID, i2cbuf, 2); - part_id = i2cbuf[0] | ((uint16_t)i2cbuf[1] << 8); - - if (debugENS16x) { - Serial.print("checkPartID() result: "); - if (part_id == ENS160_PARTID) Serial.println("ENS160 ok"); - else if (part_id == ENS161_PARTID) Serial.println("ENS161 ok"); - else Serial.println("nok"); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - if (part_id == ENS160_PARTID) { this->_revENS16x = 0; result = true; } - else if (part_id == ENS161_PARTID) { this->_revENS16x = 1; result = true; } - - return result; -} - -// Initialize idle mode and confirms -bool ScioSense_ENS16x::clearCommand(void) { - uint8_t status; - uint8_t result; - - result = this->write8(_slaveaddr, ENS16x_REG_COMMAND, ENS16x_COMMAND_NOP); - result = this->write8(_slaveaddr, ENS16x_REG_COMMAND, ENS16x_COMMAND_CLRGPR); - if (debugENS16x) { - Serial.print("clearCommand() result: "); - Serial.println(result == 0 ? "ok" : "nok"); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - status = this->read8(_slaveaddr, ENS16x_REG_DATA_STATUS); - if (debugENS16x) { - Serial.print("clearCommand() status: 0x"); - Serial.println(status, HEX); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - return result == 0; -} - -// Read firmware revisions -bool ScioSense_ENS16x::getFirmware() { - uint8_t i2cbuf[3]; - uint8_t result; - - this->clearCommand(); - - delay(ENS16x_BOOTING); // Wait to boot after reset - - result = this->write8(_slaveaddr, ENS16x_REG_COMMAND, ENS16x_COMMAND_GET_APPVER); - result = this->read(_slaveaddr, ENS16x_REG_GPR_READ_4, i2cbuf, 3); - - this->_fw_ver_major = i2cbuf[0]; - this->_fw_ver_minor = i2cbuf[1]; - this->_fw_ver_build = i2cbuf[2]; - - if (this->_fw_ver_major > 6) this->_revENS16x = 1; - else this->_revENS16x = 0; - - if (debugENS16x) { - Serial.println(this->_fw_ver_major); - Serial.println(this->_fw_ver_minor); - Serial.println(this->_fw_ver_build); - Serial.print("getFirmware() result: "); - Serial.println(result == 0 ? "ok" : "nok"); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - return result == 0; -} - -// Set operation mode of sensor -bool ScioSense_ENS16x::setMode(uint8_t mode) { - uint8_t result; - - //LP only valid for rev>0 - if ((mode == ENS161_OPMODE_LP) and (_revENS16x == 0)) result = 1; - else result = this->write8(_slaveaddr, ENS16x_REG_OPMODE, mode); - - //if (debugENS16x) { - Serial.print("setMode() activate result: "); - Serial.println(result == 0 ? "ok" : "nok"); - //} - - delay(ENS16x_BOOTING); // Wait to boot after reset - - return result == 0; -} - -// Initialize definition of custom mode with steps -bool ScioSense_ENS16x::initCustomMode(uint16_t stepNum) { - uint8_t result; - - if (stepNum > 0) { - this->_stepCount = stepNum; - - result = this->setMode(ENS16x_OPMODE_IDLE); - result = this->clearCommand(); - - result = this->write8(_slaveaddr, ENS16x_REG_COMMAND, ENS16x_COMMAND_SETSEQ); - } else { - result = 1; - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - return result == 0; -} - -// Add a step to custom measurement profile with definition of duration, enabled data acquisition and temperature for each hotplate -bool ScioSense_ENS16x::addCustomStep(uint16_t time, bool measureHP0, bool measureHP1, bool measureHP2, bool measureHP3, uint16_t tempHP0, uint16_t tempHP1, uint16_t tempHP2, uint16_t tempHP3) { - uint8_t seq_ack; - uint8_t temp; - - if (debugENS16x) { - Serial.print("setCustomMode() write step "); - Serial.println(this->_stepCount); - } - delay(ENS16x_BOOTING); // Wait to boot after reset - - temp = (uint8_t)(((time / 24)-1) << 6); - if (measureHP0) temp = temp | 0x20; - if (measureHP1) temp = temp | 0x10; - if (measureHP2) temp = temp | 0x8; - if (measureHP3) temp = temp | 0x4; - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_0, temp); - - temp = (uint8_t)(((time / 24)-1) >> 2); - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_1, temp); - - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_2, (uint8_t)(tempHP0/2)); - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_3, (uint8_t)(tempHP1/2)); - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_4, (uint8_t)(tempHP2/2)); - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_5, (uint8_t)(tempHP3/2)); - - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_6, (uint8_t)(this->_stepCount - 1)); - - if (this->_stepCount == 1) { - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_7, 128); - } else { - this->write8(_slaveaddr, ENS16x_REG_GPR_WRITE_7, 0); - } - delay(ENS16x_BOOTING); - - seq_ack = this->read8(_slaveaddr, ENS16x_REG_GPR_READ_7); - delay(ENS16x_BOOTING); // Wait to boot after reset - - if ((ENS16x_SEQ_ACK_COMPLETE | this->_stepCount) != seq_ack) { - this->_stepCount = this->_stepCount - 1; - return 0; - } else { - return 1; - } - -} - -// Perform prediction measurement and stores result in internal variables -bool ScioSense_ENS16x::measure(bool waitForNew) { - uint8_t i2cbuf[8]; - uint8_t status; - bool newData = false; - - // Set default status for early bail out - if (debugENS16x) Serial.println("Start measurement"); - - if (waitForNew) { - do { - delay(10); - status = this->read8(_slaveaddr, ENS16x_REG_DATA_STATUS); - - //if (debugENS16x) { - Serial.print("Status: "); - Serial.println(status); - //} - - } while (!IS_NEWDAT(status)); - } else { - status = this->read8(_slaveaddr, ENS16x_REG_DATA_STATUS); - } - - // Read predictions - if (IS_NEWDAT(status)) { - newData = true; - this->read(_slaveaddr, ENS16x_REG_DATA_AQI, i2cbuf, 7); - _data_aqi = i2cbuf[0]; - _data_tvoc = i2cbuf[1] | ((uint16_t)i2cbuf[2] << 8); - _data_eco2 = i2cbuf[3] | ((uint16_t)i2cbuf[4] << 8); - if (_revENS16x > 0) _data_aqis = ((uint16_t)i2cbuf[5]) | ((uint16_t)i2cbuf[6] << 8); - else _data_aqis = 0; - } - - return newData; -} - -// Perfrom raw measurement and stores result in internal variables -bool ScioSense_ENS16x::measureRaw(bool waitForNew) { - uint8_t i2cbuf[8]; - uint8_t status; - bool newData = false; - - // Set default status for early bail out - if (debugENS16x) Serial.println("Start measurement"); - - if (waitForNew) { - do { - delay(10); - status = this->read8(_slaveaddr, ENS16x_REG_DATA_STATUS); - - if (debugENS16x) { - Serial.print("Status: "); - Serial.println(status); - } - } while (!IS_NEWGPR(status)); - } else { - status = this->read8(_slaveaddr, ENS16x_REG_DATA_STATUS); - } - - if (IS_NEWGPR(status)) { - newData = true; - - // Read raw resistance values - this->read(_slaveaddr, ENS16x_REG_GPR_READ_0, i2cbuf, 8); - _hp0_rs = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[0] | ((uint16_t)i2cbuf[1] << 8))); - _hp1_rs = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[2] | ((uint16_t)i2cbuf[3] << 8))); - _hp2_rs = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[4] | ((uint16_t)i2cbuf[5] << 8))); - _hp3_rs = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[6] | ((uint16_t)i2cbuf[7] << 8))); - - // Read baselines - this->read(_slaveaddr, ENS16x_REG_DATA_BL, i2cbuf, 8); - _hp0_bl = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[0] | ((uint16_t)i2cbuf[1] << 8))); - _hp1_bl = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[2] | ((uint16_t)i2cbuf[3] << 8))); - _hp2_bl = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[4] | ((uint16_t)i2cbuf[5] << 8))); - _hp3_bl = CONVERT_RS_RAW2OHMS_F((uint32_t)(i2cbuf[6] | ((uint16_t)i2cbuf[7] << 8))); - - this->read(_slaveaddr, ENS16x_REG_DATA_MISR, i2cbuf, 1); - _misr = i2cbuf[0]; - } - - return newData; -} - - -// Writes t (degC) and h (%rh) to ENV_DATA. Returns false on I2C problems. -bool ScioSense_ENS16x::set_envdata(float t, float h) { - - uint16_t t_data = (uint16_t)((t + 273.15f) * 64.0f); - - uint16_t rh_data = (uint16_t)(h * 512.0f); - - return this->set_envdata210(t_data, rh_data); -} - -// Writes t and h (in ENS210 format) to ENV_DATA. Returns false on I2C problems. -bool ScioSense_ENS16x::set_envdata210(uint16_t t, uint16_t h) { - //uint16_t temp; - uint8_t trh_in[4]; - - //temp = (uint16_t)((t + 273.15f) * 64.0f); - trh_in[0] = t & 0xff; - trh_in[1] = (t >> 8) & 0xff; - - //temp = (uint16_t)(h * 512.0f); - trh_in[2] = h & 0xff; - trh_in[3] = (h >> 8) & 0xff; - - uint8_t result = this->write(_slaveaddr, ENS16x_REG_TEMP_IN, trh_in, 4); - - return result; -} - -/**************************************************************************/ - -void ScioSense_ENS16x::_i2c_init() { - if (this->_sdaPin != this->_sclPin) Wire.begin(this->_sdaPin, this->_sclPin); - else Wire.begin(); -} - -/**************************************************************************/ - -uint8_t ScioSense_ENS16x::read8(uint8_t addr, byte reg) { - uint8_t ret; - this->read(addr, reg, &ret, 1); - - return ret; -} - -uint8_t ScioSense_ENS16x::read(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t num) { - uint8_t pos = 0; - uint8_t result = 0; - - if (debugENS16x) { - Serial.print("I2C read address: 0x"); - Serial.print(addr, HEX); - Serial.print(" - register: 0x"); - Serial.println(reg, HEX); - } - - //on arduino we need to read in 32 byte chunks - while(pos < num){ - - uint8_t read_now = min((uint8_t)32, (uint8_t)(num - pos)); - Wire.beginTransmission((uint8_t)addr); - - Wire.write((uint8_t)reg + pos); - result = Wire.endTransmission(); - Wire.requestFrom((uint8_t)addr, read_now); - - for(int i=0; iwrite(addr, reg, &value, 1); - return result; -} - -uint8_t ScioSense_ENS16x::write(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t num) { - if (debugENS16x) { - Serial.print("I2C write address: 0x"); - Serial.print(addr, HEX); - Serial.print(" - register: 0x"); - Serial.print(reg, HEX); - Serial.print(" - value:"); - for (int i = 0; i= 100) - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#include - -// Chip constants -#define ENS160_PARTID 0x0160 -#define ENS161_PARTID 0x0161 -#define ENS16x_BOOTING 10 - -// 7-bit I2C slave address of the ENS16x -#define ENS16x_I2CADDR_0 0x52 //ADDR low -#define ENS16x_I2CADDR_1 0x53 //ADDR high - -// ENS16x registers for version V0 -#define ENS16x_REG_PART_ID 0x00 // 2 byte register -#define ENS16x_REG_OPMODE 0x10 -#define ENS16x_REG_CONFIG 0x11 -#define ENS16x_REG_COMMAND 0x12 -#define ENS16x_REG_TEMP_IN 0x13 -#define ENS16x_REG_RH_IN 0x15 -#define ENS16x_REG_DATA_STATUS 0x20 -#define ENS16x_REG_DATA_AQI 0x21 -#define ENS16x_REG_DATA_TVOC 0x22 -#define ENS16x_REG_DATA_ECO2 0x24 -#define ENS16x_REG_DATA_BL 0x28 -#define ENS16x_REG_DATA_T 0x30 -#define ENS16x_REG_DATA_RH 0x32 -#define ENS16x_REG_DATA_MISR 0x38 -#define ENS16x_REG_GPR_WRITE_0 0x40 -#define ENS16x_REG_GPR_WRITE_1 ENS16x_REG_GPR_WRITE_0 + 1 -#define ENS16x_REG_GPR_WRITE_2 ENS16x_REG_GPR_WRITE_0 + 2 -#define ENS16x_REG_GPR_WRITE_3 ENS16x_REG_GPR_WRITE_0 + 3 -#define ENS16x_REG_GPR_WRITE_4 ENS16x_REG_GPR_WRITE_0 + 4 -#define ENS16x_REG_GPR_WRITE_5 ENS16x_REG_GPR_WRITE_0 + 5 -#define ENS16x_REG_GPR_WRITE_6 ENS16x_REG_GPR_WRITE_0 + 6 -#define ENS16x_REG_GPR_WRITE_7 ENS16x_REG_GPR_WRITE_0 + 7 -#define ENS16x_REG_GPR_READ_0 0x48 -#define ENS16x_REG_GPR_READ_4 ENS16x_REG_GPR_READ_0 + 4 -#define ENS16x_REG_GPR_READ_6 ENS16x_REG_GPR_READ_0 + 6 -#define ENS16x_REG_GPR_READ_7 ENS16x_REG_GPR_READ_0 + 7 - -//ENS16x data register fields -#define ENS16x_COMMAND_NOP 0x00 -#define ENS16x_COMMAND_CLRGPR 0xCC -#define ENS16x_COMMAND_GET_APPVER 0x0E -#define ENS16x_COMMAND_SETTH 0x02 -#define ENS16x_COMMAND_SETSEQ 0xC2 - -#define ENS16x_OPMODE_RESET 0xF0 -#define ENS16x_OPMODE_DEP_SLEEP 0x00 -#define ENS16x_OPMODE_IDLE 0x01 -#define ENS16x_OPMODE_STD 0x02 -#define ENS161_OPMODE_LP 0x03 -#define ENS16x_OPMODE_CUSTOM 0xC0 - -#define ENS16x_BL_CMD_START 0x02 -#define ENS16x_BL_CMD_ERASE_APP 0x04 -#define ENS16x_BL_CMD_ERASE_BLINE 0x06 -#define ENS16x_BL_CMD_WRITE 0x08 -#define ENS16x_BL_CMD_VERIFY 0x0A -#define ENS16x_BL_CMD_GET_BLVER 0x0C -#define ENS16x_BL_CMD_GET_APPVER 0x0E -#define ENS16x_BL_CMD_EXITBL 0x12 - -#define ENS16x_SEQ_ACK_NOTCOMPLETE 0x80 -#define ENS16x_SEQ_ACK_COMPLETE 0xC0 - -#define IS_ENS16x_SEQ_ACK_NOT_COMPLETE(x) (ENS16x_SEQ_ACK_NOTCOMPLETE == (ENS16x_SEQ_ACK_NOTCOMPLETE & (x))) -#define IS_ENS16x_SEQ_ACK_COMPLETE(x) (ENS16x_SEQ_ACK_COMPLETE == (ENS16x_SEQ_ACK_COMPLETE & (x))) - -#define ENS16x_DATA_STATUS_NEWDAT 0x02 -#define ENS16x_DATA_STATUS_NEWGPR 0x01 - -#define IS_NEWDAT(x) (ENS16x_DATA_STATUS_NEWDAT == (ENS16x_DATA_STATUS_NEWDAT & (x))) -#define IS_NEWGPR(x) (ENS16x_DATA_STATUS_NEWGPR == (ENS16x_DATA_STATUS_NEWGPR & (x))) -#define IS_NEW_DATA_AVAILABLE(x) (0 != ((ENS16x_DATA_STATUS_NEWDAT | ENS16x_DATA_STATUS_NEWGPR ) & (x))) - -#define CONVERT_RS_RAW2OHMS_I(x) (1 << ((x) >> 11)) -#define CONVERT_RS_RAW2OHMS_F(x) (pow (2, (float)(x) / 2048)) - -class ScioSense_ENS16x { - - public: - ScioSense_ENS16x(uint8_t slaveaddr = ENS16x_I2CADDR_0); // Constructor using slave address (5A or 5B) - ScioSense_ENS16x(uint8_t ADDR, uint8_t nCS, uint8_t nINT); // Constructor with pin definition - ScioSense_ENS16x(uint8_t slaveaddr, uint8_t ADDR, uint8_t nCS, uint8_t nINT); // Constructor with slave address and pin definition - - void setI2C(uint8_t sda, uint8_t scl); // Function to redefine I2C pins - - bool begin(bool debug=false); // Init I2C communication, resets ENS16x and checks its PART_ID. Returns false on I2C problems or wrong PART_ID. - bool available() { return this->_available; } // Report availability of sensor - uint8_t revENS16x() { return this->_revENS16x; } // Report version of sensor (0: ENS16x, 1: ENS161) - bool setMode(uint8_t mode); // Set operation mode of sensor - - bool initCustomMode(uint16_t stepNum); // Initialize definition of custom mode with steps - bool addCustomStep(uint16_t time, bool measureHP0, bool measureHP1, bool measureHP2, bool measureHP3, uint16_t tempHP0, uint16_t tempHP1, uint16_t tempHP2, uint16_t tempHP3); - // Add a step to custom measurement profile with definition of duration, enabled data acquisition and temperature for each hotplate - - bool measure(bool waitForNew = true); // Perform measurement and stores result in internal variables - bool measureRaw(bool waitForNew = true); // Perform raw measurement and stores result in internal variables - bool set_envdata(float t, float h); // Writes t (degC) and h (%rh) to ENV_DATA. Returns "0" if I2C transmission is successful - bool set_envdata210(uint16_t t, uint16_t h); // Writes t and h (in ENS210 format) to ENV_DATA. Returns "0" if I2C transmission is successful - uint8_t getMajorRev() { return this->_fw_ver_major; } // Get major revision number of used firmware - uint8_t getMinorRev() { return this->_fw_ver_minor; } // Get minor revision number of used firmware - uint8_t getBuild() { return this->_fw_ver_build; } // Get build revision number of used firmware - - uint8_t getAQI() { return this->_data_aqi; } // Get AQI value of last measurement - uint16_t getTVOC() { return this->_data_tvoc; } // Get TVOC value of last measurement - uint16_t geteCO2() { return this->_data_eco2; } // Get eCO2 value of last measurement - uint16_t getAQI500() { return this->_data_aqi500; } // Get AQI500 value of last measurement - uint32_t getHP0() { return this->_hp0_rs; } // Get resistance of HP0 of last measurement - uint32_t getHP1() { return this->_hp1_rs; } // Get resistance of HP1 of last measurement - uint32_t getHP2() { return this->_hp2_rs; } // Get resistance of HP2 of last measurement - uint32_t getHP3() { return this->_hp3_rs; } // Get resistance of HP3 of last measurement - uint32_t getHP0BL() { return this->_hp0_bl; } // Get baseline resistance of HP0 of last measurement - uint32_t getHP1BL() { return this->_hp1_bl; } // Get baseline resistance of HP1 of last measurement - uint32_t getHP2BL() { return this->_hp2_bl; } // Get baseline resistance of HP2 of last measurement - uint32_t getHP3BL() { return this->_hp3_bl; } // Get baseline resistance of HP3 of last measurement - uint8_t getMISR() { return this->_misr; } // Return status code of sensor - - private: - uint8_t _ADDR; - uint8_t _nINT; - uint8_t _nCS; - uint8_t _sdaPin = 0; - uint8_t _sclPin = 0; - - bool debugENS16x = false; - - bool reset(); // Sends a reset to the ENS16x. Returns false on I2C problems. - bool checkPartID(); // Reads the part ID and confirms valid sensor - bool clearCommand(); // Initialize idle mode and confirms - bool getFirmware(); // Read firmware revisions - - bool _available = false; // ENS16x available - uint8_t _revENS16x = 0; // ENS160 or ENS161 connected? (FW >7) - - uint8_t _fw_ver_major; - uint8_t _fw_ver_minor; - uint8_t _fw_ver_build; - - uint16_t _stepCount; // Counter for custom sequence - - uint8_t _data_aqi; - uint16_t _data_tvoc; - uint16_t _data_eco2; - uint16_t _data_aqi500; - uint32_t _hp0_rs; - uint32_t _hp0_bl; - uint32_t _hp1_rs; - uint32_t _hp1_bl; - uint32_t _hp2_rs; - uint32_t _hp2_bl; - uint32_t _hp3_rs; - uint32_t _hp3_bl; - uint16_t _temp; - int _slaveaddr; - uint8_t _misr; - - //Isotherm, HP0 252°C / HP1 350°C / HP2 250°C / HP3 324°C / measure every 1008ms - uint8_t _seq_steps[1][8] = { - { 0x7C, 0x0A, 0x7E, 0xAF, 0xAF, 0xA2, 0x00, 0x80 }, - }; - - -/****************************************************************************/ -/* General functions */ -/****************************************************************************/ - void _i2c_init(); - - uint8_t read8(uint8_t addr, byte reg); - uint8_t read(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t num); - - uint8_t write8(uint8_t addr, byte reg, byte value); - uint8_t write(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t num); - -}; - - -#endif \ No newline at end of file diff --git a/tasmota/include/tasmota_configurations.h b/tasmota/include/tasmota_configurations.h index a87ca0b91519..650af1f5ae60 100644 --- a/tasmota/include/tasmota_configurations.h +++ b/tasmota/include/tasmota_configurations.h @@ -111,8 +111,8 @@ //#define USE_MPR121 // [I2cDriver23] Enable MPR121 controller (I2C addresses 0x5A, 0x5B, 0x5C and 0x5D) in input mode for touch buttons (+1k3 code) #define USE_CCS811 // [I2cDriver24] Enable CCS811 sensor (I2C address 0x5A) (+2k2 code) //#define USE_CCS811_V2 // [I2cDriver24] Enable CCS811 sensor (I2C addresses 0x5A and 0x5B) (+2k8 code) -#define USE_ENS16x // [I2cDriver85] Enable ENS160 and ENS161 sensor (I2C addresses 0x52 and 0x53) -#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) +//#define USE_ENS16x // [I2cDriver85] Enable ENS160 or ENS161 sensor (I2C addresses 0x52 and 0x53) +//#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) //#define USE_MPU6050 // [I2cDriver25] Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+3K3 of code and 188 Bytes of RAM) //#define USE_MGC3130 // [I2cDriver27] Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem) //#define USE_MAX44009 // [I2cDriver28] Enable MAX44009 Ambient Light sensor (I2C addresses 0x4A and 0x4B) (+0k8 code) diff --git a/tasmota/include/tasmota_configurations_ESP32.h b/tasmota/include/tasmota_configurations_ESP32.h index 936da9a73314..10e54833ab00 100644 --- a/tasmota/include/tasmota_configurations_ESP32.h +++ b/tasmota/include/tasmota_configurations_ESP32.h @@ -688,8 +688,8 @@ //#define USE_MPR121 // [I2cDriver23] Enable MPR121 controller (I2C addresses 0x5A, 0x5B, 0x5C and 0x5D) in input mode for touch buttons (+1k3 code) //#define USE_CCS811 // [I2cDriver24] Enable CCS811 sensor (I2C address 0x5A) (+2k2 code) #define USE_CCS811_V2 // [I2cDriver24] Enable CCS811 sensor (I2C addresses 0x5A and 0x5B) (+2k8 code) -#define USE_ENS16x // [I2cDriver85] Enable ENS160 and ENS161 sensor (I2C addresses 0x52 and 0x53) -#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) +//#define USE_ENS16x // [I2cDriver85] Enable ENS160 and ENS161 sensor (I2C addresses 0x52 and 0x53) +//#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) #define USE_MPU_ACCEL // [I2cDriver58] Enable MPU6886, MPU9250 6-axis MotionTracking sensor (I2C address 0x68) //#define USE_MPU6050 // [I2cDriver25] Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+3K3 of code and 188 Bytes of RAM) //#define USE_MGC3130 // [I2cDriver27] Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem)