Hello,
today i will share my Experience with the DS 18B20 Temperature Sensor.
The first step is to prepare the Raspberry PI.
edit the file:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
insert the following line
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
and Save it. For gpiopin=4 you can Use every GPIOI Port !
To autostart the 1wire edit the
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
and insert the following lines
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Now is time to Shutdown your Raspberry and connect the DS18B20 as shown in the wiring diagram
		
		
	
	
 
You will see that i use Three Lines (+3.3 / GND / Signal) with 1Wire connection you need a Levershifter to get it stable to run.
Without a Levelshifter it is not possible to get a stable temperature if you use the 1wiring connection.
!!! Attention Don't connect the 3.3V Wire to the 5V this will Destroy your Raspberry !!!
With the connection shown in the wiring diagramm i have seven DS18b20 Sensors running, the longest cable is 12 m long an i have a stable signal.
Now is time to start your Raspberry and test if the 1wire is running.
After the restart you will find in /sys/bus/w1/devices for each sensor a sub directorie which looks like this 28-000007.....
Follow the next step to see if the sesor works
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
on the first line you will receive the CRC and the information if the measured Themperatur is valid, in the second Line you will receive the Temperatur in thousandths of a degree Celsius.
Now you can use the following sample code to read the temp. data please replace 28-0000073c14fa with the ID's from your DS18b20 Sensors!
regards
Andy
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			today i will share my Experience with the DS 18B20 Temperature Sensor.
The first step is to prepare the Raspberry PI.
edit the file:
			
				B4X:
			
		
		
		sudo nano /boot/config.txt
	insert the following line
			
				B4X:
			
		
		
		dtoverlay=w1-gpio,gpiopin=4,pullup=on
	and Save it. For gpiopin=4 you can Use every GPIOI Port !
To autostart the 1wire edit the
			
				B4X:
			
		
		
		sudo nano /etc/modules
	
			
				B4X:
			
		
		
		w1-gpio pullup=1
w1-therm
	Now is time to Shutdown your Raspberry and connect the DS18B20 as shown in the wiring diagram
 You will see that i use Three Lines (+3.3 / GND / Signal) with 1Wire connection you need a Levershifter to get it stable to run.
Without a Levelshifter it is not possible to get a stable temperature if you use the 1wiring connection.
!!! Attention Don't connect the 3.3V Wire to the 5V this will Destroy your Raspberry !!!
With the connection shown in the wiring diagramm i have seven DS18b20 Sensors running, the longest cable is 12 m long an i have a stable signal.
Now is time to start your Raspberry and test if the 1wire is running.
After the restart you will find in /sys/bus/w1/devices for each sensor a sub directorie which looks like this 28-000007.....
Follow the next step to see if the sesor works
			
				B4X:
			
		
		
		cd 28-000007124*
cat w1_slave
0f 00 4b 46 ff ff 06 10 0c : crc=0c YES
0f 00 4b 46 ff ff 06 10 0c t=7375
	on the first line you will receive the CRC and the information if the measured Themperatur is valid, in the second Line you will receive the Temperatur in thousandths of a degree Celsius.
Now you can use the following sample code to read the temp. data please replace 28-0000073c14fa with the ID's from your DS18b20 Sensors!
regards
Andy
			
				B4X:
			
		
		
		Sub Process_Globals
End Sub
'************************************************************************************************************************************************
'**                                                                                                                                            **
'***                                                 Temperaturfühler einlesen                                                                ***
'**                                                                                                                                            **
'************************************************************************************************************************************************
public Sub gettemp As String
    Private tempraw As String
    If File.Exists("/sys/bus/w1/devices/28-0000073c14fa/","w1_slave") Then
        tempraw= File.ReadString("/sys/bus/w1/devices/28-0000073c14fa/","w1_slave")
        'Log ("temperatur: "& tempraw)
        Return readtempCompleted (tempraw)
    Else
        'Log ("Keine Temperatur daten vorhanden")
        Return "-.--"
    End If
End Sub   
'************************************************************************************************************************************************
'**                                                                                                                                            **
'***                                              Temperatur auf gültigkeit prüfen                                                                ***
'**                                                                                                                                            **
'************************************************************************************************************************************************
Private Sub readtempCompleted (StdOut As String) As String
    Private BeckenTemperatur As String
    Private req() As String
    Private temperatur As Float
        req = Regex.Split("=",StdOut)
        If req(1).Contains("YES") Then
            temperatur=req(2)
            temperatur = temperatur/1000
            BeckenTemperatur=temperatur
            If BeckenTemperatur.IndexOf(".") <> -1 Then
                BeckenTemperatur=BeckenTemperatur.SubString2(0,BeckenTemperatur.IndexOf(".")+2)
            End If
        Else
        '    Log("temp. fehler "&DateTime.Date(DateTime.Now)&" "&DateTime.Time(DateTime.now))   
        End If
    Return (BeckenTemperatur)
End Sub