Page 1 of 1

DS18B20 Directly connected to a RPI

Posted: Tuesday 30 October 2018 11:48
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

Re: DS18B20 Directly connected to a RPI

Posted: Tuesday 30 October 2018 13:36
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.

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 31 October 2018 14:30
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!

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 31 October 2018 17:59
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)

Re: DS18B20 Directly connected to a RPI

Posted: Saturday 08 June 2019 6:18
by chrisfraser05

Re: DS18B20 Directly connected to a RPI

Posted: Tuesday 02 July 2019 22:21
by kimot
Domoticz wiki does not works?

https://www.domoticz.com/wiki/1Wire

Re: DS18B20 Directly connected to a RPI

Posted: Tuesday 02 July 2019 22:50
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 5461 times

Re: DS18B20 Directly connected to a RPI

Posted: Sunday 21 June 2020 10:52
by pannekoek
Well, it seems that I have the same problem. Were there any solutions to get this going?
Thanks in advance

Re: DS18B20 Directly connected to a RPI

Posted: Sunday 21 June 2020 13:09
by pannekoek
Refresh devices did the job. PANNEKOEK. Some day everything is ok

Re: DS18B20 Directly connected to a RPI

Posted: Sunday 21 June 2020 13:36
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

Re: DS18B20 Directly connected to a RPI

Posted: Sunday 21 June 2020 23:53
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.

Re: DS18B20 Directly connected to a RPI

Posted: Tuesday 30 June 2020 22:24
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

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 01 July 2020 15:22
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

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 01 July 2020 17:24
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.

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 01 July 2020 18:14
by uzturre

Re: DS18B20 Directly connected to a RPI

Posted: Wednesday 01 July 2020 19:45
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.

Re: DS18B20 Directly connected to a RPI

Posted: Sunday 05 July 2020 23:24
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?