I've been working on using a NodeMCU with the Arduino IDE, which is working fine, but am using a waterproof DS18B20 sensor, and it won't work. The sensor worked fine with 5v, but when I switched to 3.3v it basically broke. I've done some research, but can't figure it out. I'm... not very good with electronics. I know the sensor works, but can't figure out 3.3v connection. If anyone has some advice, please help...
Smebdy:
but when I switched to 3.3v it basically broke.
I bet it hasn't, and it's just you not driving it properly. The data sheet says it will run on 3.0v minimum, so 3.3v should be enough. I think you should check out the pullup resistor. It may need to be changed from the usual 4.7k.
You don't say if you are using parasite power. I don't think it is ever a good idea, and probably a worse one with 3.3v.
I never really figured out parasite power, but I can say that ground an positive are connected. What resistor value would you recommend?
Smebdy:
I never really figured out parasite power,
Don't bother trying
What resistor value would you recommend?
I'm guessing 2.2k, but I only say that because I understand it is used on long cable runs. I would try googling this. You can't be the first to encounter this, and you have already proven the sensor and code are OK.
I have tested them with 3.0V, and it worked. But it was only with a very short wire (10 or 20cm). For such short wires I use a 10k or 4k7 pullup resistor.
Perhaps you have a long cable ? Perhaps the timing of the NodeMCU is not okay. Which library do you use ?
I'm using a longer wire, but I can try cutting it down. I don't need the extra length. I am using a 2.2k resistor. I use Onewire and DallasTemperature. I originally used a 4.7k resistor, and still have it. With the shorter wire, what was your circuit? And the longer wire?
Using DS18B20 on a Tiny84 on 3.3 volts with 4k7 pullup and parasite power, been working great for months. Its the weatherproof type on a 1 meter cable, also have 2 others on 3.3 volt AdaFruit Trinkets with no problems, you might try a smaller pullup, down to 2k2.
Also, didyou see this post?
http://forum.arduino.cc/index.php?topic=398744.0
I'm considering changing sensors, but will post a Fritzing diagram of my setup later. I've had the problem before on 5v with the wrong resistor. (The resistor was the same color code as 4k7 backwards.) I'll play around with a potentiometer maybe. Then check the resistance with a multimeter. I'll post any results I get with the diagram.
You have a decoupling cap on the sensor? I'd strongly recommend it.
Smebdy:
I'm considering changing sensors,
I don't think that is warranted, certainly not a new type. As I said, you have already proven that your code and the sensor are fine, and the device is known to work on 3.3v, so it really can only be the installation. You may find that a new sensor doesn't solve the problem, but just proves what you already know.
Ooookay. Not working again. Figured out parasite power, and have tried both. Have the long wire, 4k7 resistor. Not working. 2.2k?
Here's some DMM readings I took on a working DS18B20 if that helps:
- probe - probe
red 22 M blk
red 24 M grn
blk 3.2M red 0.585V diode test
blk 3.0M grn 0.585V " "
grn 19 M red
grn 18 M blk
I submit you should start over and check everything, including the code. Even if you have worked out how to use parasite power, I bet you still haven't worked out a good reason for doing so, so stay away from it.
According to the manufacturers, the DS18B20 should work fine on as little as 3.0v, and normally uses a 4.7k just like it does on 5v.
Cable can be a problem with DS18B20 but every sensor I have comes with 3m connected and used in the normal manner. I believe they are also supplied with 5m. If you have a long run and no cable, CAT5 seems a good choice, you get proper quality cheaply.
Hi All, for anyone who has this same problem of a DS18B20 on the NodeMCU. I can confirm changing to a 2.2K resistor helps. However please note, the 'Simple' example code for the Dallas Temperature library includes:
#define ONE_WIRE_BUS 2
On the NodeMCU you must define the pin as "D2" rather than just "2" otherwise it wont work.
Thanks for that! I am just about to start using a Node MCU. Karma to you
Smebdy:
I'm using a longer wire, but I can try cutting it down. I don't need the extra length. I am using a 2.2k resistor. I use Onewire and DallasTemperature. I originally used a 4.7k resistor, and still have it. With the shorter wire, what was your circuit? And the longer wire?
Hi,
This thread is a bit old but just in case you are still interested, I used to have inconsistent readings with a 15m long signal cable with 2 DS18B20 sensors attached to it in a star topology. My configuration also had a 4.7k resistor connected between signal and 5V.
That config worked without inconveniences when using short cables but do not respond very well with long cables.
Reading the Maxim site I found that this could be caused by an impedance matching. Using a 100 ohm resistor in series in the signal cable eliminated my problem.
I also tested with 3,3V from a arduino Mega and it worked without any visible problem. I didn't carried out extensive tests. I Just connected and it worked.
I hope this may help you or anyone else.
MarkT:
You have a decoupling cap on the sensor? I'd strongly recommend it.
What size decoupling cap would you recommend for a DS18B20 on 3.3V?
There was a thread on this group regarding DS18B20 and 3.3V logic.
I cannot add comment there (the thread is closed) however google still points there anyway. It might be good to reopen it or to redirect further discussion here. That's why I am opening a new thread about it.
I have a few comments and one question:
- did anybody achieve large DS18B20 network to work on 3V3 logic? If yes then how? With any extra circuit? to allow sensor network to operate on higher voltage than cpu? Or keeping 3V3 bug giving ultra small pullup resistor?
My experiences with DS18B20 on 5V logic:
-
if you are using many sensors (12+) and long wires (10m+) you need to scale down the pullup resistor significantly (really drastically). I managed to make 30 thermometers work on a topology which has weight over 30-40 meters. I did not use any decupling because the problem was with slow signal rise, not with echo (as measured using oscilloscope).
-
to achieve this I had to reduce the pullup resistor to 1k ohm. Yes. 1000ohm. I was checking on oscilloscope how the signal rise gets degraded when attaching extra sensors and extra wire length. Now I have several installations with 20+ sensors each, with cables weight up to 50m and they are working.
-
one comment: cable weight I am counting as the total length of all cables, plus 2m for each crossroad (star split), plus 2m for each sensor. It is not fully compliant with literature but it is working for me. In literature the cable weight calculations are sligthly different.
-
please note, that this is without using parasite power. in literature there is a schema for large networks using parasite power - search for a term 'strong pullup'. This is an extra transistor which is strongly pulling up power/data line to 5V when not transmitting/receiving data. You have to dedicate one extra microcontroller output for this, and disable strong pullup during transmission, re-enable it after transmission. I did not test it much because my networks are large (20+ thermometers) and I wanted to be on a safe side.
However now I am preparing to replace ATMEGA 5V cpus with 3.3V logic 32bit cpus. And now there is a question if anybody has any experience with 3.3V logic for DS18B20. Did anybody make it work, and if yes than what was the weight, and how the circuit did look like.
Please post a link to the closed topic and I will consider reopening it