Temp

Joeroddis

Member
Will this simple program read the temperature ok and display it on the computer screen?
Will it be a value between 0 and 256? or and actual temperature?

Main:
readtemp 0,b0
pause 200
debug b0
pause 200
goto main

Cheers
 

eclectic

Moderator
Joe.

First of all, which Picaxe are you using?

Then, have you set up the circuit EXACTLY as it is shown,
in Manual 2 page 128?

e.
 

eclectic

Moderator
If everything is connected correctly, then the code should work.

Or, try

sertxd (#b0,cr,lf)

It will be easier to read.

And yes, it will output directly in degrees Celsius.

e.
 

Joeroddis

Member
All works :) my room is 27 degrees :eek:

And regarding the negative:

main:
readtemp 1,b1 ‘ read value into b1
if b1 > 127 then neg ‘ test for negative
serout 7,N2400,(#b1) ‘ transmit value to serial LCD
goto loop
neg:
let b1 = b1 - 128 ‘ adjust neg value
serout 7,N2400,(“-”) ‘ transmit negative symbol
serout 7,N2400,(#b1) ‘ transmit value to serial LCD
goto main

That is in manual 2, page 128
 

westaust55

Moderator
Hi Joe,

If you wish to look at a greater resolution (tenths of a degree) then use the READTEMP12 command. You still need to handle the negative numbers with some extra maths but for temps above 0 deg C here is my basic code snippet:

Code:
READTEMP12, pin, w0

w0=w0*10/16

Degrees = w0 /10
Tenths  = w0//10

SEROUT pin, N2400 (“Temp = “,#degrees,”.”,#tenths)
you can change the last line of code to use the previously suggested SERTXD command.
 

Joeroddis

Member
Ah thankyou westaust55 that looks interesting. When i get my circuit working ill be sure to add it in and give feedback!
 
Top