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

Hi

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
Sebastian
---------------
Just finding my place in the wonderfull world of Arduino
Logged

texas
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.
Logged

Experience, it's what you get when you were expecting something else.

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 48
Posts: 2302
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.

Code:
// 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) {
  Serial.begin(9600);
  discoverOneWireDevices();
}

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++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

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: