Comments on: Raspberry Pi: Temperature Readings with DS18B20 Sensor (Python) https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Fri, 28 Nov 2025 12:42:59 +0000 hourly 1 https://wordpress.org/?v=6.8.5 By: niles https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-1128216 Fri, 28 Nov 2025 12:42:59 +0000 https://randomnerdtutorials.com/?p=133368#comment-1128216 In reply to Sara Santos.

Dear Sara,

that’s very kind, but unfortunately it is useless regarding the reusability of the code. This will need a proper Open Source license, unless then it is always under your copyright.

Regards
niles

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-1125410 Wed, 19 Nov 2025 11:54:30 +0000 https://randomnerdtutorials.com/?p=133368#comment-1125410 In reply to niles.

Hi.
You can use our code in your projects.
You just need to add a reference to this tutorial.
Regards,
Sara

]]>
By: niles https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-1125124 Tue, 18 Nov 2025 10:01:51 +0000 https://randomnerdtutorials.com/?p=133368#comment-1125124 Hi, thanks for your amazing tutorial, this was really really helpful in understanding and initially using the sensors on the PI.

I would like to use and adapt the code. However, since the result is supposed to be Open Source (probably MIT license, like adafruit, or similar permissive) it would be great to have your snippet Open Source as well.

Currently it is lacking a license and thereby is under copyright, which may not be used without your permission and will always be under restrictions.
Regards
niles

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-900958 Tue, 26 Mar 2024 14:58:13 +0000 https://randomnerdtutorials.com/?p=133368#comment-900958 In reply to Alessandro.

Thanks for sharing this info.
Regards,
Sara

]]>
By: Alessandro https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-900767 Mon, 25 Mar 2024 14:12:04 +0000 https://randomnerdtutorials.com/?p=133368#comment-900767 Hi,

ended up here following the comments of one of my students. Great work, I especially like the description of the hardware setup.

I think the code has a possible pitfall: when the RPi has seen two sensors of the same family, this code might return the the data of a sensor that has been removed (e.g. replaced due to damage). This is not a scenario where two sensor are on the bus, but a maintenance scenario when only one sensor is deployed.

Furthermore, for people who are just interested in getting things done, pypi.org/project/w1thermsensor/ might be a better starting point.

]]>
By: Brian https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-884501 Wed, 17 Jan 2024 02:31:37 +0000 https://randomnerdtutorials.com/?p=133368#comment-884501 In reply to Mark.

I haven’t had a issue since I replaced the 4.7k ohm pull with a 2.2k I am powering my 1-wire buss with 3.3v and not parasitic.

]]>
By: Mark https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-884431 Tue, 16 Jan 2024 19:17:29 +0000 https://randomnerdtutorials.com/?p=133368#comment-884431 In reply to Brian.

Did you ever figure this one out? I have the one sensor setup working fine, but would like to have 2 sensors (two aquariums).

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-883227 Wed, 10 Jan 2024 23:43:42 +0000 https://randomnerdtutorials.com/?p=133368#comment-883227 In reply to Benoit.

Hi.
Yes. I tried, but I get better results with “normal” mode.
You can try both ways and see which one works best for your scenario.
Regards,
Sara

]]>
By: Benoit https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-883127 Wed, 10 Jan 2024 12:25:36 +0000 https://randomnerdtutorials.com/?p=133368#comment-883127 HI? Great job !
Are you try to use the parasite mode to supply ?
Tks

]]>
By: Brian https://randomnerdtutorials.com/raspberry-pi-ds18b20-python/#comment-874632 Tue, 28 Nov 2023 04:18:37 +0000 https://randomnerdtutorials.com/?p=133368#comment-874632 I have modified the code to read multiple sensors. The trouble is the function randomly returns a value of 85c. Any suggestions?

#!/usr/bin/python3
import os
import glob
import time
base_dir = ‘/sys/bus/w1/devices/’

os.system(‘modprobe w1-gpio’)
os.system(‘modprobe w1-therm’)

device_folder = glob.glob(base_dir + ’28‘)
NumDev=(len(glob.glob(base_dir + ’28
‘)))
#values=range(NumDev)

def read_temp_raw(device):
f = open(device, ‘r’)
lines = f.readlines()
f.close()
return lines

def read_temp(device):
global temp_c
lines = read_temp_raw(device)
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
temp_f = temp_c * 9.0 / 5.0 + 32.0
return temp_c, temp_f

#list comprehension
device_file = [x + ‘/w1_slave’ for x in device_folder]\

print(‘Found ‘,NumDev,’Sensors’)

for a in device_file:
print(read_temp(a))

#print(read_temp(device))

]]>