Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
crackerjack Senior Member Joined: 11/07/2011 Location: AustraliaPosts: 164
Posted: 03:33pm 27 Sep 2011
Copy link to clipboard
Print this post
Not an earth-shattering post by any means, but just a little program to demonstrate using the MM to obtain a temperature from a DS1621 via I2C. It may prove of interest to somebody - particularly if you compare trying to do the same thing in C or on an Arduino which would be many lines of code plus libraries. On the MM it can be done in very few lines.
The code posted below could have been made a whole lot shorter, but I've made it a bit verbose on purpose as a bit of a tutorial. The DS1621 command values and config register settings are defined as variables, but could easily just be literals.
I have also included a trace of the I2C bus activity of a single temperature "transaction" for those who may want to follow the steps of the I2C commands from the MM.
Note that in the example given the DS1621 was wired at address &H48 (all three address input pins at ground). Alternate address config would of course require changing the value of ds1621_addr at line 50.
Hope this is of some use to somebody, somewhere...