1

If running standard release of debian on my Rpi. How fast can I sample the sensor readings through i2c and save values?

Why Im asking, I tried to read a DS18B20 and save it,s values (wrote the program in python) running xwin and it seems to be very slow.

Right now Im just samplig every 5th second. If I want to measure power readings (AC), they should be done much faster.

Will a C compiled code run much faster?

Kind Regards

  • 3
    DS18B20 is a 1-wire interface, not i2c – John La Rooy Sep 13 '12 at 21:48
  • You could post your python code so we can see what exactly it is doing. It probably waits for sensor to be ready since it takes some time for DS18B20 before you can read temperature value. – Krzysztof Adamski Sep 14 '12 at 8:12
  • The question is about i2c! My experience is with a DS18B20 with a bit banging process in the kernel (Occidentalis release). Yes, I made my python program not to accept the new value if the CRC check wherent ok. So that loop could take some extra time. – Christian Sep 14 '12 at 23:16
  • Here is speed a comparison of C and Python: link – ikku Sep 20 '12 at 20:48
  • But you want to measure the voltage on a high enough frequency to create a nice sinus? Or you (also) want to measure the current to calculate some dissipation? – ikku Sep 20 '12 at 20:58
2

DS18B20 is OneWire Interface which was mentioned before. As documentation states with maximal accuruacy You can sample not faster than every 750ms + if you use multiple devices on one "bus" You have to count additional time to query device with specified serial number.

Of course You can use i2c to poke 1w devices, but it's a waste as it is not much more complicated by simply toggling standard gpio or easiest way - using kernel module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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