ESP32 i2c driver not installed error


#1

trying to write some sensor code using i2c on ESP32 (Huzzah32) and get this error when executing:
E (15533) i2c: /tmp/tmp3w89rsqk/r2.1.1/common/vos/esp32-rtos/esp-idf-v3.0-rc1/components/driver/./i2c.c:1100 (i2c_master_cmd_begin):i2c driver not installed

Is this vm missing I2C0?

Tomm


#2

Hi @tomm,

I think you are probably skipping the start phase of the I2C initialization process: when you create an I2C object you should first create the instance, then start the driver.

obj = i2c.I2C(I2C0,addr=addr,clock=100000)
obj.start()

could you please confirm if my understanding is correct?
Thank you


#3

Yes, we solved it and you were correct. Thanks!

Blockquote

class PCA9538Expander(i2c.I2C):

def __init__(self, drvname=I2C0, addr=PCA9538_I2CADDR_A, clk=400000):
    # Initialize the I2C.
    i2c.I2C.__init__(self, drvname, addr, clk)
    try:
        self.start()
    except PeripheralError as e:
        print(e)
    print("Initialized")

Blockquote