ESP32 has 2 I2C interfaces which is why you can choose 1 or 2.
You need to read the I2C page as you need to enable/disable drivers for I2C to prevent conflicts
Regards
Phil K
Sent from Mail for Windows
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/279afb1c-ee47-486a-923c-ae255888b12bn%40googlegroups.com.
When using the ESP32 with the Arduino IDE, use the Wire.h library to communicate with devices using I2C. With this library, you initialize the I2C as follows:
Wire.begin(I2C_SDA, I2C_SCL);So, you just need to set your desired SDA and SCL GPIOs on the I2C_SDA and I2C_SCL variables.
However, if you’re using libraries to communicate with those sensors, this might not work and it might be a bit tricky to select other pins. That happens because those libraries might overwrite your pins if you don’t pass your own Wire instance when initializing the library.
In those cases, you need to take a closer look at the .cpp library files and see how to pass your own TwoWire parameters.
For example, if you take a closer look at the Adafruit BME280 library, you’ll find out that you can pass your own TwoWire to the begin() method.
Devices with the same I²C-Address cannot be used on the same I²C-bus. So I suggest to implement the use of virtual I²C-buses in Tasmota. Only one common SCL-line/GPIO is needed for all I²C-buses. A SDA-line/GPIO has to be exclusive to a bus.
To be able to use the same device or different devices with the same I²C address multiple times I suggest a user-configurable table to assign libraries and I²C-addresses to buses.
e.g.
And when you connect the other device is its address the same? If it’s not the same it should work on one bus but you need to enable/disable the drivers – with some devices you can also change the address by a jumper on the board.
BMP280 can be wired as SPI too which would solve your problem anyway.
Only the ESP32 supports 2 x I2C natively and you just need to tell the GPIO which I2C it is.
Sent from Mail for Windows
From: Peggy Schafer
Sent: 24 January 2022 14:55
To: TasmotaUsers
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
15:47:41.694 CMD: i2cscan
15:47:41.724 RSL: RESULT = {"I2CScan":"Device(s) found at 0x76"}
Regarding you link to /docs/i2cdevices -
Both the sensors I'm using have drivers and if you read the very first post you will see that both devices do work as connected but not simultaneously.
I have since learned that support for 2 physical independent I2C buses was only recently added to Tasmota (and perhaps only for the ESP32 I'm not sure about that). The problem is that many device drivers are written to NOT be indexed for 2 buses. (or at least for more than 1 bus). Some people have modified existing drivers for certain devices to suit their own needs so that they will operate on the second bus.
On Monday, January 24, 2022 at 1:44:16 AM UTC-5 knowles...@gmail.com wrote:
It's just the internal mapping of the connection that is used in the templates
Have you run I2CScan as I suggested?
Have you also read this as I suggested?
From: sonof...@googlegroups.com <sonof..@googlegroups.com> on behalf of Peggy Schafer <peggyg...@gmail.com>
Sent: Monday, January 24, 2022 2:00:46 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
CMD: gpio 255
(edited to show only the active or defined pins)
RSL: RESULT = {"GPIO4":{"641":"I2C SDA2"},"GPIO5":{"609":"I2C SCL2"},"GPIO18":{"640":"I2C SDA1"},"GPIO23":{"608":"I2C SCL1"}
What do the numbers 641, 609, 640 and 608 represent or indicate?
On Sunday, January 23, 2022 at 1:25:55 AM UTC-5 knowles...@gmail.com wrote:
As I said several posts ago ESP32 has 2 I2C interfaces. Having said that PROVIDED that the I2C devices have DIFFERENT addresses you can have more devices on an ESP8266. The I2CScan will tell you the addresses. If they are different you then need to use I2CDriver to enable/disable drivers to get the devices to appear.
Phil K
From: Philip Knowles <knowles...@gmail.com>
Sent: Sunday, January 23, 2022 6:17:00 AM
To: Peggy Schafer <peggyg...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/57a3efff-ec69-4311-a7a9-c245ff345846n%40googlegroups.com.
The AHT10 address is 0x38 or 0x39 and the BMP280 address is 0x76 or 0x77 so they should work on the same bus.
So i2cdriver10 1 and i2cdriver43 1 should enable both drivers to work.
From: Peggy Schafer
Sent: 24 January 2022 14:55
To: TasmotaUsers
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
15:47:41.694 CMD: i2cscan
15:47:41.724 RSL: RESULT = {"I2CScan":"Device(s) found at 0x76"}
Regarding you link to /docs/i2cdevices -
Both the sensors I'm using have drivers and if you read the very first post you will see that both devices do work as connected but not simultaneously.
I have since learned that support for 2 physical independent I2C buses was only recently added to Tasmota (and perhaps only for the ESP32 I'm not sure about that). The problem is that many device drivers are written to NOT be indexed for 2 buses. (or at least for more than 1 bus). Some people have modified existing drivers for certain devices to suit their own needs so that they will operate on the second bus.
On Monday, January 24, 2022 at 1:44:16 AM UTC-5 knowles...@gmail.com wrote:
It's just the internal mapping of the connection that is used in the templates
Have you run I2CScan as I suggested?
Have you also read this as I suggested?
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Peggy Schafer <peggyg...@gmail.com>
Sent: Monday, January 24, 2022 2:00:46 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
CMD: gpio 255
(edited to show only the active or defined pins)
RSL: RESULT = {"GPIO4":{"641":"I2C SDA2"},"GPIO5":{"609":"I2C SCL2"},"GPIO18":{"640":"I2C SDA1"},"GPIO23":{"608":"I2C SCL1"}
What do the numbers 641, 609, 640 and 608 represent or indicate?
On Sunday, January 23, 2022 at 1:25:55 AM UTC-5 knowles...@gmail.com wrote:
As I said several posts ago ESP32 has 2 I2C interfaces. Having said that PROVIDED that the I2C devices have DIFFERENT addresses you can have more devices on an ESP8266. The I2CScan will tell you the addresses. If they are different you then need to use I2CDriver to enable/disable drivers to get the devices to appear.
Phil K
From: Philip Knowles <knowles...@gmail.com>
Sent: Sunday, January 23, 2022 6:17:00 AM
To: Peggy Schafer <peggyg...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: How to enable 2 I2C devices each one using their own GPIO lines?
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/57a3efff-ec69-4311-a7a9-c245ff345846n%40googlegroups.com.