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:
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)
print(data1)
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?