DS18B20 where to connect

Hi! I bought a DS18B20 sensor, and would like to make a WiFi temperature reader.
I followed this tutorial, but it says that its -127 Celsius. I think that it's wrongly connected, but where do I connect it? In the code, it says GPIO4, but in the description it says 2. I tried both, but it still doesn't work.
I have one of this board.

Use code that is appropriate to the controller you are using
Arduino 1-Wire Tutorial
You are using a Uno-ish Arduino and pin 2 should be OK. You are correct in that -127 means not connected but, since you have tried both, I guess that means you are not making a proper connection. Also check you have correctly installed the 4k7 pullup. Note that there are a lot of fake DS18B20s around.

Welcome to the world of "ESP". The pin numbering system can drive you bonkers. Look at your board and connect it to GPIO 4. Different versions will have GPIO 4 but it can be connected to other pins. The tutorial you picked is good; Everyone I have tried from them always worked. He shows both normal and parasite mode, start with normal and get it working first.

Do you have the TO-92 (looks like a transistor) type or the "waterproof" type with a long, 3 wire cable? If the latter, what are the wire colors?

Definitely - I wouldn't trust a DS18B20 not bought from a reputable electronics supplier at all.

1 Like

I have the waterproof version of it, it has Red, Black and yellow wires. I tried it with an Arduino micro, and it worked, so my sensor is not fake.

I found this schematic, and if I'm correct, is says that pin 2 is on GPIO4.
Am I correct?

I do not see that on Pin 2 in the schematic that appears in your link. The simple way is to use the blink sketch and connect a LED to it. If it blinks you got it, if not try some other pins. Be sure to put a resistor in series with the LED.

Don't be so sure.
Other posters reported problems over ~50 degrees C with fake ones.
Leo..

That is no guarantee of what you have. Try adding a pull up resistor in the 4.7K range from the yellow to black wire.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.