I2C baudrate oddity?

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
User avatar
Posts: 6
Joined: Wed Jun 03, 2015 4:24 pm

I2C baudrate oddity?

Post by r4space » Mon Jun 20, 2016 1:00 am


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
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)

running above will output:
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)



Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: I2C baudrate oddity?

Post by Niallp » Thu Jun 23, 2016 3:38 pm

9600 seems like a very slow clock rate for I2C, is this an asynchronous (ie RS232) device ? I suppose there is probably an I2C UART that will do the job for you but I suspect you weren't intending that ...

... Niall

User avatar
Posts: 3301
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada

Re: I2C baudrate oddity?

Post by dhylands » Thu Jun 23, 2016 4:31 pm

100k, 400k, and 1M are common I2C baudrates. 9600 is definitely not. I wouldn't be surprised to find out that trying to use 9600 doesn't work.

Post Reply