I'm currently working on a project that requires temperature control. I've followed the instructions in the OneWire page of the playground and successfully got my temperature sensor to work. My initial work was done with an Arduino Uno which my professor lent to my group. However, we wish to minimize the space that our temp control circuit is going to use so we purchased an Arduino Nano. After hooking up our Nano we observed that we weren't getting temperature readings so upon further review we found that using the Nano, the program does not get past this piece of code.
if ( !ds.search(addr)) {
Serial.print("No more addresses.\n");
ds.reset_search();
return;
}
Using the same code interchangeably between the Nano and Uno it is obvious that it doesn't work for the nano. Does anyone have any idea what is going on/how to fix it? Any help would be greatly appreciated.
Was talking to another colleague and they suggested that the connections to the arduino could be loose. We've checked them and we're pretty certain the connections are good. Just in case anyone would have the same question upon reading the first post.
This reply might not satisfy you, but if the problem lies in the snippet which you posted, the only idea I have is that the ds.search() function returns false, which lead to return statement inside the if. But this is only happening if there is no sensor detected, but that is what you already wrote in your update. So in your case I would check, check and double-check all the connections to the sensors.
Have you selected the correct board type?
Are you sure you're using the equivalent pin on the Nano?
Can you drive a LED (with suitable resistor) from that pin?
We've tried different pins on the nano and get the same result. We've also been able to use the pins for driving an LED so they are functional.
It just seems very odd to us that it works for one product and not the other, was hoping that there are others out there that have encountered the same problem and if they know a fix.
Well the Nano and the Uno are identical as far as the sketch software goes, so most likely (IMHO) you are not wired up to the same pins that you think you are.