0
\$\begingroup\$

I have a DS18B20 temperature sensor connected to a Node MCU (ESP-12 / ESP8266) like shown below, where μP is the MCU (any GPIO gives the same result) and Vpu = VDD = 3.3 V, coming from the 3.3 V pin of the MCU.

enter image description here enter image description here

The sensor works well as long as the MCU is powered through USB. But when I power the MCU using an external 5 V, 700 mA power supply through the Vin pin, the temperature sensor stops working (reads 0 all the time). The MCU, however, continues operating normally.

I have found that I can make the temperature sensor work again by replacing the 4.7 kΩ pull-up resistor with one of 333 Ω, making it a much stronger pull-up.

I am baffled as to why this happens. The 3.3 V output should behave the same no matter if the 5 V power is supplied through USB or Vin (and it does seem stable in both cases according to measurements). And why would such a strong pull-up be needed on the signaling line anyway, since I'm powering the DS18B20 through an external supply (not using parasitic power mode)?

enter image description here

\$\endgroup\$
4
  • 1
    \$\begingroup\$ You did not show the connection of sensor to MCU. \$\endgroup\$
    – user263983
    Commented Oct 31, 2022 at 10:37
  • \$\begingroup\$ The connection of the sensor to the MCU is done through the one-wire bus as shown in the first figure, where μP is the MCU. I'm using GPIO5, but I have tried others and the results is the same. \$\endgroup\$
    – guiweb
    Commented Oct 31, 2022 at 15:52
  • 1
    \$\begingroup\$ @guiweb he/she asked the physical connection details such as whether the sensor is on a separate board which connects to the NodeMCU through a cable, which port/pin is used for 1-Wire communication, etc. \$\endgroup\$ Commented Oct 31, 2022 at 15:56
  • \$\begingroup\$ I have added a picture to show the physical connection. \$\endgroup\$
    – guiweb
    Commented Oct 31, 2022 at 16:55

1 Answer 1

2
\$\begingroup\$

This was actually caused by the external 5V power supply used, which was badly grounded and, as a result, noisy. Using a stronger pull-up resistor alleviated the issue at first, although more testing revealed that communication still failed sometimes.

After fixing the ground connection in the power supply, it was possible to revert to the 4.7 kΩ resistor without any issue.

\$\endgroup\$
1
  • \$\begingroup\$ guiweb - Hi, Thanks for coming back with an answer to your question. In order to effectively mark the topic as solved, please consider "accepting" an answer (i.e. click the "tick mark" next to an answer - your answer or another one, if one is written - to turn the relevant tick mark green). This shows that you don't need more help and future readers can quickly see which was the confirmed solution. Thanks. \$\endgroup\$
    – SamGibson
    Commented Nov 2, 2022 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.