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