Connecting to DS18B20 OneWire temp sensors

I need to connect to some DS18B20 OneWire temperature sensors from my new OpenHAB system (on Raspberry Pi). I plan to do this using a DS9490R. What software do I need to install? Do I need OWFS, or just OWSERVER? Can this run on the same RPi as OH, or do I need a different one? As step-by step guide on how to get from my virgin OH system to beaing able to read temperatures from the DS18b20s would be really helpful for me.

Thank you - Rowan

How many sensors do you have, and how close are they all to your Pi?

I’ve deployed many of these sensors by attaching them to an NodeMCU clone flashed with Tasmota, and then grabbing the data into openHAB via MQTT. All over wi-fi, so the sensors are far away from the openHAB machine. There’s quite a few steps involved with this setup, so it would be good to understand a little more on your physical arrangement!

1 Like

I recommend OWFS with the onewire binding.

I will eventually have 13 sensors. They will be placed throughout the house (one in each room that I need to control the heating in). The house is about 20m long, so the OneWire cable will be longer than this having snaked around all the locations that need a sensor.

Rowan

I have tried to install OWFS. Here’s a section of the log:

Creating config file /etc/owfs.conf with new version
Setting up libow-3.2-4:arm64 (3.2p4+dfsg1-4+b1) …
Setting up owhttpd (3.2p4+dfsg1-4+b1) …
Created symlink /etc/systemd/system/multi-user.target.wants/owhttpd.service → /lib/systemd/system/owhttpd.service.
Job for owhttpd.service failed because the control process exited with error code.
See “systemctl status owhttpd.service” and “journalctl -xe” for details.
Setting up owserver (3.2p4+dfsg1-4+b1) …
Created symlink /etc/systemd/system/multi-user.target.wants/owserver.service → /lib/systemd/system/owserver.service.
Created symlink /etc/systemd/system/sockets.target.wants/owserver.socket → /lib/systemd/system/owserver.socket.
Job failed. See “journalctl -xe” for details.
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u2) …
Processing triggers for man-db (2.9.4-2) …
Updating FireMotD available updates count …

Does the “job failed” message matter? If so, how do I fix this?
If the installation is OK, what do I have to do next to read temperatures from my DS18B20 sensor?

If I connect to http://openhabian:8080, I see a page saying " Overview Page Not Configured Yet". The documentation tells me to click the Settings item in the menu, but when I do this nothing at all happens. Not sure how to proceed.

Thank you - Rowan

If I enter the command line “sudo /opt/owfs/bin/owfs -F --allow_other /dev/ttyS0 /var/1Wire/mnt” as recommended on Testing - owfs, I get “-bash: /usr/bin/sudo: Input/output error”. How do I find out what is wrong and fix it?

Thanks - Rowan

Is /dev/tty0 your device?

I’ve no idea. How do I find out which port number it had given the DS9490R?

Thank you - Rowan

You can try

ls -l /dev/serial/by-id

if you can’t identify the device by that, try

lsusb
ls -l /dev/serial/by-path

And match the output of the first with the latter.

1 Like

lsusb gives me:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 04fa:2490 Dallas Semiconductor DS1490F 2-in-1 Fob, 1-Wire adapter
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

ls -l /dev/serial/by-path gives me:

ls: cannot access ‘/dev/serial/by-path’: No such file or directory

What am I doing wrong?

Thanks - Rowan

When I did watch “dmesg | tail -20” andplugged in the DS9490R, I got:

[ 1654.498403] usb 1-1.1: USB disconnect, device number 3
[ 1728.941040] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd
[ 1729.048152] usb 1-1.1: New USB device found, idVendor=04fa, idProduct=2490, bcdDevice= 0.02
[ 1729.048188] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

Does this tell me what name to use for this port? What do I use?

Thanks - Rowan

Try

sudo dmesg | grep tty

You should see something like

[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-18-amd64 root=UUID=83a2763c-2101-4f89-b56a-fd2517730741 ro console=ttyS0,115200n8 quiet
[    0.748912] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-18-amd64 root=UUID=83a2763c-2101-4f89-b56a-fd2517730741 ro console=ttyS0,115200n8 quiet
[    0.946453] console [ttyS0] enabled
[    4.321456] 00:02: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    4.342596] serial8250: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[    9.628875] systemd[1]: Created slice system-serial\x2dgetty.slice.
[   10.848010] usb 2-2.4: FTDI USB Serial Device converter now attached to ttyUSB0

This is not a DS9490, but the one line should contain “attached to” and that is the correct port.

Thank you for your reply. I tried this, and this is what I see:

openhabian@openhabian:~ $ sudo dmesg | grep tty
[sudo] password for openhabian:
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=0 bcm2708_fb.fbheight=0 bcm2708_fb.fbdepth=16 bcm2708_fb.fbswap=1 smsc95xx.macaddr=E4:5F:01:A4:A5:FA vc_mem.mem_base=0x3f000000 vc_mem.mem_size=0x3f600000 console=ttyS0,115200 console=tty1 root=PARTUUID=6c72fba2-02 rootfstype=ext4 fsck.repair=yes rootwait
[ 0.000812] printk: console [tty1] enabled
[ 1.450886] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 17, base_baud = 0) is a PL011 rev2
[ 3.174971] systemd[1]: Created slice system-getty.slice.
openhabian@openhabian:~ $

Nothing says “attached to”. What does this mean? What do I try next?

I’m sorry about my absolute lack of knowledge with Linux. I have been using computers for over 50 years but never Unix/Linux, so I’m early on the learning curve.

Thank you - Rowan

I guess ttyAMA0 should be the correct port

Now when I enter:

openhabian@openhabian:~ $ sudo /opt/owfs/bin/owfs -F --allow_other /dev/ttyAMA0 /var/1Wire/mnt

I get:

[sudo] password for openhabian:
sudo: /opt/owfs/bin/owfs: command not found
openhabian@openhabian:~ $

So I still can’t verify that OWFS (or OWSERVER) is correctly installed.

Rowan

In my system the path to OWFS is different:

jnk@apu:~$ whereis owfs
owfs: /usr/bin/owfs /usr/lib/owfs /etc/owfs.conf /usr/share/owfs /usr/share/man/man1/owfs.1.gz /usr/share/man/man5/owfs.5.gz

Maybe check with whereis if the binary is really located under /opt/owfs/bin/owfs or somewhere else like /usr/bin/owfs.

I get this:

openhabian@openhabian:~ $ whereis owfs
owfs: /etc/owfs.conf /usr/share/owfs /usr/share/man/man5/owfs.5.gz
openhabian@openhabian:~ $

And this:

openhabian@openhabian:~ $ ls -l /usr/share/owfs
total 4
-rw-r–r-- 1 root root 1103 Oct 30 2020 owfs.conf
openhabian@openhabian:~ $

Which of these is meant to be the OWFS binary? And having found it, how do I enable the OS to find it when I type owfs? Actually I’m not sure that I successfully installed the whole of OWFS, since I read somewhere that it was not necessary for OH, that only OWSERVER was necessary.

Is the whole of OWFS necessary? If so, how do I install it properly? And how do I verify that it is properly installed? And how do I get it to list all the devices that it finds on the OneWire bus (to prove that everything is working properly)?

Sorry for the interminable questions…

Thank you - Rowan

I don’t know how far did you get, but good luck. I went the OWFS way with the DS9490R in the middle. I lost aloooooot of time, and got it (almost) working in one of the 4 fresh (the most messed up) installs in a row. All of the other times failed, no mater how hard I tried. Thus, what can I say - OH, it it’s current state of development is mostly for enthusiasts with eternity of time available on their hand, who can learn all the internals of the Linux system underneath it, unearth all of the bugs and glitches hidden here and there.
Currently I just dropped the project and left it as it is laying on the table till the moment I will have more time to drain there.