Beaglebone and DS1624 temperature sensor in python

0
136

In this article we look at another sensor – this time its the DS1624 and we will connect it to our Beaglebone and we will have a python example

First lets take a look at the sensor in question

The DS1624 consists of two separate functional units: a 256-byte nonvolatile E2 memory and a direct-to-digital temperature sensor.

The nonvolatile memory is made up of 256 bytes of E2 memory. This memory can be used to store any type of information the user wishes. These memory locations are accessed through the 2-wire serial bus.

The direct-to-digital temperature sensor allows the DS1624 to measure the ambient temperature and report the temperature in a 12-bit word with 0.0625°C resolution. The temperature sensor and its related registers are accessed through the 2-wire serial interface. Figure 1 in the full data sheet shows a block diagram of the DS1624.

Features

Reduces Component Count with Integrated Temperature Sensor and Nonvolatile E2 Memory
Measures Temperatures from -55°C to +125°C in 0.0625°C Increments
±0.5°C Accuracy from 0°C to 70°C
256 Bytes of E2 Memory for Storing Information Such as Frequency Compensation Coefficients
No External Components
Easy-to-Use 2-Wire Serial Interface
Temperature is Read as a 12-Bit Value (2-Byte Transfer)
Available in 8-Pin SO and DIP Packages

 

Parts Required

NameLink
BeagleboneBeagleBone Black TI AM335x Cortex-A8 development BB-Black Rev.C
DS1624SMAKN DS1624Digital Thermometer Module,High Precision with Storage Function
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

BeagleboneModule
3.3v – P9.3Vcc
Gnd – P9.1Gnd
SDA – P9.20SDA
SCL – P9.19SCL

 

Code Example

Save this as ds1624.py

import smbus
import time
 
# Get I2C bus
bus = smbus.SMBus(2)
 
DS1624_READ_TEMP = 0xAA
DS1624_START = 0xEE
DS1624_STOP = 0x22
DS1624_MEMORY = 0xAC
DS1624_CONFIG = 0x17
DS1624_ADDRESS = 0x48
 
 
bus.write_byte(DS1624_ADDRESS, DS1624_START);
bus.write_byte(DS1624_ADDRESS, DS1624_STOP);
bus.read_word_data(DS1624_ADDRESS, DS1624_READ_TEMP)        
 
time.sleep(1)    
 
raw = bus.read_word_data(DS1624_ADDRESS, DS1624_READ_TEMP)
temp_integer = raw & 0x00FF
#if temp_integer > 127:
#   temp_integer = temp_integer - 256
#   temp_fractional = (raw >> 12) * 0.0625
#   temp_integer = raw & 0x00FF
 
temp_fractional = ((raw & 0xFF00) >> 8) >> 3
 
temp = temp_integer + ( 0.03125 * temp_fractional)
 
 
print ("1624: %02.02fC" % temp)
time.sleep(1)

Output

Run this example and you should see the following.

debian@beaglebone:/var/lib/cloud9/$ python DS1624.py
1624: 23.03C
debian@beaglebone:/var/lib/cloud9/$ python DS1624.py
1624: 22.88C
debian@beaglebone:/var/lib/cloud9/$ python DS1624.py
1624: 22.75C

Links

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.