ESP8266 - temperature sensor troubleshooting

Evening folks,

I’m having issues with an ESP8266 and ds18b20 temperature probe.

I would appreciate if anyone could help me trouble shoot the issue. (Go easy on me, this is my first attempt at ESPhome). I’ve manged to flash device and have had a successful upload of the yaml file but it seems the ESP8266 is not seeing the sensor. I’ve tried two esp8266 with different sensors, both resulting in the same issue. Is this a coding issue or hardware issue? See snippet of code below with issue

[20:35:08.760][C][gpio.one_wire:021]: GPIO 1-wire bus:
[20:35:08.760][C][gpio.one_wire:022]: Pin: GPIO2
[20:35:08.760][W][gpio.one_wire:082]: Found no devices!
[20:35:08.768][C][dallas.temp.sensor:029]: Dallas Temperature Sensor:
[20:35:08.769][W][dallas.temp.sensor:031]: Unable to select an address
[20:35:08.788][C][captive_portal:122]: Captive Portal:
[20:35:08.805][C][esphome.ota:075]: Over-The-Air updates:
[20:35:08.805][C][esphome.ota:075]: Address: buffer-tank-temp.local:8266
[20:35:08.805][C][esphome.ota:075]: Version: 2
[20:35:08.806][C][esphome.ota:082]: Password configured
[20:35:08.811][C][safe_mode:018]: Safe Mode:
[20:35:08.811][C][safe_mode:018]: Successful after: 60s
[20:35:08.811][C][safe_mode:018]: Invoke after: 10 attempts
[20:35:08.811][C][safe_mode:018]: Duration: 300s
[20:35:08.821][C][web_server.ota:235]: Web Server OTA
[20:35:08.829][C][api:205]: Server:
[20:35:08.829][C][api:205]: Address: buffer-tank-temp.local:6053
[20:35:08.829][C][api:210]: Noise encryption: YES
[20:35:08.849][C][mdns:213]: mDNS:
[20:35:08.849][C][mdns:213]: Hostname: buffer-tank-temp

From this part of the log the config looks “ok”. Though GPIO2 is not the best option. See the table lower down on this page: ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials Also you have not shared your config so there may be other issues.

On the hardware side:

  • Do you have a physical pull-up resistor installed on the Dallas data line?
  • What value?

Thanks for the reply Tom,

Excuse my ignorance here, which is the best pin for temp input and why? Again, this is all new to me. I have a 4.7k resistor across the data and 3.3V line of the temp probe. Admittedly the probe is bought off aliexpress and I’m hoping that is the issue. I’ve ordered some elsewhere, although they look identical. There wasn’t a wiring diagram - i used black for ground, red for 3.3 and yellow for data.

I have a node MCU chip and I connected the probe to D4 - GPI02. I attempted a different pin D2 - GPI04 with the same result. I tested the D4 pin and did see 3.3V on start up.

well D4 is already pulled up, but commonly internal pullup are weak so you just created a parallel that is still weak.
I’d try with a totally free GPIO (look at the table Tom posted above), but honestly if you have not used a very long cable DS18b20 sensors commonly works also with a weak pullup.
Check the connections again

Double check your wiring. Use a 4.7K Ohm pull up.

Thanks for the reply MassiPi,

The cable is 1m long. When you say a totally free GPIO, do you mean one that is not pulled up? IE D1 or D2 on the table.

What is the function of the resistor, I was assuming it was an EOL resistor or to monitor that the device is connected. Is this not the case?

D1/D2 are the most trouble free pins in general, D4 should be ok in this case as well though.
Your wiring description looks good, but are your wires well soldered?
You could post your code.

The data pins on both the master (ESP) and slave (temperature sensor) are open drain, i.e. they are switches that short to ground. Thus a pull up resistor is required to sense the drop in voltage when these pins are active. The size of the resistor is determined by the capacitance of the line and signalling timing. Recommended values are from 5K to 1K Ohms for short (1 meter) to long (~100s of meters) lines respectively.

The resistor can also be used to supply power to the slave device if it supports and is connected in parasitic mode (data and ground lines only). Not recommended that you complicate things this way unless absolutely necessary (i.e. you really can’t supply a power wire for some reason).

Hi Karosm, I have not soldered any connections, I have pin used pin connectors. The probe is connected to a small module allowing the probe to be terminated and the pin connectors connected. I have proven continuity from this termination point to the soldered side of the pin connector on the esp.

I will post the code this evening.

post a picture of your setup, especially the wiring.

Generally you need to solder things, but there are some methods that can work without solder.

Hi Karsosm,

See the code below.

esphome:
name: buffer-tank-temp
friendly_name: Buffer Tank Temp

esp8266:
board: nodemcuv2 # change to d1_mini if that’s your actual board

logger:

api:
encryption:
key: “HFH9imrX3kPdLt4YbZwAY3CoNxKKz9eybQ=”

ota:

  • platform: esphome
    password: “d026467313d1e3ec63ba908”

wifi:
ssid: Removed
password: Removed

ap:
ssid: “Buffer-Tank-Temp”
password: “J96nKeNuqb”

captive_portal:

1-Wire bus on D4 (GPIO2)

one_wire:

  • platform: gpio
    id: bus1
    pin:
    number: GPIO2
    mode: INPUT_PULLUP

sensor:

  • platform: dallas_temp
    one_wire_id: bus1
    name: “Buffer Tank Temperature”
    update_interval: 30s
    accuracy_decimals: 1

    address: 0x1C0000XXXXXXXXXX # optional, once you see it in logs

Please use code tags to post your code.

Hi Neel,

See photo, as I’m a new user I can only post one photo

esphome:
  name: buffer-tank-temp
  friendly_name: Buffer Tank Temp

esp8266:
  board: nodemcuv2   # change to d1_mini if that's your actual board

logger:

api:
  encryption:
    key: "HFH9imrX3kPdLt4YbZwAxKXdOzXudKz9eybQ="

ota:
  - platform: esphome
    password: "d026467313d1e364424b63b908"

wifi:
  ssid: Removed
  password: Removed

  ap:
    ssid: "Buffer-Tank-Temp"
    password: "J96neNuqb"

captive_portal:

# 1-Wire bus on D4 (GPIO2)
one_wire:
  - platform: gpio
    id: bus1
    pin:
      number: GPIO2
      mode: INPUT_PULLUP

sensor:
  - platform: dallas_temp
    one_wire_id: bus1
    name: "Buffer Tank Temperature"
    update_interval: 30s
    accuracy_decimals: 1
    # address: 0x1C0000XXXXXXXXXX   # optional, once you see it in logs
``

I don’t notice anything abnormal. Anyway, you have 4k7 already on the connection module. Did you try without external resistor?

And the sensor cropped out of the image…?

Thanks for pointing that out, i didn’t realise. I’ll remove the resistor and see if it makes any difference.

nice board, no sensor though…

That interface board already has a 4.7K pull-up resistor.

You don’t need the extra one in the screw terminals. It won’t be the cause of your issue but you can remove it for simplicity.

EDIT: actually it might be a problem. If that colour code is yellow - purple - gold - gold then it is a 4.7 OHM resistor (not K Ohm). If it is yellow - purple - brown - gold then it is a 470 Ohm resistor.

Both are very low values that the sensor may have trouble pulling to ground.

Remove the resistor from the screw terminals.

3 Likes

Hi Tom,

You were dead on, I tested the resistor and it was 4.7ohm I removed and problem solved.

I really appreaciate all the assistance.

1 Like