[Basic I2C]
circuitcrush.com/i2c-tutorial/
[ESP32 default I2C]
ESP32 晶片原本有 2 組 I2C 介面, 它的 Arduino Core 預設支援一組I2C, IO21為SDA, IO22為SCL, 要注意的是:3.3V LCD
https://ghostyguo.pixnet.net/blog/post/314586685-esp32-%E4%BD%BF%E7%94%A8-i2c-lcd
[Single I2C]
https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/
[ x2 I2C]
https://github.com/espressif/arduino-esp32/issues/977
commented on 15 Feb 2018
/* I2C slave Address Scanner
for 5V bus * Connect a 4.7k resistor between SDA and Vcc * Connect a 4.7k resistor between SCL and Vcc for 3.3V bus * Connect a 2.4k resistor between SDA and Vcc * Connect a 2.4k resistor between SCL and Vcc Kutscher07: Modified for TTGO TQ board with builtin OLED */ #include <Wire.h> #include <dummy.h> //for esp32 #define SDA1 21 #define SCL1 22 #define SDA2 5 #define SCL2 4 TwoWire I2Cone = TwoWire(0); TwoWire I2Ctwo = TwoWire(1); void scan1(){ Serial.println("Scanning I2C Addresses Channel 1"); uint8_t cnt=0; for(uint8_t i=0;i<128;i++){ I2Cone.beginTransmission(i); uint8_t ec=I2Cone.endTransmission(true); if(ec==0){ if(i<16)Serial.print('0'); Serial.print(i,HEX); cnt++; } else Serial.print(".."); Serial.print(' '); if ((i&0x0f)==0x0f)Serial.println(); } Serial.print("Scan Completed, "); Serial.print(cnt); Serial.println(" I2C Devices found."); } void scan2(){ Serial.println("Scanning I2C Addresses Channel 2"); uint8_t cnt=0; for(uint8_t i=0;i<128;i++){ I2Ctwo.beginTransmission(i); uint8_t ec=I2Ctwo.endTransmission(true); if(ec==0){ if(i<16)Serial.print('0'); Serial.print(i,HEX); cnt++; } else Serial.print(".."); Serial.print(' '); if ((i&0x0f)==0x0f)Serial.println(); } Serial.print("Scan Completed, "); Serial.print(cnt); Serial.println(" I2C Devices found."); } void setup(){ Serial.begin(115200); I2Cone.begin(SDA1,SCL1,400000); // SDA pin 21, SCL pin 22 TTGO TQ I2Ctwo.begin(SDA2,SCL2,400000); // SDA pin 5, SCL pin 4 builtin OLED } void loop(){ scan1(); Serial.println(); delay(100); scan2(); Serial.println(); delay(5000); }
[多組I2C OLED ]
Good! There are codes https://github.com/bitbank2/Multi_OLED master.zip <download
[多組I2C OLED 討論]
[多組I2C OLED youtube]
tobozo tagada: All displays have the same I2C address, the multiplexer takes care of addressing them separately and in sequence.
TCA9548ATCA9548A
[多組I2C Devices]
[任何引腳設置為具有I2C功能]
沒有留言:
張貼留言