Can I configure I2C frequency?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

Can I configure I2C frequency?

Post by water » Thu Jun 24, 2021 9:54 pm

In my memory old version of MicroPython (I forgot which version), I2C can configure frequency likes

Code: Select all

freq = 400000
,
but I can't do that in current version:

Code: Select all

i2c = machine.SoftI2C(scl = Pin(5), sda = Pin(4), freq = 400000)

Code: Select all

i2c
SoftI2C(scl=5, sda=4, freq=500000)

Code: Select all

i2c = SoftI2C(scl = Pin(5), sda = Pin(4), freq = 1000000)

Code: Select all

i2c
SoftI2C(scl=5, sda=4, freq=500000)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Can I configure I2C frequency?

Post by Roberthh » Fri Jun 25, 2021 6:59 am

Indeed. I can set it to 100_000, but not to 400_000. The way the frequency is set is by dividing 500_000 by an integer, with 1 as the smallest value. Therefore, resultingl values are 500_000, 250_000, 166_000, 125_000, ......

Post Reply