Introduction: Picaxe Based Digital Thermometer With Max and Min

(Please leave a message, but don't be too critical, this is my first instructable!!)

This is a thermometer I made for our camper-van, to show the external temperature. It is based on a Picaxe chip as they are cheap and easy to use.

If this is for a vehicle, see this voltage regulator instructable for how to regulate the voltage . 

The finished circuit and circuit diagram are pictures below or, if you aren't a member, on the last two pages.

You will need:
1X Breadboard (or you can solder it onto verro board, but I'd test it on breadboard first.)
1X Axe033 LCD display or 2x16 LCD screen such as the one sold by
Milford Instruments (6-111) with driver board
1X Picaxe 14M (or other picaxe chip, if you use a different one you will need to look up the pinouts)
1X Digital temperature sensor
1X picaxe programming cable
Some Verro board (stereo plugs don't work on breadboard)
2X 10K resistor
1X 22K resistor
1X 47K resistor
1X 3.5mm stereo plug
1X push to make switch
1X 4.5V battery pack
Picaxe Programming Editor


Step 1: Connect Battery Pack

 Step One: Connect the battery pack to the two outside tracks on the breadboard. 

Step 2: Plug in Chip

 Step 2: Plug the Chip in, roughly in the centre of the board, so that the legs are on either side of the gap down the middle. 

Step 3: Connect Power to the Chip

 Step 3: Connect the first leg away from V+ on the chip to V+, and the 0V opposite to 0V. . 

Step 4: Make the Programming Interface

 Step 4:
Cut the verro board so that the tracks are running lengthways. 
Solder on the stereo plug so that it slightly overhangs the edge. 
Solder in the 10K resistor between the two outside pins on the stereo plug.
Solder the 22K resistor between the right hand pin and a spare track. 
Solder three wires, one to the middle pin on the socket, one to the end of the 10K resistor and one to the end of the 22K resistor. 

Step 5: Plug in the Programming Interface

Step 5:
Connect the wire form the centre pin to the serial output. 
Connect the wire from the 22K resistor to serial input.
Connect the other wire to 0V.

Step 6: Connect the Temperature Sensor

 Step 6: 
Plug the sensor into the breadboard with the rounded face pointing out. 
Connect the right hand leg to V+.
Connect the left hand leg to 0V.
Connect the middle leg to input 1. 
Connect the 47K resistor from the same pin on the chip to V+.

Step 7: Connect the Switch

 Step 7:
Plug one end of the switch to V+. 
Connect the other end to 0V with a 10K resistor and input 2 with a 1K resistor. 

Step 8: Connect the Screen

 Step 8:
Connect a wire to the pads marked "In", "V+" and "0V" on the screen.
Connect the V+ and 0V to, you'll never guess, V+ and 0V. 
Connect the In wire to output 1. 

Step 9: Program the Screen

 Step 9:
If you are using the screen from Milford Instruments then skip to step 11.
Plug the circuit into the computer with the cable.
Open Picaxe Programming Editor. 
Set it to 14M and the correct COM port for the cable. 
Type in this code:

init: pause 500
main: serout 1,N2400, (253,1,"External:       ")
pause 1000
serout 1,N2400,(253,2,"Temperature     ")
pause 1000
serout 1,N2400, (253,3,"Max. Temp:      ")
pause 1000
serout 1,N2400,(253,4,"Min. Temp:      ")
pause 1000
end

Turn the power on. 
Press program.


This code writes four messages into the screen's memory to save spave on the chip. They will be called up in the program that will run on the chip. 

Remember to turn the power on while trying to program.

Step 10: Program the Chip

 Type in this code:

init: pause 500` wait for screen to initialise so data is not lost
serout 1,N2400,(1)`display saved message 1 :"External :" on top line
pause 5`wait for it to work
serout 1,N2400, (2)`display saved message 2 :"Temperature" on bottom line
readtemp 1,b1`read temperature initially to get reading for minimum temperature
b6 = b1`set minimum temperature as current so it doesnt display 0
setint %00000100,%00000100`set interrupt to common input pin (input 2)

Interrupt:
gosub Maxmin`go to screen showing max and min temperatures
setint %00000100,%00000100`reset interrupt because it is cancelled when it is tripped

Maxmin:
serout 1,N2400,(3)`display saved message 3 :"Max. Temp:" on top line
pause 5`wait for it to work
serout 1,N2400, (4)`display saved message 4 :"Min. Temp:" on bottom line
pause 5`wait for it to work
serout 1,N2400,(254,140,#b5," C")        `show maximum temperature (variable b5) then " C"
pause 5`wait for it to work
serout 1,N2400,(254,204,#b6," C")`show minimum temperature (variable b6) then " C"
wait 10`wait 10 seconds to allow time to read
serout 1,N2400,(1)`display saved message 1 :"External :" on top line
pause 5`wait for it to work
serout 1,N2400, (2)`display saved message 2 :"Temperature" on bottom line

Celcius: 
readtemp 1,b1
serout 1,N2400,(254,140,#b1," C")
serout 1,N2400,(254,140)
if b1 > b5 then goto GT `test whether new max temperature
if b1 < b6 then goto LT `test whether new min temperature
goto Celcius

GT: 
b5 = b1 `set new max temperature
goto Celcius

LT:
b6 = b1 `set new min temperature
goto Celcius

Click run and program the chip. Remember to turn on the power to the chip while programming.
If nothing shows then adjust the contrast on the back of the driver board. It is a small potentiometer.

Step 11: Other Screen Code

 Program the chip with this code.

init: pause 1000                               `wait for screen to initialise so data is not lost
serout 1,N2400,("External:")
serout 1,N2400,(254,192,"Temperature")
readtemp 1,b1    
b6 = b1                                               `set minimum temperature as current so it doesnt display 0
setint %00000100,%00000100    `set interrupt to common input pin (input 2)
goto Celcius

Interrupt:  
serout 1,N2400,(254,128,"Max. Temp:     ")
serout 1,N2400,(254,192,"Min. Temp:     ")
serout 1,N2400,(254,140,#b5," C")               `show maximum temperature (variable b5) then " C"
serout 1,N2400,(254,204,#b6," C")               `show minimum temperature (variable b6) then " C"
wait 5                                                                   `wait 5 seconds to allow time to read
serout 1,N2400,(254,128,"External:      ")
pause 10
serout 1,N2400,(254,192,"Temperature     ") `go to screen showing max and min temperatures
setint %00000100,%00000100                   `reset interrupt because it is cancelled when it is tripped
return                                                                 `go back to where it was interrupted

Celcius:
readtemp 1,b1
serout 1,N2400,(254,140,#b1," C")
serout 1,N2400,(254,140)
if b1 > b5 then gosub GT                                 `test whether new max temperature
if b1 < b6 then gosub LT                               
goto Celcius


GT:
b5 = b1                                                                 `set new max temperature
return

LT:
b6 = b1                                                                 `set new min temperature
return


Click run and program the chip. Remember to turn on the power to the chip while programming.
If nothing shows then adjust the contrast on the back of the driver board. It is a small potentiometer

Step 12: Circuit Diagram

(For non-members!)

Step 13: Finished Circuit