DS18B20 Config

I have the Dallas Temp sensor all wired up and it looks good in the Serial Monitor. IN my config file I have the following:

sensor 6: -platform: onewire names: some_id: outside mount_dir: "/mnt/1wire"

Not even sure where the mount_dir is located. None of this is listed on the sensor page of HA. I found all these things from other forums and posts.

Is this correct??? Is the mount_dir correct? I added dtoverlay = w1-gpio, gpiopin = 4, pullup = on
I have no idea what the 3 variables should be set to.

I get this error when I start up HA after rebooting:
ERROR (Thread-3) [homeassistant.components.sensor.onewire] No onewire sensor found. Check if dtoverlay=w1-gpio is in your /boot/config.txt. Check the mount_dir parameter if it's defined.

Make sure you are using correct GPIO pin and powered correctly.

Verify sensor from command line sensor present in /sys/bus/w1/devices/. Will look like “28-xxxxxx”.

How do I know what GPIO Pin I am using or that I am supposed to use? When I type:

ls -l /sys/bus/w1/devices/

I get:

(homeassistant_venv) pi@raspberrypi:~ $ ls -l /sys/bus/w1/devices/ total 0 lrwxrwxrwx 1 root root 0 Nov 8 02:12 00-320800000000 -> ../../../devices/w1_bus_master1/00-320800000000 lrwxrwxrwx 1 root root 0 Nov 8 02:12 00-520800000000 -> ../../../devices/w1_bus_master1/00-520800000000 lrwxrwxrwx 1 root root 0 Nov 8 02:12 00-d20800000000 -> ../../../devices/w1_bus_master1/00-d20800000000 lrwxrwxrwx 1 root root 0 Nov 8 02:12 w1_bus_master1 -> ../../../devices/w1_bus_master1

Is that correct? I have a serial gateway set up, a motion sensor, and a Dallas Temperature sensor set up on a RPi3. I also am getting a correct reading in the serial monitor and in HA but the error still shows when I start HA. Its weird…

sudo gpio readall

That command will printout GPIO states
it also shows pinout for RPi
I assume you have RPi 2 or 3

you should connect DS18B20 data connection to GPIO.7 (physical pin 7).
Be aware that connection guides show this as BCM 4 in some cases.

you should have 4.7K ohm resistor connected between GPIO7 and 5VDC.

The result you show means Sensor is not communicating. Usually caused by having it connected on incorrect pin.

EDIT
for some reason many guide say connect to GPIO4 but they are meaning BCM4 (GPIO7).
I connected GPIO4 then realized the guides I reference were incorrect. Use the command above to determine pinout configuration and try to connect as I suggest.
After connect in this manner rerun the dtoverlay command from before. The 00-xxxx should change to 28-xxxx.

I get this when I type that command
pi@raspberrypi:~ $ sudo gpio readall sudo: gpio: command not found

I am getting a temp reading in HA and its correct: https://www.dropbox.com/s/bpa4ouhuhdfj0lh/Screenshot%202016-11-07%2022.27.35.png?dl=0

I have the onewire connected to D3 on a NANO based on what MySensors.org said to do with a 4.7k ohm resistor on a Pi 3 and in the serial monitor reports the correct output with a temp reading that is correct. I only get the error when I start HA and then I never see it again. Maybe its the order I have the sensor in my configuration.yaml file. I load the Serial Gateway before any of my sensors though… Do you want me to post my config file?

Not sure if this is closed.

But you could try this.

Start by adding the following line to /boot/config.txt

dtoverlay=w1-gpio

You can edit that file with nano by running sudo nano /boot/config.txt and then scrolling to the bottom and
typing it there

This pdf is a nice guide.

Was completely overthinking it myself. Its super basic

the sensor is plugged into PIN 4 (gpio 7) and can see in the w1 folder (/sys/bus/w1/devices/)

in /boot/config.txt I added
dtoverlay=w1-gpio

added a seperate sensor yaml by this line
sensor: !include sensors.yaml

added the following in sensors.yaml
- platform: onewire

then restart hass
profit :smiley:

Which PIN exactly is the correct?

Currently I’m connected to GPIO4, PIN number 7. Is this correct?

Because every some time I lost communication and get:

Log Details (ERROR)
Thu Feb 07 2019 10:25:39 GMT+0100 (Central European Standard Time)

No onewire sensor found. Check if dtoverlay=w1-gpio is in your /boot/config.txt. Check the mount_dir parameter if it’s defined

I have edited config.txt… is problem in PIN connection? Also, I connected to 3.3V withouth any resistor…

Yes. This is correct.

This is wrong. He meant gpio4 (pin 7)

Did you reboot after that?

There are 3 methods to enable the one wire sensor in raspberry.
The third method is what you did. If you think it is easier follow number 2.
Read this article:

Dont forget to reboot!

Yea, for me this was already all working… But after some time and after some HA restarts (constantly working on something) sensor drop-off…

ha

Then check your wiring. Your problem could be the sensor disconnected from the pi. If not disconnected, then it could have failed… Do you have another sensor to check? Preferably a new one.

Wirring is 100% OK… double checked…

After un-plug and plug-it back and restart of HA it start working… but it will work for about 24 hours and after some time it will loose connection…

ha2

Ok, this is not going to be easy… Some questions:

  • Are you using 3.3v or 5v to power the sensor?
  • What is the lenght of the cable?
  • Are you using a resistor or not? if yes how many kohms? if yes, the resistor is placed in the side of the sensor or the pi?
  • How have you connected the 3 wires of your sensor? Can you show a photo or a diagram?

1: 3.3V power
2: 20cm cable lenght, all 3
3: no resistor use
4: GND, PW 3.3V, GPIO4 (PIN 7)

Try reading this post. I think they have the same problem as yours.
https://www.raspberrypi.org/forums/viewtopic.php?t=25154

I strongly recommend using a resistor. A 4.7K should be fine.

I have 4 ds18b20 sensors and I am using at least 10meter long cables for each of them. I have them on 5v pin but I am using a resistor. I had too many problems at random times when I did not use the resistor.
I am not sure if that is your problem, but it is worth a try. Nothing else comes in my mind, so I am not sure if I can help you further…

Do I connect resistor to GND cable or to PW cable?
Probably to GND…?

Power and data.
See this:

Uf… I will try that one day - but not today :slight_smile:

PS. Thank you for your help…

1 Like