Go Down

Topic: 1-wire sensor network with multiple DS18B20 .... need som input/help (Read 2399 times) previous topic - next topic



I'm planning on making an multi channel temperature monitor based on an Arduino, perhaps a pro mini, and a 1-wire bus with DS18B20 temperatur sensors.

I contemplates using 3.5mm stereo jack plugs as external connections, one for each "channel" (sensor), is there a way to make the Arduino determin which sensor adress is connected to which "channel" (jack socket) so that I don't have to manually set up the system to know what each measurement represents.

Best regards
Just finding my place in the wonderfull world of Arduino


Each sensor has a unique ID that can be read from the device.  You could read this number and integrate it into the system each time you acquire/assign a new sensor.  Internally, all the sensors could be on the same electrical 1-wire bus so it didn't matter which connector a sensor got plugged into.  You then specifically address the sensor that you want to read at run-time.
Experience, it's what you get when you were expecting something else.


Feb 15, 2013, 03:13 pm Last Edit: Feb 15, 2013, 11:54 pm by Nick_Pyner Reason: 1
This code finds the address. As you can see, it came from Hacktronics.

Using stereo jacks is as good as anything else. I use the cheapo flat plugs a lot of DS18B20s already come with.

Code: [Select]
// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {

void discoverOneWireDevices(void) {
 byte i;
 byte present = 0;
 byte data[12];
 byte addr[8];
 Serial.print("Looking for 1-Wire devices...\n\r");
 while(ds.search(addr)) {
   Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
   for( i = 0; i < 8; i++) {
     if (addr[i] < 16) {
     Serial.print(addr[i], HEX);
     if (i < 7) {
       Serial.print(", ");
   if ( OneWire::crc8( addr, 7) != addr[7]) {
       Serial.print("CRC is not valid!\n");
 Serial.print("\n\r\n\rThat's it.\r\n");

void loop(void) {
 // nothing to see here

Go Up