Dallas sensor

I have a ntc sensor working on an esp8266. As a comparison of accuracy want to add a dallas DS 18b20 sensor to the same esp.
Ths is the configuration file uploaded to the esp8266 by OTA

esphome:
  name: playground
  platform: ESP8266
  board: d1

wifi:
  ssid: "soinsmesh"
  password: "3!Syerhacc3!KS"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Playground Fallback Hotspot"
    password: "PY8h1v2eIIyg"

captive_portal:

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:

switch:
  -  platform: gpio
     id: builtIn_led
     name: "Built In Led"
     pin:
       number:  D9
       inverted:  True
       
  -  platform: gpio
     id: ntc_vcc
     name:  VCC For NTC from PinD7
     internal:  True
     pin:
       number:  D7
       inverted:  True
interval:
  - interval: 60s
    then:
      - switch.turn_off:  ntc_vcc
      - component.update:  source_sensor
      - switch.turn_on:  ntc_vcc
       
#######
sensor:
  -  platform:  ntc
     sensor:  resistance_sensor
     name:  NTC Temperature Sensor
     accuracy_decimals:  0
     calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 10.0kOhm
      
               
     
  -  platform:  resistance
     sensor:  source_sensor
     id:  resistance_sensor
     name:  Resistance Sensor
     resistor:  9.9kOhm
     reference_voltage:  3.3V
     configuration:  DOWNSTREAM
     accuracy_decimals:  2
     
     
     
  -  platform:  adc
     id:  source_sensor
     accuracy_decimals:  4
     filters:
       -  offset:  -0.052
       -  multiply: 3.3
     pin:  A0
     update_interval:  never
     
  
dallas:
  -  pin:
       number:  D3  #GPIO5
       #inverted:  True

The sensor is not connected and the log gives an error that sensor not found. Was expecting a series of addresses for the sensors.
Here is a part of the relevant log

[23:48:03][C][dallas.sensor:073]:   Pin: GPIO5 (Mode: INPUT)
[23:48:03][C][dallas.sensor:074]:   Update Interval: 60.0s
[23:48:03][W][dallas.sensor:077]:   Found no sensors!
[23:48:04][C][captive_portal:169]: Captive Portal:
[23:48:04][C][ota:029]: Over-The-Air Updates:
[23:48:04][C][ota:030]:   Address: playground.local:8266
[23:48:04][C][api:095]: API Server:
[23:48:04][C][api:096]:   Address: playground.local:6053
[23:48:39][E][dallas.sensor:126]: Requesting conversion failed
[23:48:43][D][switch:025]: 'VCC For NTC from PinD7' Turning OFF.
[23:48:43][D][switch:045]: 'VCC For NTC from PinD7': Sending state OFF
[23:48:43][D][adc:056]: 'source_sensor': Got voltage=0.49V
[23:48:43][D][sensor:092]: 'source_sensor': Sending state 1.44617 V with 4 decimals of accuracy
[23:48:43][D][resistance:037]: 'Resistance Sensor' - Resistance 7723.0Ω
[23:48:43][D][sensor:092]: 'Resistance Sensor': Sending state 7723.00830 Ω with 2 decimals of accuracy
[23:48:43][D][ntc:026]: 'NTC Temperature Sensor' - Temperature: 30.9°C
[23:48:43][D][sensor:092]: 'NTC Temperature Sensor': Sending state 30.93044 °C with 0 decimals of accuracy
[23:48:43][D][switch:021]: 'VCC For NTC from PinD7' Turning ON.
[23:48:43][D][switch:045]: 'VCC For NTC from PinD7': Sending state ON
[23:49:39][E][dallas.sensor:126]: Requesting conversion failed

How can I get the address of the sensor?

D3 is not GPIO5 ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

I am using a D1 board in fact a Wemos D1R1( in looks it is like a UNO but with a esp8266)
On this D3 is GPIO5. My board pinout is here

https://alselectro.wordpress.com/2018/04/14/wifi-esp8266-development-board-wemos-d1/

Right, well esphome might be confused by that, try using the GPIO number in your yaml, ie

number: GPIO05

I used the GPIO05 as you suggested @nickrout, I did not get the result I was seeking. Even created a dallas hub on a esp8266 on pins GPIO05 and GPIO04 in turn, but same result.
What am I missing…

Have you got the pullup resistor?

I have not connected the sensor yet to the defined pin(As stated in the documentation). Yes I have the pullup of 4.7kOhms as defined in the esphome documentation.
BTW I am using ESPHOME(dev) to compile and upload.

So the dallas is not physically connected? It won’t get the address like that!

I was merely following this from the documentation @ Esphome

Getting Sensor IDs

It is highly recommended to use the address attribute for creating dallas sensors, because if you have multiple sensors on a bus and the automatic sensor discovery fails, all sensors indices will be shifted by one. In order to get the address, simply start the firmware on your device with a configured dallas hub and observe the log output (the log level must be set to at least debug!). Note that you don’t need to define the individual sensors just yet, as the scanning will happen even with no sensors connected. For example with this configuration:

# Example configuration entry
dallas:
  - pin: GPIO23

# Note you don't have to add any sensors at this point


I will give it a try with sensor connected…

I am pretty sure that means you do not need to create a sensor in your yaml file - the sensor clearly needs to be physically connected to get the address.

You are right @nickrout!
Esphome takes pin number as an int for the dallas sensor I think, so used 5 to get the sensor working. This is the final yaml file uploaded.

esphome:
  name: playground
  platform: ESP8266
  board: d1

wifi:
  ssid: "soinsmesh"
  password: "3!Syerhacc3!KS"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Playground Fallback Hotspot"
    password: "PY8h1v2eIIyg"

captive_portal:

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:

dallas:
   -  pin:
       number:  5
     #inverted:  True

switch:
  -  platform: gpio
     id: builtIn_led
     name: "Built In Led"
     pin:
       number:  GPIO02
       inverted:  True
       
  -  platform: gpio
     id: ntc_vcc
     name:  VCC For NTC from GPIO13
     internal:  True
     pin:
       number:  GPIO13
       inverted:  True
interval:
  - interval: 60s
    then:
      - switch.turn_off:  ntc_vcc
      - component.update:  source_sensor
      - switch.turn_on:  ntc_vcc
       
#######
sensor:
  -  platform:  ntc
     sensor:  resistance_sensor
     name:  NTC Temperature Sensor
     accuracy_decimals:  2
     calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 10.0kOhm
               
  -  platform:  resistance
     sensor:  source_sensor
     id:  resistance_sensor
     name:  Resistance Sensor
     resistor:  9.9kOhm
     reference_voltage:  3.3V
     configuration:  DOWNSTREAM
     accuracy_decimals:  2
     
  -  platform:  adc
     id:  source_sensor
     accuracy_decimals:  4
     filters:
       -  offset:  -0.052
       -  multiply: 3.3
     pin:  A0
     update_interval:  never
     
  - platform:  dallas
    address:  0x620004411638FF28
    id:  dallas_sensor
    name:  Dallas Sensor

Thanks for your deliberations and guidance @nickrout

4 Likes