[Resolved] TwoWire _wire = TwoWire(1); causing NULL TX buffer pointer error

Microsoft Windows 11 Version 22H2 (OS Build 22621.4249)
PlatformIO Core 6.1.16·Home 3.4.4 ( airm2m_core_esp32c3 board selected )
ESP32-C3
Zadig 2.9 (Build 788)
FTDI driver CDM212364_Setup

The instruction of TwoWire(1) caused error message below at the line of .beginTransmission():

[ 89][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer

The code:

void scan (void)
{
    Serial.println("Scanning for I2C devices...");
    for( uint8_t address = 1; address < 127; address++ ) 
	{
    _wire.beginTransmission(address);
    uint8_t error = _wire.endTransmission();
    if( error == 0 ) 
	{
    Serial.print("I2C device found at address 0x");
    if (address < 16) Serial.print("0");
    Serial.println(address, HEX);
    }
    }
    Serial.println("I2C scan complete.");	
}

However, if I specify as “TwoWire _wire = TwoWire(0);” then no error, able to detect the I2C device address.

Please advise.

What happens if you use the already existing Wire object like the WireScan example does?

using Wire. is fine as TwoWire(0), the TwoWire(1) created the error mentioned.

The ESP32 has two I2C interfaces, but the ESP32-C3 has only one of them.

ESP32 datasheet | page 4 | Advanced Peripheral Interfaces
ESP32-C3 datasheet | page 4 | Advanced Peripheral Interfaces

1 Like