Adding a DS18B20 to axe132 board

marks

Senior Member
Rich (BB code):
                          C.2
                           o
               _       _______
    V +       / \     /       \    GND
     o   o   o   o   o    o    o    o    AXE132 unused pads showing existing onboard links.
     1    \______________/          8
For an upcoming project I wanted to add a ds18b20
but also needed a pin for a pushbutton here we share the same pinC.2
The programming socket has been replaced with pins because when installed
I will no longer have access to that side.

supply will be 5v so will use the standard 4.7k pullup to the datapin of the ds18b20
which we solder to pads 6(v+) 7(data) 8(gnd) and(C.2)
if we bend all 3 leads 90 degrees about 4mm from their ends towards the c.2pad
then push the ds18b20 in place as far as possible
we should be then able to push the end of the datapin angled straight into the c.2 pad (creating a link).

the 4.7k resistor is placed in pads 1 and 5 , I also wanted to create a 5v pin for programming.
with the resistor lead from pad 1 also loop into the two support holes for the unused socket
and back into pad2 creating a common 5v link.you can then press a pin into the non soldered hole
with the resistor lead looped in it ,soldering to this makes it very strong when we dont have a soldered pad.

To add a switch if required just use the H3 terminations. connect a switch in series with a 47k resistor
between C.2 and 0v connections. When pressed this only drops the data high levels 10% (4.5v)so data
from the ds18b20 sensor will be unaffected.
axe132withds18b20.JPGaxe132ds18b20n.JPG
 

marks

Senior Member
now some code to test ...
will display Celsius temperature with minimum and maximum cycling evry 15secs on line 2 of an OLED display.
If switch is pressed on release will swap to Fahrenheit .
If switch is held it will eventually display (reset) release min/max will start again.
Rich (BB code):
#picaxe 18m2    'version D.A AXE132 8Bit marks                               

 SYMBOL E        = C.6                              
 SYMBOL RS       = C.7
 SYMBOL DS18B20  = C.2  ' 1431 C4  +662AB
 SYMBOL Switches = C.2    ' 
 SYMBOL senddata     = pinsb
 SYMBOL index        = b0
 SYMbol PushButton   = b1
 SYMBOL Temperature  = W1  SYMBOL TempMsb   = b3  SYMBOL TempLsb  = b2
 SYMBOL Counter      = b4  
 SYMBOL Sign         = b5
 SYMBOL D0           = b10
 SYMBOL D1           = b11 
 SYMBOL D2           = b12 
 SYMBOL D3           = b13 
 SYMBOL D4           = b14
 SYMBOL Lo           = W8
 SYMBOL Hi           = W9
 
SETFREQ M32
     dirsB = %11111111            
     dirsC = %11001011
 EEPROM 10,(6 ,9 ,9 ,6 ,0 ,0 ,0 ,0) ' load custom character (o) =0 degrees symbol
 EEPROM 18,(0 ,17,27,21,17,17,17,0) ' load custom character (M) =1
Initialise:    
    FOR  index = 0 to 7 
          LOOKUP index, ($38,$38,$38,$08,$01,$02,$06,$0C),senddata : PULSOUT E,1 ' Initialise LCD/OLED
          '(8bit/2line/5x8)*3(Display Off)(Clear Display)(Return Home)(Entry Mode Set)(Display On)
     NEXT index : PAUSE 10 
    
      LoadCustomCharactersFromEEPROM:
       LOW RS : senddata = $40 : pinsB = senddata : PULSOUT E,1 : HIGH RS ' Load Characters to LCD    
     FOR  index =10 TO 25                 
         READ index, senddata : pinsB = senddata : PULSOUT E,1 ' sending characters to LCD      
     NEXT index    
    
      Default:  d0="C"  ' "C"for Celsius  "F"for Fahrenheit
      ResetMinMax:  Hi = 0 : Lo = 2927        
Main: 
  ReadADC Switches,pushbutton : LET pushbutton=pushbutton/242+1//2  '(4.7k/47k()230)
   let adcsetup = %1000000000 ' reenable digital pin for DS18B20
  
  IF pushbutton = 0 THEN  
   IF counter >0 AND counter <6 Then   
      If d0 = "C" then let d0 = "F" : goto ResetCounter: endif
      If d0 = "F" then let d0 = "C" : endif
   Endif
   ResetCounter: counter = 0
  ENDIF

  DisplayTemperatureMinMax:
  
   ReadTEMP12 DS18B20,Temperature 
       Temperature = Temperature + 880 
       IF Temperature > Hi THEN LET Hi = Temperature: ENDIF
       IF Temperature < Lo THEN LET Lo = Temperature: ENDIF
      
  IF d0 ="C" then : Temperature = Temperature * 5 / 8 -550 :endif 'Celsius 
  IF d0 ="F" then : Temperature = Temperature * 9 / 8 -670 :endif 'Fahrenheit
 
       Sign = " " : IF TempMsb > 127 THEN : Temperature = -Temperature : Sign = "-" : ENDIF     
                  BinTOASCII Temperature,D4,D4,D3,D2,D1 
                  IF  D4 = "0" THEN : D4 = Sign                      ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = Sign : D4 = " " : ENDIF   ' leading zero blanking 
              ENDIF 
        
           LOW  RS : senddata = 192 : PULSOUT E,1                    ' commandmode (128)Line 1 (192)Line 2
           HIGH RS                                                   ' charactermode
           FOR  index = 0 TO 8
               LOOKUP index,(D4,D3,D2,".",D1,0,D0," ",1),senddata : PULSOUT E,1 
           NEXT index 
     
    IF pushbutton = 1 THEN : INC counter :  ENDIF 
     IF counter >5 THEN
         FOR  index = 0 TO 6
               LOOKUP index,("  reset"),senddata : PULSOUT E,1    
         NEXT index
      GOTO ResetMinMax
     ENDIF
           sign=Time//2 ' change state every 15 secs time extended due to using Readtemp12 
        if sign=0 then: Temperature = Lo : senddata = "i" : PULSOUT E,1 : senddata = "n" :endif
        if sign=1 then: Temperature = Hi : senddata = "a" : PULSOUT E,1 : senddata = "x" :endif: PULSOUT E,1 
    
       IF d0 ="C" then : Temperature = Temperature * 5 / 8 -550 :endif 'Celsius 
       IF d0 ="F" then : Temperature = Temperature * 9 / 8 -670 :endif 'Fahrenheit
     
        Sign = " " : IF TempMsb > 127 THEN : Temperature = -Temperature : Sign = "-" : ENDIF     
                   BinTOASCII Temperature,D4,D4,D3,D2,D1            
                  IF  D4 = "0" THEN : D4 = Sign                      ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = Sign : D4 = " " : ENDIF   ' leading zero blanking 
              ENDIF           
            FOR  index = 0 TO 4
               LOOKUP index,(D4,D3,D2,".",D1),senddata : PULSOUT E,1    
            NEXT index                                                                                         
GOTO Main
 
Top