diff --git a/code/espurna/config/all.h b/code/espurna/config/all.h index 15ba43e2..90d60d15 100644 --- a/code/espurna/config/all.h +++ b/code/espurna/config/all.h @@ -1,9 +1,9 @@ #include "version.h" #include "arduino.h" #include "hardware.h" +#include "prototypes.h" #include "general.h" #include "sensors.h" -#include "prototypes.h" #ifdef USE_CORE_VERSION_H #include "core_version.h" diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index b0e45134..ddd65dfe 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -659,28 +659,6 @@ PROGMEM const char* const custom_reset_string[] = { #endif -// ----------------------------------------------------------------------------- -// I2C -// ----------------------------------------------------------------------------- - -#ifndef I2C_SUPPORT -#define I2C_SUPPORT 1 // I2C enabled (1.98Kb) -#endif - -#define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire - -#ifndef I2C_SDA_PIN -#define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4) -#endif - -#ifndef I2C_SCL_PIN -#define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14) -#endif - -#define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time -#define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency -#define I2C_CLEAR_BUS 0 // Clear I2C bus at boot - // ----------------------------------------------------------------------------- // DOMOTICZ // ----------------------------------------------------------------------------- diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index 08e6befd..a3018c43 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -48,21 +48,28 @@ template bool setSetting(const String& key, unsigned int index, T va template String getSetting(const String& key, T defaultValue); template String getSetting(const String& key, unsigned int index, T defaultValue); +// ----------------------------------------------------------------------------- +// I2C +// ----------------------------------------------------------------------------- +unsigned char i2cFindFirst(size_t size, unsigned char * addresses); + +// ----------------------------------------------------------------------------- +// Debug +// ----------------------------------------------------------------------------- +void debugSend(const char * format, ...); +void debugSend_P(PGM_P format, ...); + // ----------------------------------------------------------------------------- // Domoticz // ----------------------------------------------------------------------------- -#if DOMOTICZ_SUPPORT template void domoticzSend(const char * key, T value); template void domoticzSend(const char * key, T nvalue, const char * svalue); -#endif // ----------------------------------------------------------------------------- // InfluxDB // ----------------------------------------------------------------------------- -#if INFLUXDB_SUPPORT template bool idbSend(const char * topic, T payload); template bool idbSend(const char * topic, unsigned char id, T payload); -#endif // ----------------------------------------------------------------------------- // Light diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index 9c094b26..fa0e6a35 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -97,7 +97,7 @@ #endif #ifndef BMX280_ADDRESS -#define BMX280_ADDRESS 0 +#define BMX280_ADDRESS 0x00 // 0x00 means auto #endif #define BMX280_MODE 1 // 1 for forced mode, 3 for normal mode @@ -105,6 +105,11 @@ #define BMX280_HUMIDITY 1 // Oversampling for humidity (set to 0 to disable magnitude, only for BME280) #define BMX280_PRESSURE 1 // Oversampling for pressure (set to 0 to disable magnitude) +#if BMX280_SUPPORT +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 +#endif + //-------------------------------------------------------------------------------- // Dallas OneWire temperature sensors // Enable support by passing DALLAS_SUPPORT=1 build flag @@ -185,7 +190,12 @@ #define EMON_ADC121_SUPPORT 0 // Do not build support by default #endif -#define EMON_ADC121_I2C_ADDRESS 0x50 // I2C address of the ADC121 +#define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto + +#if EMON_ADC121_SUPPORT +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 +#endif //-------------------------------------------------------------------------------- // Energy Monitor based on ADS1X15 @@ -196,11 +206,16 @@ #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default #endif -#define EMON_ADS1X15_I2C_ADDRESS 0x48 // I2C address of the ADS1115 +#define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115 #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A4=8 +#if EMON_ADS1X15_SUPPORT +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 +#endif + //-------------------------------------------------------------------------------- // Energy Monitor based on interval analog GPIO // Enable support by passing EMON_ANALOG_SUPPORT=1 build flag @@ -272,9 +287,36 @@ #endif #ifndef SI7021_ADDRESS -#define SI7021_ADDRESS 0x40 +#define SI7021_ADDRESS 0x00 // 0x00 means auto +#endif + +#if SI7021_SUPPORT +#undef I2C_SUPPORT +#define I2C_SUPPORT 1 #endif +// ----------------------------------------------------------------------------- +// I2C +// ----------------------------------------------------------------------------- + +#ifndef I2C_SUPPORT +#define I2C_SUPPORT 0 // I2C enabled (1.98Kb) +#endif + +#define I2C_USE_BRZO 0 // Use brzo_i2c library or standard Wire + +#ifndef I2C_SDA_PIN +#define I2C_SDA_PIN SDA // SDA GPIO (Sonoff => 4) +#endif + +#ifndef I2C_SCL_PIN +#define I2C_SCL_PIN SCL // SCL GPIO (Sonoff => 14) +#endif + +#define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time +#define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency +#define I2C_CLEAR_BUS 0 // Clear I2C bus at boot + //-------------------------------------------------------------------------------- // Internal power monitor // Enable support by passing ADC_VCC_ENABLED=1 build flag @@ -293,11 +335,6 @@ // Class loading //-------------------------------------------------------------------------------- -// Embarrasing... -unsigned char i2cFindFirst(size_t size, unsigned char * addresses); -void debugSend(const char * format, ...); -void debugSend_P(PGM_P format, ...); - #include "sensors/BaseSensor.h" #if ANALOG_SUPPORT