I'm trying to set the baudrate to 9600 as past experience with my sensor (CO2meter K33) says that's best but when initiating the i2c it always changes that to 50000 - huh?
Code: Select all
from machine import Pin
from machine import I2C
#Set alternate ode on pins
#GP23=I2C0_SCL[9]
#GP24=I2C0_SDA[9]
scl=Pin('GP23',mode=Pin.ALT, alt=9)
sda=Pin('GP24',mode=Pin.ALT, alt=9)
i2c_pins=(sda, scl)
i2c = I2C(I2C.MASTER, baudrate=9600, pins=i2c_pins)
addr=i2c.scan()[0]
i2c
I2C(0, I2C.MASTER, baudrate=50000)
Why does it change it to 50000? And if this is the slowest it can run any suggestions?
Running the following commands (any of them, in any order) sometimes gets a response but more often gets:
"OSError: the requested operation failed"
The write commands works more often than read.
Code: Select all
i2c.writeto_mem(addr,208 ,s2)
i2c.readfrom_mem_into(addr,208,buf)
i2c.readfrom_mem(0x64,2,2)