Bus Pirate: DS28EA00 temperature sensor

From DP

Jump to: navigation , search


DS28EA00 Temperature Sensor

The DS28EA00 is a, 1-wire temperature sensor. It features selectable 9/10/11/12 bit resolution with a typical accuracy of ±0.5°c, alarm function and user-programmable upper and lower trigger points. Special to this sensor are the two io pins which can be used for sequence detection or as general IO. The GPIO pins can be used for sequence detection (in which order are the sensors connected on the 1-wire bus) or as general purpose io pins. The pins are only capable of sinking 20mA maximum, so when connecting for instance a led make sure the current limiting resistors are large enough to stay well below this maximum.


DS28EA00 bus pirate.jpg


Bus Pirate DS2EA00 (pin) Led
+3.3v, Vpullup Vdd (8)
+5.0v Annode led 1 and 2
PIOA (6) Cathode led1 (trough resistor)
PIOB (7) Cathode led2 (trough resistor)

DS28EA00 PIN S.png

Pull-up resistors are required, the Bus Pirate's on-board pull-ups are used. Ensure the Vpullup pin is connected to +v.

HiZ>m << Enter mode selection
1. HiZ
2. 1-WIRE
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. LCD
9. DIO
x. exit(without change)

(1)>2 << Select 1-WIRE
1WIRE routines (C) 2000 Michael Pearce GNU GPL
1-WIRE>W << Enable PSU
Power supplies ON
1-WIRE>P << Enable pull-ups
Pull-up resistors ON


To find the 1-wire address we used the Bus Pirate's 1-wire search address macro (0xF0).

1-WIRE>(0xF0) << Search macro
Macro 1WIRE address
1.0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD
*Unknown deviceDevice IDs are available by MACRO, see (0).

The address of the connected device has been assigned to the number 1 macro. So instead of typing the 7 byte hexadecimal address we can just use (1). In this demonstration we want to switch two leds on the output pins, because this is an unique feature of this one wire sensor. We will use the 1-wire match rom command 0x55 to select our device and then we use the 0xA5 'PIO access write' command to manipulate the pins.

1-WIRE>(0x55) (1) 0xA5 0x02 0xFD
MATCH ROM (0x55)

ADDRESS MACRO 1: 0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD

WRITE: 0x02

After this command the first led wil turn on. Now lets break this command line in to parts. (0x55) macro issues a bus reset and sends a Match rom command. The (1) macro is replaced by our devices address '0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD'. We then send a 0xA5 'PIO access write' command followed by two bytes with pin information. The second byte (0xFD) is the first byte inverted, this is a checksum to prevent transmission errors. Bit 0 is the PIOA control bit, Bit 1 is the PIOB control bit, the rest of the bits do not have a function. Sending a 0 wil put the output transistor in a conducting state (output switch to ground). To toggle the led 1 off and led 2 on we wil send the following command:

1-WIRE>{0x55 (1) 0xA5 0xFD 0x02
WRITE: 0x55
ADDRESS MACRO 1: 0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD

WRITE: 0x02

Instead of using the match rom macro we send a separate bus reset '{' and a match rom command '0x55'. Just to show that there are more ways to send commands.

As this is a temperature sensor the next thing we will do is get a temperature reading from the chip. This is done with the 'convert temperature' command 0x44. Two bytes with temperature data are then saved in the so called scratchpad memory of the chip. The first byte of the scratchpad is the least significant byte followed by the most significant byte. The temperature (degrees Celsius) is stored in 16 bit sign extended two's complement format.

1-WIRE>(0x55) (1) 0x44
MATCH ROM (0x55)

ADDRESS MACRO 1: 0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD

WRITE: 0x44

Reading of the scratchpad is done with the 'read scratchpad' command 0xBE. We also need to tell how many bytes we want to read. In this case we want the first two bytes.

1-WIRE>(0x55) (1) 0xbe r:2
MATCH ROM (0x55)

ADDRESS MACRO 1: 0x42 0xE7 0x92 0x03 0x00 0x00 0x00 0xAD

READ: 0x73 0x01

So the temperature is 0x0173 which is 371 in decimal notation. From the datasheet we can determine that we have to multiply by 0.0625 (85.0 Celsius = 0x0550 = 1360 -> 85/1360=0.0625) 371x0.0625=23.19 degree Celsius.