This post may be interesting for all those willing to interface ADT7310 temperature sensor with RaspberryPi using Python script. That is actually quite simple to do, all you need is to use the means of standard SpiDev library. I won't go into the details on how to enable SPI and install SpiDev on RaspberryPi, there are a lot of posts covering these subjects in the Internet. Also some basic knowledge of Python and Bash is required. RPi B+ with Raspbian 4.1.6+ was used.
Preparation. Solder the ADT7310 sensor on some kind of a proto-board along with required capacitor and 2 resistors to monitor the state of CT and INT outputs. I've used a simple SOIC-8 adapter from RS.
How to make it work:
1) Connect ADT7310 to RPi SPI pins (DOUT to MISO, DIN to MOSI and SCLK to SCLK). 3.3V and GND can be also taken directly from the GPIOs grid (i.e. pin 17 - 3.3V and pin 25 - GND). Connect CSN to CE0.
2) Download the script in the attachment and run it with an argument specifying the operation mode (0 - continuous, 1 - one shot, 2 - SPS), i.e.:
> ./ADT7310.py 2
will start the sensor in the1-SPS mode
3) Look on the output, confirm that temperature is changing when you heat up/cool down the sensor. State of CT/INT can be monitored with an oscilloscope or multimeter.
4) Precc Ctrl+C to exit
So, what's implemented:
1) Reading temperature in all 3 modes - Continuous, One Shot and 1 SPS, results converted to Deg C
2) Reading Part ID and silicon revision
3) Reading and setting set-points (Critical, high and Low) and the hysteresis
4) Checking alarms in 13-bit mode
What's not implemented:
1) Checking alarms in 16-bit mode
2) Verification of CT and INT states via GPIOs
3) Negative temperature conversion for set-points
We're living in a strange world, so I have to say this (as everybody else does): The code in the attachment is provided as is, solely for educational purposes without any warranty for whatsoever. It can by copied/pasted/changed and so on under WTFPL conditions.
Don't hesitate to ask your questions or post your improvements, all comments are welcomed.