Playing with the DS18B20 1-Wire Digital Thermometer required a bit of research. One could make a career out of this one chip.
The TO-92 chip sits in the 3 machined sockets U5 closest to J1 jumper. J1 feeds 5v to a 10k resistor R5 and the centre pin DQ.
The silkscreen layout is correct with the flat side facing the bottom side of the board towards the 3 pushbuttons.
The designation "U5-18b20-LM35-A4" has an arrow pointing up toward the centre DQ data pin. Gnd on the left, +5 on the right. DQ data is on pin A4.
"Each DS18B20 contains a unique 64–bit code stored in ROM. The least significant 8 bits
of the ROM code contain the DS18B20’s 1-Wire family code: 28h. The next 48 bits contain a unique
serial number. The most significant 8 bits contain a cyclic redundancy check (CRC) byte that is
calculated from the first 56 bits of the ROM code." The serial monitor output is shown below: R= 28 is the family code.
Byte 0 and byte 1 of the scratchpad contain the LSB and the MSB of the temperature register respectively.
P= 01 A2 is 0x01A2 = 418 decimal x 0.0625 = 26.125 degrees C, increases to 0x01A3 on the next sample.
Sample Monitor Dump:
R= 28 32 6A B9 05 00 00 06 Device is a DS18B20 family device.
P= 01 A2 01 4B 46 7F FF 0E 10 D8 CRC=D8
No more addresses.
R= 28 32 6A B9 05 00 00 06 Device is a DS18B20 family device.
P= 01 A3 01 4B 46 7F FF 0D 10 CE CRC=CE
No more addresses.
Four of my devices (out of a possible 127)
in parallel shows unique serial numbers and temperatures within 3 units:
R= 28 32 6A B9 05 00 00 06 Device is a DS18B20 family device.
P= 01 8E 01 4B 46 7F FF 02 10 02 CRC=2
R= 28 8A 84 B9 05 00 00 D8 Device is a DS18B20 family device.
P= 01 90 01 4B 46 7F FF 10 10 92 CRC=92
R= 28 89 5D B9 05 00 00 2C Device is a DS18B20 family device.
P= 01 8F 01 4B 46 7F FF 01 10 14 CRC=14
R= 28 1F 5E B9 05 00 00 61 Device is a DS18B20 family device.
P= 01 8E 01 4B 46 7F FF 02 10 02 CRC=2
No more addresses.
The latest version of the OneWire library is on Paul Stoffregen's site.
http://www.pjrc.com/teensy/td_libs_OneWire.html
Code taken from
http://playground.arduino.cc/Learning/OneWire
Code: Select all
//Start of Arduino Code modified by barewires 15062014
#include <OneWire.h>
// DS18B20 Temperature chip i/o
OneWire ds(18); // on pin A4
void setup(void) {
// initialize inputs/outputs
// start serial port
Serial.begin(9600);
}
void loop(void) {
byte i;
byte present = 0;
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
Serial.print("No more addresses.\n");
ds.reset_search();
return;
}
Serial.print("R= ");
for( i = 0; i < 8; i++) {
if (addr[i] <16)
{
Serial.print("0");
}
Serial.print(addr[i], HEX);
Serial.print(" ");
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}
if ( addr[0] == 0x10) {
Serial.print(" Device is a DS18S20 family device.\n");
}
else if ( addr[0] == 0x28) {
Serial.print(" Device is a DS18B20 family device.\n");
}
else {
Serial.print(" Device family is not recognized: 0x");
Serial.println(addr[0],HEX);
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
Serial.print("P= ");
if (present <16)
{
Serial.print("0");
}
Serial.print(present,HEX);
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
if (data[i] <16)
{
Serial.print("0");
}
Serial.print(data[i], HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print( OneWire::crc8( data, 8), HEX);
Serial.println();
}