Dallas DS18B20 Temperature Sensor
Dallas DS18B20 Temperature Sensor

PICAXE-18M2 with Dallas DS18B20 Temperature Sensor

by Lewis Loflin

The Dallas Semiconductor DS18B20 Centigrade temperature sensor is accurate, cheap, and easy to use. This fits perfectly with a PICAXE micorcontroller with built in routines to operate the component. A single input pin is all that's needed. The program below displays the temperature on a terminal. Note that the PICAXE-18M2 does not do decimal points.

The best applications include a simple heat controller operating a solid sate relay, etc. Also, PICAXE-18M2 Pin Connections.


#picaxe 18m2 ; type chip used

; set internal frequency of PICAXE to 4 mHz.
; setfreq m4  
; All M2 - k31, k250, k500, m1, m2, m4, m8,m16, m32

; set terminal 4800, must be run at 4 mHz.; readtemp page 184

symbol sensor_pin = B.7
symbol temperature_value = b0

main:

pause 1000 ; 700 mSec delay between readings

readtemp sensor_pin, temperature_value

sertxd("T C : ", #temperature_value, " deg.", 13, 10)

goto main

Picaxe Micro-controller Projects!

The PICAXE series of micro-controllers rank as the easiest and most cost effective way to use Microchip processors. I wanted an easier and less expensive way to introduce my students to the "PIC" micro-controller. Here I hope to get those starting out past poorly written literature and lack of simple working code examples.

See How I got into Electronics

 


donate