I am having problems with my i2c bus speed on a Raspberry Pi 4. My Sensor requires clock stretching, which I set according to [these instructions (https://pypi.org/project/scd30/)

When I check the bus typing $sudo i2cdetect -y 1 I see the following: i2cdetect zoomed out

enter image description here So first question is: why does the clock speed switch from 25ms to 10ms? The default speed should be 10ms, shouldn't it?

When I send commands over the i2c tools in the command line, the speed is 25ms $i2cset -y 1 0x61 0x01 0x04 i, but when I use a pythonscript the clock speed is 10ms :

from smbus2 import SMBus, i2c_msg

msg1 = i2c_msg.read(0x61, 18)
read_measurement = i2c_msg.write(0x61, [0x03, 0x00])
bus = SMBus(1)
bus.i2c_rdwr(read_measurement, msg1)
data1 = list(msg1)

Lowering the bus speed with dtparam=i2c_arm=on,i2c_arm_baudrate=50000 as described here has no effect on my bus speed.

My Problem is that my sensor gives me constant values for the measurements, which is probably due to a high clock speed (datasheet says 12ms is needed). Using ic2tools seems to achieve this with a clockstretch, but that doesn't work within the python script...

Any suggestions?

1 Answer 1


Set a slow I2C bus rate, e.g.


This will set a bus rate of 50 kbps (or 20 ms per bit in the slightly odd terms you appear to be using).

  • I already tried lower values (edited my post), it is not affecting the observed bus speed at all
    – shoj
    Aug 21, 2022 at 18:31
  • That is the problem then. You need to sort out the bus speed problem first. Are you using a non-standard OS?
    – joan
    Aug 21, 2022 at 18:54
  • I am using the latest 32bit version of raspbian.
    – shoj
    Aug 22, 2022 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.