Just received my waterproof DS18B20 temperature sensors (5 of them) (link). I've been trying to follow various tutorials, but can't seem to find the address of the sensors.
I've connected the sensors to:
black to GND
yellow to D5 (4.6 k Ohm to 5V)
Red to 5V (I've also tried without 5V on the red...)
I've installed OneWire (2.3.2) for the Library Manager. And then installed Example -> OneWire ->DS18x20_Temperature
I've changed the code to "OneWire ds(5);" to match the port it is connected to.
In the serial monitor I get only "No more addresses"...
what am I doing wrong? Ive tested 2 sensors so far...
Sounds right - are you sure you are looking at the right pin in your code? What code are you using? (is that output from the scanner that is around here somewhere (don't remember just where I saw it recently, but it was 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
// DO ONE DEVICE AT A TIME!!
#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
}
If you are wired correctly, the example code from the one wire library(DS18X20_Temperature) should work, it definitely does with the DS18B20 I have-- in both powered and in parasite mode.
The code Nick posted also shows the address.
Are you sure of the value of the pull up resistor? Can you actually read 5v across it with a multi meter?
Perhaps the waterproof probes were incorrectly wired in reverse by some 11 year old child worker in the place where they were made. You could try reverse the leads and see if anything happens. The probe will either get real hot, or it will be working.
From the website linked, they claim they are tested before being shipped and your wiring matches their description I have a number of these but have not had a chance to play with them (different vendor a while back, but probably out of the same shack somewhere):
Detail:
1.Brand New High Quality
2.The probe the temperature sensor DS18B20 original chip
3.High quality stainless steel tube encapsulation waterproof moistureproof prevent rust
4.Stainless steel shell 6*50m
==> 5.Power supply range: 3.0V to 5.5V
6.Operating temperature range: -55°C to +125°C (-67°F to +257°F)
7.Storage temperature range: -55°C to +125°C (-67°F to +257°F)
8.Accuracy over the range of -10°C to +85°C: ±0.5°C.
9.No other components, unique single bus interface
==> 10.Output lead: red (VCC), yellow(DATA) , black(GND)
11.Cable length: 100 cm
Mian business [I assume they mean "Main" - please to be so careful ... spell checker broke ]
We selling items with high quality and best price .
All items will be tested before shipped. we seek for long term .
We mainly selling ICs, electronic component ,
electronic modules. PCB board etc,
I rewired everything last night. No change. Then I tested with my official Arduino Uno, and it worked like a sharm. Is the unofficial Arduino Nano broken, or do I need to adapt the code... I've testet two Nanos, none of them can identify the digital sensor... so I suspect its the code....
Christian_83:
Then I tested with my official Arduino Uno, and it worked like a sharm. Is the unofficial Arduino Nano broken, or do I need to adapt the code...
The Nano is pretty much a UNO, Arduino-ly speaking (it has a couple of extra analog pins) so I suspect that one wire detector does something special that the Nano cannot support (which I find somewhat eyebrow raising but stranger things happen at sea).
But now you've discovered the address using your UNO you can use that in your Nano, right? Does it work then?
Well, the good news is you have verified the sensors are working. Your homework for tonight is to figure out what is different between the two boards. Glad we know the sensors are OK though - that narrows down the problem. That leads us back to my comment in #5 - if you have access to a scope, do you see the pin you expect being toggled when it is trying to read the sensor? (I just got caught with one of those "can't count" things a few days ago installing Ubuntu Linux in a virtual machine. I (for some reason) could not figure out the right partition to install GRUB into and kept giving it the wrong one which caused the install to fail. One of those profound "duh" moments when solved )
As mentioned, I now have the addresses to each of the sensors. And they have been duly marked both physically and in the code. Good to know that the senosors are working.
Will check if I can read the data with the Arduino Nano now when the addresses known.
Christian_83:
Then I tested with my official Arduino Uno, and it worked like a sharm. I've testet two Nanos, none of them can identify the digital sensor... so I suspect its the code....
I understand a Nano is simply a stripped-down Uno. If the code is kosher for one, it should be kosher for both.
I therefore suspect the problem is somewhere else, particularly since you have tried two Nanos.
You have made some silly mistake with the wiring.
The power supply to Nano is different to that for Uno, and is not up to the job.
Please don't tell us you are trying to use a 9v PP3 battery on the Nano.
That's noteworthy, but your device is more than just a DS18B20, and looks more complicated than it should be. A DS18B20 runs on 3.0 > 5.5v You should have no problem with your 3.3v Nano if you get a proper DS18B20.
Nick_Pyner:
That's noterworthy, but your device is more than just a DS18B20, and looks more complicated than it should be. A DS18B20 runs on 3.0 > 5.5v You should have no problem with your Nano if you get a proper DS18B20.
One would think so, HOWEVER, he did state that he had the pull-up resistor and sensor power connected to 5v - if his board is running on 3.3v, that could be an issue.
I am curious to know if you resolved this problem. I am experiencing the same problem with some generic Nanos I purchased. I would like to know if there is a solution before I purchase a genuine Nano.
How did you power the Nano.
A Nano has a schottky backflow diode between USB and 5volt, so 5volt is ~4.6volt on USB power.
Try some (10-100uF) decoupling between supply and ground on the sensor.
Leo..
Wawa:
How did you power the Nano.
A Nano has a schottky backflow diode between USB and 5volt, so 5volt is ~4.6volt on USB power.
Try some (10-100uF) decoupling between supply and ground on the sensor.
Leo..
Thanks Leo.
You are correct about the USB voltage being roughly ~4.6 volts. I measured it yesterday and it was that value. I will try your suggested decoupling and report back.