DS18B20 Directly connected to a RPI

Moderator: leecollings

Post Reply
crazynight
Posts: 13
Joined: Saturday 07 October 2017 18:05
Target OS: -
Domoticz version:
Contact:

DS18B20 Directly connected to a RPI

Post by crazynight »

Is it possible to have a DS18B20 directly connected to the RPI which is running domoticz, it seems overkill to have the RPI and a nodemcu in the same room.

Some simple instructions or a link to some would be appreciated.

TIA
Domoticz v3.8153 - Rpi
RFLink r48- Arduino Mega Chinese 433 RX TX
2x bye bye Standby Switches
TP-Link HS100
1x DHT11 & 1x ds18B20 connected directly yo the RPi
Nodemcu flashed with ESPEasy
1x ds18B20 connected to the Nodemcu
mtsinc
Posts: 6
Joined: Monday 29 October 2018 17:45
Target OS: Linux
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by mtsinc »

I don't see why not. Adafruit has an example of the DS18B20 connected to a Pi GPIO port and the Pi is a multi-tasking OS.

https://learn.adafruit.com/adafruits-ra ... g/hardware

The tricky part is in figuring out what channel to feed the measurements into Domoticz with. But if a superficial reading of the above article is correct, then I think that they're publishing the sensor as an OS device whose name can be used in the 1Wire device hardware configuration.
rv24531
Posts: 10
Joined: Thursday 13 September 2018 1:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Chatham, VA
Contact:

Re: DS18B20 Directly connected to a RPI

Post by rv24531 »

I currently do it with a mix of Node-Red and json post data into a virtual temperature sensor.

Although I only use Node-red because I have other magic going on that pushes data into Domoticz, I'm sure there are perl/php/others out there that can come up with a command line and cron script to automatically post this data into domoticz, however Node-Red makes it a piece of cake to pull and temperature and output it into a message.

As far as the http post/get command, this is what I use in reference to the Domoticz/JSON commands ... localhost:8088/json.htm?type=command&param=udevice&idx=19&nvalue=0&svalue={{payload}} and it sends updates the sensor (IDX #19) with the value.

Piece of cake, maybe a overkill, but it takes longer to install node-red than it does to set it up to push data into Domoticz :)

Also, don't forget to ENABLE 1-wire support in raspi-config or it will never work :)

Need help, just ask!
gerardvs
Posts: 81
Joined: Sunday 04 January 2015 0:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest-1
Location: /dev/null
Contact:

Re: DS18B20 Directly connected to a RPI

Post by gerardvs »

I do almost the same to measure the temperature of the cabinet where the pi is situated and use a simple quick and dirty python script.

Code: Select all

import os
import glob
import time
import requests

# sometimes needed
#os.system('modprobe w1-gpio')
#os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '10*')[0]
device_file = device_folder + '/w1_slave'

idx = "67"	
dUrl = "http://localhost:8080"


def read_temp_raw():
   f = open(device_file, 'r')
   lines = f.readlines()
   f.close()
   return lines

def read_temp():
  lines = read_temp_raw()
  while lines[0].strip()[-3:] != 'YES':
     time.sleep(0.2)
     lines = read_temp_raw()
  equals_pos = lines[1].find('t=')
  if equals_pos != -1:
     temp_string = lines[1][equals_pos+2:]
     temp_c = float(temp_string) / 1000.0
     return temp_c

degree = read_temp()

sensUrl = dUrl + "/json.htm?type=command&param=udevice&idx=" + idx + "&nvalue=0&svalue=" + str(round(degree,1))
r = requests.get(sensUrl)
chrisfraser05
Posts: 32
Joined: Sunday 08 January 2017 18:59
Target OS: Windows
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by chrisfraser05 »

kimot
Posts: 105
Joined: Saturday 25 November 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

Re: DS18B20 Directly connected to a RPI

Post by kimot »

Domoticz wiki does not works?

https://www.domoticz.com/wiki/1Wire
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by alarm_guy1 »

The Wiki is correct.
I have followed the instructions and it is working.
However what is Ambiguous is this line
Note: When using GPIO, set OWFS Path to nothing. After adding 1-wire (system) the sensors will eventually show up in the log.

SEE ATTACHED PIC
1WIRE.jpg
1WIRE.jpg (187.99 KiB) Viewed 5328 times
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Well, it seems that I have the same problem. Were there any solutions to get this going?
Thanks in advance
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Refresh devices did the job. PANNEKOEK. Some day everything is ok
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by alarm_guy1 »

I now use an Esp8266-01 running easyesp with a temp sensor DS18B20, I am lucky enough to have access to my wired alarm and use a 12v to 3.3v regulator to power the ESP, being wireless they are cheap too
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Yes, I use a nodemcu. Works very nice. The only thing is that there is only room for a few sensors.

And the place where I want to put these, there is no wifi.
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Well, there are some problems. The ds18b20’s direct connected to the raspberry seem to freze after a few hours. They keep displaying the same temp.
The sensors conected via a nodemcu keep working without a problem.
Any idea someone?
Thanks already
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by alarm_guy1 »

Yes I have 2 running now for some months, 1 upstairs and one downstairs both on ESP8266-01's flashed with mega-20190903
One is powered from my alarm panel and the other via a power supply maybe 12v down to 3.3v. all appear to work well then I have another on on a Fibaro module outside. I also have a unit ping setup for my various Esp's, they get pinged every 20mins or so and if they go down I get an email.... Since march this year neith ESP has given me any issues
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Here the same, but without email notification. Esp is running great. But the place where I want to measure too has no wifi, only lan. So I connected three bs18 direct to the raspberry. Runs ok, but only for a short time. Don't know what could be wrong.
uzturre
Posts: 14
Joined: Wednesday 13 June 2018 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Basque Country
Contact:

Re: DS18B20 Directly connected to a RPI

Post by uzturre »

pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Thanks, already followed all those steps. Just did it again. Can't find anything. Maybe bad connection somewhere? It functions for some hours and then stays at exact the same temp.
pannekoek
Posts: 7
Joined: Sunday 21 June 2020 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DS18B20 Directly connected to a RPI

Post by pannekoek »

Ok, it seems a cable problem. We'll see what happens this week.

And now e-mail notifications? We use office 365 but can't get the job done. Raspberry is only for my lokal network. Is that a problem?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest