multiple DS18B20

Armagon

Member
Dear All:

I will need to connect four sensors DS18B20 into PICAXE 18X, one for each input, 0,1,2 and 7, but I need to know how connect them and how display the reading into LCD

Thanks
________
Daytona
 
Last edited:

inglewoodpete

Senior Member
I connected 3 DS18B20 sensors and an LCD display to an 08M successfully. I'll have to search for the code that I used. (On my PC at home - I'm at work at the moment)
 

inglewoodpete

Senior Member
Hi Armagon, This is the code I used to test 2 or 3 DS18B20 temperature sensors.

The code presented here is limited to 2 sensors due to the particular hardware configuration that I used with the AXE-092 board. My Serial LCD module plugs into header H2 which is hard wired to pin 1.
<code><pre><font size=2 face='Courier'>
'Read temperatures and display on Serial LCD
'Written for PICAXE 08M (AXE-092 Board)
' Tested on 08M firmware 9.1
' 01-Dec-2006 196 bytes Peter Gee &quot;inglewoodpete&quot;
'
'Decimal pesentation code courtesy Peter Anderson
' http://www.phanderson.com/picaxe/index.html
'
'***** Definitions *****
' Variables
Symbol TBinary = w0
Symbol Tx100 = w1
Symbol Whole = b2
Symbol LoFract = b1
Symbol Fract = b1
Symbol HiFract = b0
' Hardware
Symbol RedLED = 0 'Pin 0
Symbol LCD = 1 'Pin 1
Symbol Green = 1 'Pin 1 Temperature sensor in roof gable
Symbol White = 2 'Pin 2 Temperature sensor in living room
Symbol Yellow = 4 'Pin 4 Temperature sensor in roof space
'
Symbol NotPressed = 0
Symbol Pressed = 1
'***** End of Definitions *****
'
Init: 'Initialisation of specific LCD module
High LCD
Pause 5000
SerOut LCD, T2400, (&quot;?G216&quot;) 'Set to 2 x 16
Pause 500
SerOut LCD, T2400, (&quot;?c0?f&quot;) 'No cursor + home
Pause 500
'User defined character 0 configured as 'degrees' character
'0-..x.. '04
'1-.x.x. '0a
'2-..x.. '04
'3-..... '00
'4-..... '00
'5-..... '00
'6-..... '00
'7-..... '00
'0-..... '00
SerOut LCD, T2400, (&quot;?D0040a040000000000&quot;) 'bit pattern for 'degrees'
Pause 1000 'Settling (loading) time
'
Main: High RedLED
Do Until Input3 = Pressed
'Wait for key press
Loop
'
Readtemp12 Yellow, TBinary 'from Yellow wire
SerOut LCD, T2400, (&quot;RoofSpace:&quot;)
Gosub Conv2Decimal
'
Readtemp12 White, TBinary 'from White wire
SerOut LCD, T2400, (&quot;?y1?x00Livg Room:&quot;)
Gosub Conv2Decimal
'
' Readtemp12 Green, TBinary 'from Green wire
' SerOut LCD, T2400, (&quot;Inside Gable:&quot;)
' Gosub Conv2Decimal
'
Do While Input3 = Pressed
'Wait for key release
Loop
Low RedLED
Goto Main
'
Conv2Decimal:
'Decimal pesentation code courtesy Peter Anderson
' http://www.phanderson.com/picaxe/index.html
'Convert TBinary to a decimal string
' to two decimal places
' and transmit it to the terminal
Tx100 = TBinary * 6
TBinary = TBinary * 25 / 100 'a quarter
Tx100 = Tx100 + TBinary
Whole = Tx100 / 100
Fract = Tx100 % 100
HiFract = Fract / 10
LoFract = Fract % 10
'
if Whole &lt; 10 then 'Pad out temperatures under 10deg C
SerOut LCD, T2400, (&quot; &quot;)
EndIf
SerOut LCD, T2400, (#Whole, &quot;.&quot;, #HiFract, #LoFract, &quot;?0&quot;) '8 chars
Return
</font></pre></code>
 
Top