Pages: [1]   Go Down
Author Topic: 1-wire sensor network with multiple DS18B20 .... need som input/help  (Read 1232 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Offline Offline
God Member
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Dee Why NSW
Offline Offline
Edison Member
Karma: 48
Posts: 2300
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

// 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:

#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( {
    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

« Last Edit: February 15, 2013, 05:54:55 pm by Nick_Pyner » Logged

Pages: [1]   Go Up
Jump to: