TSP Address Finder

Geek, Lighting Tech, Maker

TSP Address Finder

Made With:
If you need to know the Addresses of the Temp Sensors Attached to your Arduino Upload and Run this code.
Note Please follow the Arduino TSP Process for installing the libraries prior to using this code
Process is located HERE
// 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(6); // 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...nr");
while(ds.search(addr)) {
Serial.print("nrFound '1-Wire' device with address:nr");
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("nrnrThat's it.rn");
ds.reset_search();
return;
}

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


No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.