Hello,
I am trying for some time to get five ds18s20 to run over the one wire libary on one port.
My problem is that if you conect more sensors, that some times the id of the Sensor stays the same,
so that the newest sensor has the id and the values of an other sensor.
I could find nothing about this failure in the internet. I hope you can help me.
Which program are you using, to determine the ID of the sensor ?
If you have 5 sensors and you cannot see the 6th one, then my suggestion would be, to remove the 5 sensors
and keep the 6th one, then run the program to find the iD of the 6th one, then put the other back in the
circuit and use the temperature-reading program, it should be able to find the 6th sensor then, because it
already knows the ID.
From Hacktronics. Plug in one sensor at a time.
// 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
}
Hey after two days i found now the failure. The Problem was that the get_id funktion gives me the ids not in order.
So when i store the ids one after the other in an array i store a some point the same ids and therefore get the same temps with the funktion get temp by id.
But thank you very much