RF Help

D396

Senior Member
i am trying to build a wireless thermometer and I Have a DS18B20, This transmitter http://www.sparkfun.com/commerce/product_info.php?products_id=8945 and this receiver http://www.sparkfun.com/commerce/product_info.php?products_id=8948 i am also using Sparkfuns serial LED display http://www.sparkfun.com/commerce/product_info.php?products_id=9230 although I have not yet attempted to put that in. My problem is that I cant Get the two 08Ms communicating over wireless or even wired. I don't see any problems in my code but maybe you can. Any help is appreciated. Thanks.

Receiver
'Varibles
symbol CHECKSUM = b0
symbol READING = b1
symbol digitone = b2
symbol digittwo = b3
symbol TEMP1 = b4


'serout 1,T2400,(0x7A,0x00)
'serout 1,T2400,(0x78,0x78,0x78,0x78)
'wait 5

rxloop:
'read srial data from reciver
serin 2,N600, READING, CHECKSUM
'check checksum
TEMP1 = CHECKSUM + READING
IF TEMP1 = $FF THEN rxok

rxinvalid:
goto rxloop

rxok:
'islolate digit
digitone = reading / 10
digittwo = reading // 10
'display digit
'serout 1, T2400, (0x78,digitone, digittwo, 0xf)
debug
goto rxloop
Transmitter
' PICAXE 08M Tempurature Transmitter

#picaxe 08m
symbol TXDATA = 2
symbol CHECKSUM = w5
symbol READING = w3



main:
readtemp 1,w1

' w1 is a 16-bit variable which holds an 8 bit number returned from the sensor
' if bit position 7 is high, the temperature is negative, else it is positive
' the absolute temperature value is held in bit positions 0 - 6
' theoretical temperature range is thus -127 to 127 celsius, or -196.6 to 260.6 farenheit
' actual sensor range is -55 to 125 celsius, or -67 to 257 farenheit

' program works for sensor temperatures between -32 and 126 celsius (-25.6 to 258.8 farenheit)
' values outside this range cause overflow/underflow

if w1 < 127 then ' test for positive temperature reading
gosub PosCtoF

gosub transmit ' value of "x" is used as a delimeter for the VisualBasic code
else ' else temperature reading is negative
gosub NegCtoF
if w0 > 17 then

gosub transmit ' value of "x" is used as a delimeter for the VisualBasic code
else

gosub transmit ' value of "x" is used as a delimeter for the VisualBasic code
endif

endif

gosub transmit
goto main

transmit:
CHECKSUM = $FF-READING 'create Checksum
serout TXDATA,N600, ($55, $55, $55, $55, $55, $55,$FF, $00, $01, $7F, READING, CHECKSUM, $AA, $AA, $AA, $AA) ' send serial data to transmitter
low TXDATA ' shut offf transmitter
return

PosCtoF:
' w1 is in celsius; farenheit = 1.8*w1 + 32 = w1 + 8*w1/10 + 32
w2 = 8*w1 / 10 ' w2 holds the integer portion of the value 8*w1/10
w3 = w1 + w2 + 32 ' w3 holds the integer portion of temperature in farenheit
w4 = 8*w1 // 10 ' w4 holds the decimal portion of the value 8*w1/10
' temperature in farenheight is "w3.w4"
return


NegCtoF:
w0 = w1 - 128
w1 = w1 - 128 ' isolate the lower order 7 bits containing the absolute value of the temperature

' w1 is in celsius; farenheit = -1.8*w1 + 32 = -w1 - 8*w1/10 + 32
w2 = 8*w1 / 10 ' w2 holds the (positive) integer portion of the value 8*w1/10
w4 = 8*w1 // 10 ' w4 holds the decimal portion of the value 8*w1/10

w3 = -w1 + 32 ' will not work if temperature is below -32 celsius (-25.6 farenheit)

if w3 <= w2 then
w3 = w2 - w3
else
w3 = w3 - w2 - 1
w4 = 10 - w4
end if

' temperature in farenheit is "-w3.w4"
return
 

Technical

Technical Support
Staff member
these two lines just don't match!

serin 2,N600, READING, CHECKSUM
serout TXDATA,N600, ($55, $55, $55, $55, $55, $55,$FF, $00, $01, $7F, READING, CHECKSUM, $AA, $AA, $AA, $AA)

did you cut and paste this from elsewhere - why all the extra data bytes?

Try this as a starter, althought it would be better to get rid of the unused data
serin 2,N600, ($FF, $00, $01, $7F),READING, CHECKSUM
 

lbenson

Senior Member
Don't you need a qualifier (as technical put it) with your serin so that you know where to start reading, e.g.

serin 2,N600, ($01, $7F),READING, CHECKSUM
 
Top