mirror of
https://github.com/anklimov/lighthub
synced 2026-01-26 16:19:07 +03:00
LOG cleaning
This commit is contained in:
@@ -22,14 +22,14 @@ static bool CCS811ready = false;
|
|||||||
|
|
||||||
int in_ccs811::Setup()
|
int in_ccs811::Setup()
|
||||||
{
|
{
|
||||||
if (CCS811ready) {errorSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
if (CCS811ready) {errorSerial<<F("CCS811: Already initialized")<<endl; return 0;}
|
||||||
|
|
||||||
#ifdef WAK_PIN
|
#ifdef WAK_PIN
|
||||||
pinMode(WAK_PIN,OUTPUT);
|
pinMode(WAK_PIN,OUTPUT);
|
||||||
digitalWrite(WAK_PIN,LOW);
|
digitalWrite(WAK_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
infoSerial.println("CCS811 Init");
|
infoSerial.println(F("CCS811: Init"));
|
||||||
|
|
||||||
#if defined (TWI_SCL) && defined (TWI_SDA)
|
#if defined (TWI_SCL) && defined (TWI_SDA)
|
||||||
Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
|
Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
|
||||||
@@ -37,7 +37,9 @@ Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
|
|||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Wire.setClock(4000);
|
#ifdef I2C_CLOCK
|
||||||
|
Wire.setClock(I2C_CLOCK);
|
||||||
|
#endif
|
||||||
|
|
||||||
//It is recommended to check return status on .begin(), but it is not
|
//It is recommended to check return status on .begin(), but it is not
|
||||||
//required.
|
//required.
|
||||||
@@ -46,8 +48,7 @@ Wire.setClock(4000);
|
|||||||
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
||||||
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
||||||
{
|
{
|
||||||
errorSerial.print("CCS811 Init error ");
|
errorSerial.print(F("CCS811: Init error "));
|
||||||
//debugSerial.println(ccs811.statusString(returnCode));
|
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -68,16 +69,16 @@ return 1;
|
|||||||
int in_hdc1080::Setup()
|
int in_hdc1080::Setup()
|
||||||
{
|
{
|
||||||
//i2cReset();
|
//i2cReset();
|
||||||
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
if (HDC1080ready) {debugSerial<<F("HDC1080: Already initialized")<<endl; return 0;}
|
||||||
debugSerial.println("HDC1080 Init ");
|
debugSerial.print(F("HDC1080: Init. "));
|
||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
// Default settings:
|
// Default settings:
|
||||||
// - Heater off
|
// - Heater off
|
||||||
// - 14 bit Temperature and Humidity Measurement Resolutions
|
// - 14 bit Temperature and Humidity Measurement Resolutions
|
||||||
hdc1080.begin(0x40);
|
hdc1080.begin(0x40);
|
||||||
debugSerial.print("Manufacturer ID=0x");
|
debugSerial.print(F("Manufacturer ID=0x"));
|
||||||
debugSerial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
debugSerial.print(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
||||||
debugSerial.print("Device ID=0x");
|
debugSerial.print(F(" Device ID=0x"));
|
||||||
debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
||||||
printSerialNumber();
|
printSerialNumber();
|
||||||
HDC1080ready = true;
|
HDC1080ready = true;
|
||||||
@@ -91,14 +92,14 @@ int in_hdc1080::Poll(short cause)
|
|||||||
float h,t;
|
float h,t;
|
||||||
int reg;
|
int reg;
|
||||||
if (cause!=POLLING_SLOW) return 0;
|
if (cause!=POLLING_SLOW) return 0;
|
||||||
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
if (!HDC1080ready) {errorSerial<<F("HDC1080: Not initialized")<<endl; return 0;}
|
||||||
debugSerial.print("HDC Status=");
|
debugSerial.print(F("HDC1080: Status="));
|
||||||
debugSerial.println(reg=hdc1080.readRegister().rawData,HEX);
|
debugSerial.print(reg=hdc1080.readRegister().rawData,HEX);
|
||||||
if (reg!=0xff)
|
if (reg!=0xff)
|
||||||
{
|
{
|
||||||
debugSerial.print(" T=");
|
debugSerial.print(" T=");
|
||||||
debugSerial.print(t=hdc1080.readTemperature());
|
debugSerial.print(t=hdc1080.readTemperature());
|
||||||
debugSerial.print("C, RH=");
|
debugSerial.print(F("C, RH="));
|
||||||
debugSerial.print(h=hdc1080.readHumidity());
|
debugSerial.print(h=hdc1080.readHumidity());
|
||||||
debugSerial.println("%");
|
debugSerial.println("%");
|
||||||
|
|
||||||
@@ -126,6 +127,7 @@ if (reg!=0xff)
|
|||||||
}
|
}
|
||||||
else //ESP I2C glitch
|
else //ESP I2C glitch
|
||||||
{
|
{
|
||||||
|
debugSerial.println();
|
||||||
i2cReset();
|
i2cReset();
|
||||||
}
|
}
|
||||||
return INTERVAL_SLOW_POLLING;
|
return INTERVAL_SLOW_POLLING;
|
||||||
@@ -147,14 +149,14 @@ int in_ccs811::Poll(short cause)
|
|||||||
CCS811Core::status returnCode = ccs811.readAlgorithmResults();
|
CCS811Core::status returnCode = ccs811.readAlgorithmResults();
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
float co2,tvoc;
|
float co2,tvoc;
|
||||||
debugSerial.print(" CO2[");
|
debugSerial.print(F(" CO2["));
|
||||||
//Returns calculated CO2 reading
|
//Returns calculated CO2 reading
|
||||||
debugSerial.print(co2 = ccs811.getCO2());
|
debugSerial.print(co2 = ccs811.getCO2());
|
||||||
debugSerial.print("] tVOC[");
|
debugSerial.print(F("] tVOC["));
|
||||||
//Returns calculated TVOC reading
|
//Returns calculated TVOC reading
|
||||||
|
|
||||||
debugSerial.print(tvoc = ccs811.getTVOC());
|
debugSerial.print(tvoc = ccs811.getTVOC());
|
||||||
debugSerial.print("] baseline[");
|
debugSerial.print(F("] baseline["));
|
||||||
debugSerial.print(ccs811Baseline = ccs811.getBaseline());
|
debugSerial.print(ccs811Baseline = ccs811.getBaseline());
|
||||||
|
|
||||||
#ifdef M5STACK
|
#ifdef M5STACK
|
||||||
@@ -192,11 +194,11 @@ int in_ccs811::Poll(short cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void in_hdc1080::printSerialNumber() {
|
void in_hdc1080::printSerialNumber() {
|
||||||
debugSerial.print("Device Serial Number=");
|
infoSerial.print(F("Device Serial Number="));
|
||||||
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
|
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
|
||||||
char format[16];
|
char format[16];
|
||||||
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
|
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
|
||||||
debugSerial.println(format);
|
infoSerial.println(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printDriverError decodes the CCS811Core::status type and prints the
|
//printDriverError decodes the CCS811Core::status type and prints the
|
||||||
@@ -206,25 +208,26 @@ debugSerial.println(format);
|
|||||||
//to this function to see what the output was.
|
//to this function to see what the output was.
|
||||||
void in_ccs811::printDriverError( CCS811Core::status errorCode )
|
void in_ccs811::printDriverError( CCS811Core::status errorCode )
|
||||||
{
|
{
|
||||||
|
debugSerial.print(F("CCS811: "));
|
||||||
switch ( errorCode )
|
switch ( errorCode )
|
||||||
{
|
{
|
||||||
case CCS811Core::SENSOR_SUCCESS:
|
case CCS811Core::SENSOR_SUCCESS:
|
||||||
debugSerial.print("SUCCESS");
|
debugSerial.print(F("SUCCESS"));
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_ID_ERROR:
|
case CCS811Core::SENSOR_ID_ERROR:
|
||||||
debugSerial.print("ID_ERROR");
|
debugSerial.print(F("ID_ERROR"));
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_I2C_ERROR:
|
case CCS811Core::SENSOR_I2C_ERROR:
|
||||||
debugSerial.print("I2C_ERROR");
|
debugSerial.print(F("I2C_ERROR"));
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_INTERNAL_ERROR:
|
case CCS811Core::SENSOR_INTERNAL_ERROR:
|
||||||
debugSerial.print("INTERNAL_ERROR");
|
debugSerial.print(F("INTERNAL_ERROR"));
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_GENERIC_ERROR:
|
case CCS811Core::SENSOR_GENERIC_ERROR:
|
||||||
debugSerial.print("GENERIC_ERROR");
|
debugSerial.print(F("GENERIC_ERROR"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debugSerial.print("Unspecified error.");
|
debugSerial.print(F("Unspecified error."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,18 +239,18 @@ void in_ccs811::printSensorError()
|
|||||||
|
|
||||||
if ( error == 0xFF ) //comm error
|
if ( error == 0xFF ) //comm error
|
||||||
{
|
{
|
||||||
debugSerial.println("Failed to get ERROR_ID register.");
|
errorSerial.println(F("CCS811: Failed to get ERROR_ID register."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//debugSerial.print("");
|
if (error) errorSerial.print(F("CCS811: Error "));
|
||||||
if (error & 1 << 5) debugSerial.print("Error: HeaterSupply");
|
if (error & 1 << 5) errorSerial.print(F("HeaterSupply"));
|
||||||
if (error & 1 << 4) debugSerial.print("Error: HeaterFault");
|
if (error & 1 << 4) errorSerial.print(F("HeaterFault"));
|
||||||
if (error & 1 << 3) debugSerial.print("Error: MaxResistance");
|
if (error & 1 << 3) errorSerial.print(F("MaxResistance"));
|
||||||
if (error & 1 << 2) debugSerial.print("Error: MeasModeInvalid");
|
if (error & 1 << 2) errorSerial.print(F("MeasModeInvalid"));
|
||||||
if (error & 1 << 1) debugSerial.print("Error: ReadRegInvalid");
|
if (error & 1 << 1) errorSerial.print(F("ReadRegInvalid"));
|
||||||
if (error & 1 << 0) debugSerial.print("Error: MsgInvalid");
|
if (error & 1 << 0) errorSerial.print(F("MsgInvalid"));
|
||||||
debugSerial.println();
|
if (error) errorSerial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
#include "ClosedCube_HDC1080.h"
|
#include "ClosedCube_HDC1080.h"
|
||||||
#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811
|
#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811
|
||||||
|
|
||||||
|
//#ifndef I2C_CLOCK
|
||||||
|
//#define I2C_CLOCK 4000
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#define CCS811_ADDR 0x5B //Default I2C Address
|
//#define CCS811_ADDR 0x5B //Default I2C Address
|
||||||
#define CCS811_ADDR 0x5A //Alternate I2C Address
|
#define CCS811_ADDR 0x5A //Alternate I2C Address
|
||||||
|
|
||||||
@@ -28,13 +32,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined (__SAM3X8E__)
|
|
||||||
#define SCL_LOW() digitalWrite(21,LOW)
|
|
||||||
#define SCL_HIGH() digitalWrite(21,HIGH)
|
|
||||||
#define SCL_RESET
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (ARDUINO_ARCH_ESP32)
|
#if defined (ARDUINO_ARCH_ESP32)
|
||||||
#undef WAK_PIN
|
#undef WAK_PIN
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ e-mail anklimov@gmail.com
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "aJSON.h"
|
#include "aJSON.h"
|
||||||
//#include "twi.h"
|
|
||||||
|
|
||||||
extern aJsonObject *owArr;
|
extern aJsonObject *owArr;
|
||||||
extern uint32_t timerCtr;
|
//extern uint32_t timerCtr;
|
||||||
aJsonObject *dev2Check = NULL;
|
aJsonObject *dev2Check = NULL;
|
||||||
|
|
||||||
OneWire *oneWire = NULL;
|
OneWire *oneWire = NULL;
|
||||||
@@ -62,7 +61,7 @@ char * getReadableNote(aJsonObject * owObj)
|
|||||||
void processTemp(aJsonObject * owObj, float currentTemp) {
|
void processTemp(aJsonObject * owObj, float currentTemp) {
|
||||||
if (!owObj || !owArr) return;
|
if (!owObj || !owArr) return;
|
||||||
char* note = getReadableNote(owObj);
|
char* note = getReadableNote(owObj);
|
||||||
debugSerial<<endl<<F("1WT:")<<currentTemp<<F(" <")<<owObj->name<<F("> ");
|
debugSerial <<F("1WT:")<<currentTemp<<F(" <")<<owObj->name<<F("> ");
|
||||||
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
|
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
|
||||||
{
|
{
|
||||||
if (note) debugSerial<<note;
|
if (note) debugSerial<<note;
|
||||||
|
|||||||
Reference in New Issue
Block a user