mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-06 16:27:12 +01:00
ONly add support for I2C if required, set all I2C sensors to auto-discover
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -48,21 +48,28 @@ template<typename T> bool setSetting(const String& key, unsigned int index, T va
|
||||
template<typename T> String getSetting(const String& key, T defaultValue);
|
||||
template<typename T> 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<typename T> void domoticzSend(const char * key, T value);
|
||||
template<typename T> void domoticzSend(const char * key, T nvalue, const char * svalue);
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// InfluxDB
|
||||
// -----------------------------------------------------------------------------
|
||||
#if INFLUXDB_SUPPORT
|
||||
template<typename T> bool idbSend(const char * topic, T payload);
|
||||
template<typename T> bool idbSend(const char * topic, unsigned char id, T payload);
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Light
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user