mirror of https://github.com/arendst/Tasmota.git
parent
b7b87f5524
commit
cdae4f3f46
|
@ -1,4 +1,5 @@
|
|||
/* 6.1.1c
|
||||
* Add support for CCS811 sensor (#3309)
|
||||
* Add command Timers 0/1 to globally disable or enable armed timers (#3270)
|
||||
*
|
||||
* 6.1.1b
|
||||
|
|
|
@ -188,6 +188,9 @@ uint8_t ntp_force_sync = 0; // Force NTP sync
|
|||
StateBitfield global_state;
|
||||
RulesBitfield rules_flag;
|
||||
|
||||
uint8_t glob_humidity = 0;
|
||||
sint16_t glob_temperature = -9999;
|
||||
|
||||
char my_version[33]; // Composed version string
|
||||
char my_hostname[33]; // Composed Wifi hostname
|
||||
char mqtt_client[33]; // Composed MQTT Clientname
|
||||
|
@ -198,11 +201,6 @@ char log_data[LOGSZ]; // Logging
|
|||
char web_log[WEB_LOG_SIZE] = {'\0'}; // Web log buffer
|
||||
String backlog[MAX_BACKLOG]; // Command backlog
|
||||
|
||||
#ifdef USE_CCS811
|
||||
uint8_t glob_humidity=0;
|
||||
sint16_t glob_temperature=-9999;
|
||||
#endif
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
char* Format(char* output, const char* input, int size)
|
||||
|
|
|
@ -58,9 +58,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
|||
* Provide an image with all supported sensors enabled
|
||||
\*********************************************************************************************/
|
||||
|
||||
|
||||
#define USE_CCS811 // Add I2C code for CCS811 sensor (+2k2 code)
|
||||
|
||||
#ifdef USE_ALL_SENSORS
|
||||
|
||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||
|
@ -74,7 +71,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
|||
#define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code)
|
||||
#define USE_BME680 // Add additional support for BME680 sensor using Bosch BME680 library (+4k code)
|
||||
#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 code)
|
||||
#define USE_CCS811 // Add I2C code for CCS811 sensor (+2k2 code)
|
||||
#define USE_BH1750 // Add I2C code for BH1750 sensor (+0k5 code)
|
||||
#define USE_VEML6070 // Add I2C code for VEML6070 sensor (+0k5 code)
|
||||
#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code)
|
||||
|
@ -84,6 +80,7 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
|||
#define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code)
|
||||
#define USE_MGS // Add I2C code for Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code)
|
||||
//#define USE_APDS9960 // Add I2C code for APDS9960 Proximity Sensor. Disables SHT and VEML6070 (+4k7 code)
|
||||
//#define USE_CCS811 // Add I2C code for CCS811 sensor (+2k2 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)
|
||||
#ifndef CO2_LOW
|
||||
|
|
|
@ -290,6 +290,7 @@
|
|||
// #define USE_APDS9960 // Enable APDS9960 Proximity Sensor (I2C address 0x39). Disables SHT and VEML6070 (+4k7 code)
|
||||
// #define USE_MCP230xx // Enable MCP23008/MCP23017 for GP INPUT ONLY (I2C addresses 0x20 - 0x27) providing command Sensor29 for configuration (+2k2 code)
|
||||
// #define USE_MPR121 // Enable MPR121 controller (I2C addresses 0x5A, 0x5B, 0x5C and 0x5D) in input mode for touch buttons (+1k3 code)
|
||||
// #define USE_CCS811 // Enable CCS811 sensor (I2C address 0x5A) (+2k2 code)
|
||||
#endif // USE_I2C
|
||||
|
||||
// -- SPI sensors ---------------------------------
|
||||
|
|
|
@ -459,6 +459,9 @@ void BmpRead()
|
|||
#endif // USE_BME680
|
||||
}
|
||||
if (bmp_temperature != 0.0) { bmp_temperature = ConvertTemp(bmp_temperature); }
|
||||
|
||||
glob_humidity = bmp_humidity;
|
||||
glob_temperature = bmp_temperature;
|
||||
}
|
||||
|
||||
void BmpEverySecond()
|
||||
|
@ -495,12 +498,6 @@ void BmpShow(boolean json)
|
|||
dtostrfd(bmp_gas_resistance, 2, gas_resistance);
|
||||
#endif // USE_BME680
|
||||
|
||||
|
||||
#ifdef USE_CCS811
|
||||
glob_humidity=bmp_humidity;
|
||||
glob_temperature=(bmp_temperature*4);
|
||||
#endif
|
||||
|
||||
if (json) {
|
||||
char json_humidity[40];
|
||||
snprintf_P(json_humidity, sizeof(json_humidity), PSTR(",\"" D_JSON_HUMIDITY "\":%s"), humidity);
|
||||
|
|
|
@ -102,12 +102,10 @@ void Sht3xShow(boolean json)
|
|||
for (byte i = 0; i < sht3x_count; i++) {
|
||||
if (Sht3xRead(t, h, sht3x_sensors[i].address)) {
|
||||
|
||||
#ifdef USE_CCS811
|
||||
if (i==0) {
|
||||
glob_humidity=h;
|
||||
glob_temperature=(t*4);
|
||||
if (0 == i) {
|
||||
glob_humidity = h;
|
||||
glob_temperature = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
dtostrfd(t, Settings.flag2.temperature_resolution, temperature);
|
||||
dtostrfd(h, Settings.flag2.humidity_resolution, humidity);
|
||||
|
|
|
@ -34,19 +34,20 @@ uint8_t CCS811_ready;
|
|||
uint8_t CCS811_type;
|
||||
uint16_t eCO2;
|
||||
uint16_t TVOC;
|
||||
uint8_t tcnt,ecnt;
|
||||
uint8_t tcnt = 0;
|
||||
uint8_t ecnt = 0;
|
||||
|
||||
/********************************************************************************************/
|
||||
#define EVERYNSECONDS 5
|
||||
|
||||
void CCS811Update() // Perform every n second
|
||||
{
|
||||
tcnt+=1;
|
||||
if (tcnt>=EVERYNSECONDS) {
|
||||
tcnt=0;
|
||||
tcnt++;
|
||||
if (tcnt >= EVERYNSECONDS) {
|
||||
tcnt = 0;
|
||||
CCS811_ready = 0;
|
||||
if (!CCS811_type) {
|
||||
sint8_t res=ccs.begin(CCS811_ADDRESS);
|
||||
sint8_t res = ccs.begin(CCS811_ADDRESS);
|
||||
if (!res) {
|
||||
CCS811_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "CCS811", 0x5A);
|
||||
|
@ -58,19 +59,19 @@ void CCS811Update() // Perform every n second
|
|||
} else {
|
||||
if (ccs.available()) {
|
||||
if (!ccs.readData()){
|
||||
TVOC=ccs.getTVOC();
|
||||
eCO2=ccs.geteCO2();
|
||||
TVOC = ccs.getTVOC();
|
||||
eCO2 = ccs.geteCO2();
|
||||
CCS811_ready = 1;
|
||||
if (glob_humidity!=0 && glob_temperature!=-9999) {
|
||||
double gtmp=glob_temperature;
|
||||
ccs.setEnvironmentalData(glob_humidity,gtmp/4);
|
||||
if ((glob_humidity != 0) && (glob_temperature != -9999)) {
|
||||
double gtmp = glob_temperature * 4;
|
||||
ccs.setEnvironmentalData(glob_humidity, gtmp / 4);
|
||||
}
|
||||
ecnt=0;
|
||||
ecnt = 0;
|
||||
}
|
||||
} else {
|
||||
// failed, count up
|
||||
ecnt+=1;
|
||||
if (ecnt>6) {
|
||||
ecnt++;
|
||||
if (ecnt > 6) {
|
||||
// after 30 seconds, restart
|
||||
ccs.begin(CCS811_ADDRESS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue