Skip to main content
Topic: I2C thermometer DS1631 Python interface + pyBusPirateLite patch (Read 5903 times) previous topic - next topic

I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Hi there,

I have created a python script to interface Maxim's DS1631 I2C thermometer using binary mode and pyBusPirateLite library. I noticed that binary I2C mode using I2C module is very very slow, mainly due to a mistake in BitBang.py function bulk_trans where (byte_count+2) instead of (byte_count+1) is requested as reply from BP. This leads to waiting for serial timeout (by default one second).

I also figured out that sending twenty zeroes in a row to a BP, which is already in binary mode leads into strange result where BP gets stuck in BitBang mode, and has to be power-cycled, so I rewritten BBmode function to send only as much zeroes as needed.

For high-level I2C communication with the thermometer and similar I2C devices like EEPROMS, RTC, etc... I included a library I2Chigh, implementing getters and setters for byte and word values using common I2C protocol.

I am attaching patch to current svn trunk and also sample script to read themperature from two DS1631 thermometers.

Cheers,
Ondrej Caletka

Re: I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Reply #1
Thanks Ondrej,

I'll apply the patch and add the script to SVN.

There is a new write/read command for I2C that might be even easier and faster:
http://dangerousprototypes.com/docs/I2C ... _then_read
Got a question? Please ask in the forum for the fastest answers.

Re: I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Reply #2
Hi again,

I applied the patch and commited everything to svn. Thanks!
Got a question? Please ask in the forum for the fastest answers.

Re: I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Reply #3
Thanks Ian from committing it.

And also thanks for noticing the new command write then read.

Re: I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Reply #4
Hi, as weather out there started getting cold, I realised that my library doesn't correctly work with negative temperatures, so here is updated version.

Re: I2C thermometer DS1631 Python interface + pyBusPirateLite patch

Reply #5
Thanks! I updated the version in SVN.
Got a question? Please ask in the forum for the fastest answers.