I2C pullups

Ok all the Dev boards that I have used have had internal pullups on the I2C lines (usually on the chip that drives them so it can be driven by software)

I just measured the voltage on the I2C pins when I ran a script that created a I2C bus and the I2C lines stayed low, I assume this means there isn’t any internal pullups on the OpenMV board and for I2C they have to be connected externally???

You have to enable pull ups on the pins using the PIN object. There aren’t any pull ups externally. This is because the STM32 chips can pull pins high and low.

Just so I understand everything properly.

In your example i2c_control1.py you use the code

from pyb import I2C

i2c = I2C(2, I2C.MASTER) # The i2c bus must always be 2.
mem = i2c.mem_read(256, 0x50, 0) # The eeprom slave address is 0x50.

But nowhere do you use the Pin class to set the SDA and SCL lines as pullups. R you relying on external pullsups pullups??

I asked on the official MicroPython forum about the I2C pullups for the pyboard and they said they are not done by the software but rather the pyboard has external pullups on the PCB. This is different to all the other ports of micropython that I have used where there isn’t any external pullups and they are done in software automatically by the machine.I2C class.

If your using the official micro-python port without any modification to the pyb.I2C class or machine.I2C class or any external pullups on the PCB then this means the user will have ensure that there is pullups on the other device.

That code does not turn pull ups on. On our I2C boards we add pull ups. On the camera we don’t. If you’d like to turn pull ups on in software then make a pin object and set pull ups on when you make it. The pin object will modify some regs in hardware that I2C will just silently benefit from. It won’t disable them.

Thank you :slight_smile:

I want to add my own pullups anyway as want to use 82K pullups instead of 10K.

But now I know the difference in running my MicroPython script on OpenMV compared to other boards running MicroPython. For OpemMv you have to change your script to add turning on pullups or use external pullups :slight_smile:

Maybe you need to add the I2C class docs http://docs.openmv.io/library/pyb.I2C.html that no pullups are provided on the OpenMV cam and users need make sure there is pullups on any I2C devices they connect to the bus.

Send a github PR?

We need the documentation help.

Ok I will see if I can do my very first ever PR on github :slight_smile: