From 538d40ab72a6145d5510daffda50df9504656123 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 8 Nov 2019 17:48:19 +0100 Subject: [PATCH] Change default I2C address ranges * Change supported PCF8574 I2C address range to 0x20 - 0x26 allowing other I2C devices with address 0x27 to be used at the same time * Change supported PCF8574A I2C address range to 0x39 - 0x3F allowing other I2C devices with address 0x38 to be used at the same time * Change supported MCP230xx I2C address range to 0x20 - 0x26 allowing other I2C devices with address 0x27 to be used at the same time --- I2CDEVICES.md | 8 ++++---- RELEASENOTES.md | 2 +- tasmota/_changelog.ino | 3 +++ tasmota/my_user_config.h | 4 ++-- tasmota/tasmota_post.h | 4 ++-- tasmota/xdrv_28_pcf8574.ino | 13 +++++++------ tasmota/xsns_29_mcp230xx.ino | 2 +- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 6358280ed..5e2526e57 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -12,8 +12,8 @@ The following table lists the supported I2C devices Index | Define | Driver | Device | Address(es) | Description ------|---------------------|---------|----------|-------------|----------------------------------------------- 1 | USE_PCA9685 | xdrv_15 | PCA9685 | 0x40 - 0x47 | 16-channel 12-bit pwm driver - 2 | USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x27 | 8-bit I/O expander - 2 | USE_PCF8574 | xdrv_28 | PCF8574A | 0x38 - 0x3F | 8-bit I/O expander + 2 | USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x26 | 8-bit I/O expander + 2 | USE_PCF8574 | xdrv_28 | PCF8574A | 0x39 - 0x3F | 8-bit I/O expander 3 | USE_DISPLAY_LCD | xdsp_01 | | 0x27, 0x3F | LCD display 4 | USE_DISPLAY_SSD1306 | xdsp_02 | SSD1306 | 0x3C - 0x3D | Oled display 5 | USE_DISPLAY_MATRIX | xdsp_03 | HT16K33 | 0x70 - 0x77 | 8x8 led matrix @@ -44,8 +44,8 @@ Index | Define | Driver | Device | Address(es) | Description 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Ultra violet index and light sensor 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Temperature sensor 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | Proximity ambient light RGB and gesture sensor - 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x27 | 16-bit I/O expander - 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x27 | 16-bit I/O expander + 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | 16-bit I/O expander + 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x26 | 16-bit I/O expander 23 | USE_MPR121 | xsns_30 | MPR121 | 0x5A - 0x5D | Proximity capacitive touch sensor 24 | USE_CCS811 | xsns_31 | CCS811 | 0x5A | Gas (TVOC) and air quality sensor 25 | USE_MPU6050 | xsns_32 | MPU6050 | 0x68 - 0x69 | 3-axis gyroscope and temperature sensor diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f7554a990..2a34e5fca 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -220,7 +220,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c | USE_CHIRP | - | - | - | - | - | - | - | | USE_PAJ7620 | - | - | - | - | - | - | - | | USE_PCF8574 | - | - | - | - | - | - | - | -| USE_HIH6 | - | - | - | - | - | - | - | +| USE_HIH6 | - | - | - | - | x | - | - | | | | | | | | | | | Feature or Sensor | minimal | basic | tasmota | knx | sensors | ir | display | Remarks | USE_SPI | - | - | - | - | - | - | x | diff --git a/tasmota/_changelog.ino b/tasmota/_changelog.ino index 4cc3a85ef..e715dd96b 100644 --- a/tasmota/_changelog.ino +++ b/tasmota/_changelog.ino @@ -1,6 +1,9 @@ /*********************************************************************************************\ * 7.0.0.4 20191108 * Add command WifiPower 0 .. 20.5 to set Wifi Output Power which will be default set to 17dB + * Change supported PCF8574 I2C address range to 0x20 - 0x26 allowing other I2C devices with address 0x27 to be used at the same time + * Change supported PCF8574A I2C address range to 0x39 - 0x3F allowing other I2C devices with address 0x38 to be used at the same time + * Change supported MCP230xx I2C address range to 0x20 - 0x26 allowing other I2C devices with address 0x27 to be used at the same time * * 7.0.0.3 20191103 * Initial support for I2C driver runtime control using command I2CDriver and document I2CDEVICES.md diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 7a72693d8..626283ecc 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -391,7 +391,7 @@ #define USE_LM75AD // Enable LM75AD sensor (I2C addresses 0x48 - 0x4F) (+0k5 code) // #define USE_APDS9960 // Enable APDS9960 Proximity Sensor (I2C address 0x39). Disables SHT and VEML6070 (+4k7 code) // #define USE_MCP230xx // Enable MCP23008/MCP23017 - Must define I2C Address in #define USE_MCP230xx_ADDR below - range 0x20 - 0x27 (+4k7 code) -// #define USE_MCP230xx_ADDR 0x20 // Enable MCP23008/MCP23017 I2C Address to use (Must be within range 0x20 through 0x27 - set according to your wired setup) +// #define USE_MCP230xx_ADDR 0x20 // Enable MCP23008/MCP23017 I2C Address to use (Must be within range 0x20 through 0x26 - set according to your wired setup) // #define USE_MCP230xx_OUTPUT // Enable MCP23008/MCP23017 OUTPUT support through sensor29 commands (+1k5 code) // #define USE_MCP230xx_DISPLAYOUTPUT // Enable MCP23008/MCP23017 to display state of OUTPUT pins on Web UI (+0k2 code) // #define USE_PCA9685 // Enable PCA9685 I2C HW PWM Driver - Must define I2C Address in #define USE_PCA9685_ADDR below - range 0x40 - 0x47 (+1k4 code) @@ -412,7 +412,7 @@ // #define USE_MLX90614 // Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) // #define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) // #define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code) -// #define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code) +// #define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x26 and 0x39 - 0x3F) (+1k9 code) // #define USE_HIH6 // Enable Honeywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6) // #define USE_DISPLAY // Add I2C Display Support (+2k code) diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index 964b2cb8f..a11938fd6 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -155,8 +155,8 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c //#define USE_MLX90614 // Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) //#define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) //#define USE_PAJ7620 // Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code) -//#define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x27 and 0x38 - 0x3F) (+1k9 code) -//#define USE_HIH6 // Enable Honywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6) +//#define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x26 and 0x39 - 0x3F) (+1k9 code) +#define USE_HIH6 // Enable Honywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6) #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) diff --git a/tasmota/xdrv_28_pcf8574.ino b/tasmota/xdrv_28_pcf8574.ino index 0be5b6c71..d8e2daaef 100644 --- a/tasmota/xdrv_28_pcf8574.ino +++ b/tasmota/xdrv_28_pcf8574.ino @@ -22,7 +22,8 @@ /*********************************************************************************************\ * PCF8574 - I2C IO Expander * - * I2C Address: PCF8574 = 0x20 .. 0x27, PCF8574A = 0x38 .. 0x3F + * I2C Address: PCF8574 = 0x20 .. 0x27 (0x27 is not supported), + * PCF8574A = 0x39 .. 0x3F (0x38 is not supported) \*********************************************************************************************/ #define XDRV_28 28 @@ -76,7 +77,7 @@ void Pcf8574Init() Pcf8574.type = false; uint8_t pcf8574_address = PCF8574_ADDR1; - for (uint32_t i = 0; i < MAX_PCF8574; i++) { + while ((Pcf8574.max_devices < MAX_PCF8574) && (pcf8574_address < PCF8574_ADDR2 +8)) { // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PCF: Probing addr: 0x%x for PCF8574"), pcf8574_address); @@ -92,13 +93,13 @@ void Pcf8574Init() } AddLog_P2(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, Pcf8574.stype, pcf8574_address); } + pcf8574_address++; - if ((PCF8574_ADDR1 + 8) == pcf8574_address) { - pcf8574_address = PCF8574_ADDR2; - i=0; + if ((PCF8574_ADDR1 +7) == pcf8574_address) { // Support I2C addresses 0x20 to 0x26 and 0x39 to 0x3F + pcf8574_address = PCF8574_ADDR2 +1; } } - if (Pcf8574.max_devices) { + if (Pcf8574.type) { for (uint32_t i = 0; i < sizeof(Pcf8574.pin); i++) { Pcf8574.pin[i] = 99; } diff --git a/tasmota/xsns_29_mcp230xx.ino b/tasmota/xsns_29_mcp230xx.ino index c1dfa2c88..d74fdd5a4 100644 --- a/tasmota/xsns_29_mcp230xx.ino +++ b/tasmota/xsns_29_mcp230xx.ino @@ -25,7 +25,7 @@ Docs at https://www.microchip.com/wwwproducts/en/MCP23008 https://www.microchip.com/wwwproducts/en/MCP23017 - I2C Address: 0x20 - 0x27 + I2C Address: 0x20 - 0x26 (0x27 is not supported) \*********************************************************************************************/ #define XSNS_29 29