Search code examples
arduinoesp8266arduino-esp8266

Trouble with Digital Temperature Probe and ESP8266


I am having a hard time troubleshooting this project build of mine. I am trying to utilize a DS18B20 temperature sensor in conjunction with an ESP8266 to create a temperature beacon.

The problem I'm running into pertains to the data interpreted by the ESP8266. I am using the Arduino IDE to program the HUZZAH ESP8266 breakout.

The WiFi client is behaving as supposed to, but the temperature sensing is not. When I upload the same sketch to an Arduino Mega2560 (recompiled obviously), and plug the data line into a digital pin of the 2560, the probe temps come in perfectly, changing according to the temp. If I unplug the data lead, I get -196.80, what I assume is a ground value.

Simply moving the data line into the ESP8266 pin, I receive a temp of 262.29 and this does not change in between reads, regardless of sensor temperature.

I have ensured all of the cables are wired properly, there is no weird grounding or anything. I have tried changing the baud rate of the serial interface maybe thinking the clock had something to do with it, but that seems to have affected nothing.

Any idea/direction is always appreciated!


I have wired the circuit according to a diagram located at this link here.

Here is a Gist to the code that I have been uploading to the ESPs. The code is designed to setup a WiFi Client (attached to a local AP, which works totally fine), request the temps, and submit up to a host that has a listening server. The pin (2) refers to GPIO2 on ESP8266 [i think]


So I found A solution to this. I'm not sure if this particular problem has been replicated for everyone, however, in my situation, the parasitic power on the data line was not charging the IC enough to finish the proper calculation.

All I had to do was unground the VDD pin and hook it up to the 5V rail. Leave the 4.7kOhm resistor on the data line also pulled up to the 5V rail. After doing so, the program reports PARASITIC POWER: OFF, and reports temperatures as I hoped!


Solution

  • I changed my post above to include a working solution!

    The DS18B20 device can operate in 2 power modes (normal and parasitic). In the case of parasitic power, the VDD pin is jumped to GND and the IC receives power from the data line that is connected back to a micro-controller.

    An interesting quality of the DS18B20 is the power draw during temperature sensing. While operating in parasitic mode, the host device needs to be able to supply the IC with enough power to complete the calculation, otherwise the device will return a bad answer.

    The solution for me (using an Adafruit HUZZAH ESP8266 micro-controller) was to not use parasitic power. I cannot say for sure what the problem with this setup is, however, when configuring the circuit in normal mode, the probe worked as expected. I imagine the data line isn't getting enough power.

    To change the circuit from the diagram linked above:

    • Remove the jumper between VDD and GND pins
    • Connect VDD to 5V rail
    • Keep GND to GND rail
    • Keep 4.7kOhm resistor pulling data line up to 5v rail