This is a quick guide on how to get the individual serial numbers of your DS18B20 1-wire temperature sensors.
This is handy for projects that require multiple sensors.
Things you need:
Temp Sensor DS18B20 - AliExpress - eBay
4.7k - 1/4w Resistor THT - AliExpress - eBay
Breadboard - AliExpress - eBay
Alternatively you can download the Library from here: https://github.com/milesburton/Arduino-Temperature...
This Library includes the OnWire Library.
Using a bread board connect +5V, GND and Digital Pin 2 (Pin 2 is already set in the example sketch) from the Arduino using Male to Male breadboard jumpers.
Connect the DS18B20 parallel to the 3x terminal strips on the breadboard.
For Normal Power Mode connect a 4.7K Resistor from +5V to Digital Pin 2 wire on the breadboard.
The following link is a great resource for the DS18B20 1-wire temperature sensor.
Once you have it wired up you are ready to load the Dallas Temperature "Single" Sketch
Open Arduino IDE (I am using 1.8.1)
Click "File" -> "Examples" -> "Dallas Temperature" -> "Single"
I added in delay(5000); on line 103 to give me time to copy the serial number
Select your appropriate board form "Tools" -> "Board"
Select your appropriate port "Tools" -> "Port"
Now "Upload" the Sketch "Sketch" -> "Upload"
Click "Tools" -> "Serial Monitor" make sure the baud rates match mine is 9600
If you sketch did not upload check your Board, Port, USB drivers etc.
From the "Serial Monitor" you will see the 4th line is "Device 0 Address: xxxxxxxxxxxxxxxx"
This is the Serial Number of the DS18B20
If it is "0000000000000000" then there is an issue reading your DS18B20.
Highlight it with your mouse and press CTRL+C on you keyboard then past it in Notepad
For my other projects my code uses an array of these numbers. I reformatted the HEX string to the following format.
DeviceAddress tempSensorSerial[9]= {
{0x28, 0xFF, 0x07, 0xA6, 0x70, 0x17, 0x04, 0xB5}, {0x28, 0xFF, 0xB2, 0xA6, 0x70, 0x17, 0x04, 0x28}, {0x28, 0xFF, 0x42, 0x98, 0x70, 0x17, 0x04, 0xD3}, {0x28, 0xFF, 0x86, 0xA8, 0x70, 0x17, 0x04, 0xA6}, {0x28, 0xFF, 0x2B, 0x65, 0x71, 0x17, 0x04, 0x76}, {0x28, 0xFF, 0x66, 0x62, 0x71, 0x17, 0x04, 0xF5}, {0x28, 0xFF, 0xD9, 0x9B, 0x70, 0x17, 0x04, 0x9C}, {0x28, 0xFF, 0x98, 0x6A, 0x71, 0x17, 0x04, 0xED}, {0x28, 0xFF, 0x99, 0x42, 0x71, 0x17, 0x04, 0x4C} };
Now you can identify each individual DS18B20 1-wire temperature sensor in your code and use a function like this:
float getTemperature(byte j)
{
sensors.requestTemperaturesByAddress(tempSensorSerial[j]);
float tempC = sensors.getTempC(tempSensorSerial[j]);
return tempC;
}
Check out my simple example sketch