help temperature sensor with 912mhz RF modules
Tomvn
Posts: 103
Hi all , i have two Bs2 module one with temperature sensor, i can rx temperature data·on one stamp then i like to send that temperature data to another bs2 module·via rf 912mhz so can anyone help to write code,·please.
Post Edited (Tomvn) : 9/17/2009 5:18:34 PM GMT
Post Edited (Tomvn) : 9/17/2009 5:18:34 PM GMT
Comments
Do you have some generic code for the 912mhz RF units?, One would also need some info on the temperature modules your using?
If you have some code started, post it... This will help the most.
___Willing to help,But need more info__________________$WMc%_________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
so i like to send that output to another BS2.
' I/O Definitions
'
ShtData PIN 6 ' bi-directional data
Clock PIN 7
'
' Constants
'
ShtTemp CON %00011 ' read temperature
ShtHumi CON %00101 ' read humidity
ShtStatW CON %00110 ' status register write
ShtStatR CON %00111 ' status register read
ShtReset CON %11110 ' soft reset
Ack CON 0
NoAck CON 1
No CON 0
Yes CON 1
DegSym CON 186 ' degrees symbol for DEBUG
'
' Variables
'
ioByte VAR Byte ' data from/to SHT11
ackBit VAR Bit ' ack/nak from/to SHT11
toDelay VAR Byte ' timeout delay timer
timeOut VAR Bit ' timeout status
soT VAR Word ' temp counts from SHT11
tC VAR Word ' temp - Celcius
tF VAR Word ' temp - Fahrenheit
soRH VAR Word ' humidity counts
rhLin VAR Word ' humidity; linearized
rhTrue VAR Word ' humidity; compensated
status VAR Byte ' status byte
'
' EEPROM Data
'
'
' Initialization
'
Initialize:
GOSUB SHT_Connection_Reset ' reset device connection
PAUSE 250 ' let DEBUG window open
DEBUG CLS,
"SHT11 Sensor Demo", CR,
"
", CR
'
' Program Code
'
Main:
DO
GOSUB SHT_Measure_Temp
DEBUG CRSRXY, 0, 3,
"soT...... ", DEC soT, CR,
"tC....... ", DEC (tC / 10), ".", DEC1 tC, DegSym, " ", CR,
"tF....... ", DEC (tF / 10), ".", DEC1 tF, DegSym, " "
GOSUB SHT_Measure_Humidity
DEBUG CRSRXY, 0, 7,
"soRH..... ", DEC soRH, CR,
"rhLin.... ", DEC (rhLin / 10), ".", DEC1 rhLin, "% ", CR,
"rhTrue... ", DEC (rhTrue / 10), ".", DEC1 rhTrue, "% "
PAUSE 1000
LOOP
END
'
' Subroutines
'
' connection reset: 9 clock cyles with ShtData high, then start sequence
'
SHT_Connection_Reset:
SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]$FFF\9]
' generates SHT11 "start" sequence
' _____ _____
' ShtData |_______|
' ___ ___
' Clock ___| |___| |___
'
SHT_Start:
INPUT ShtData ' let pull-up take high
LOW Clock
HIGH Clock
LOW ShtData
LOW Clock
HIGH Clock
INPUT ShtData
LOW Clock
RETURN
' measure temperature
' -- celcius = raw * 0.01 - 40
' -- fahrenheit = raw * 0.018 - 40
'
SHT_Measure_Temp:
GOSUB SHT_Start ' alert device
ioByte = ShtTemp ' temperature command
GOSUB SHT_Write_Byte ' send command
GOSUB SHT_Wait ' wait for measurement
ackBit = Ack ' another read follows
GOSUB SHT_Read_Byte ' get MSB
soT.HIGHBYTE = ioByte
ackBit = NoAck ' last read
GOSUB SHT_Read_Byte ' get LSB
soT.LOWBYTE = ioByte
' Note: Conversion factors are multiplied by 10 to return the
' temperature values in tenths of degrees
tC = soT ** $1999 - 400 ' convert to tenths C
tF = soT ** $2E14 - 400 ' convert to tenths F
RETURN
' measure humidity
'
SHT_Measure_Humidity:
GOSUB SHT_Start ' alert device
ioByte = ShtHumi ' humidity command
GOSUB SHT_Write_Byte ' send command
GOSUB SHT_Wait ' wait for measurement
ackBit = Ack ' another read follows
GOSUB SHT_Read_Byte ' get MSB
soRH.HIGHBYTE = ioByte
ackBit = NoAck ' last read
GOSUB SHT_Read_Byte ' get LSB
soRH.LOWBYTE = ioByte
' linearize humidity
' rhLin = (soRH * 0.0405) - (soRH^2 * 0.0000028) - 4
'
' for the BASIC Stamp:
' rhLin = (soRH * 0.0405) - (soRH * 0.002 * soRH * 0.0014) - 4
'
' Conversion factors are multiplied by 10 to return tenths
'
rhLin = (soRH ** $67AE) - (soRH ** $83 * soRH ** $5B) - 40
' temperature compensated humidity
' rhTrue = (tc - 25) * (soRH * 0.00008 + 0.01) + rhLin
'
' Conversion factors are multiplied by 10 to return tenths
' -- simplified
'
rhTrue = (tC - 250) * (soRH ** $34) + rhLin
RETURN
' sends "status"
'
SHT_Write_Status:
GOSUB SHT_Start ' alert device
ioByte = ShtStatW ' write to status reg cmd
GOSUB SHT_Write_Byte ' send command
ioByte = status
GOSUB SHT_Write_Byte
RETURN
' returns "status"
'
SHT_Read_Status:
GOSUB SHT_Start ' alert device
ioByte = ShtStatW ' write to status reg cmd
GOSUB SHT_Read_Byte ' send command
ackBit = NoAck ' only one byte to read
GOSUB SHT_Read_Byte
RETURN
' sends "ioByte"
' returns "ackBit"
'
SHT_Write_Byte:
SHIFTOUT ShtData, Clock, MSBFIRST, [noparse][[/noparse]ioByte] ' send byte
SHIFTIN ShtData, Clock, LSBPRE, [noparse][[/noparse]ackBit\1] ' get ack bit
RETURN
' returns "ioByte"
' sends "ackBit"
'
SHT_Read_Byte:
SHIFTIN ShtData, Clock, MSBPRE, [noparse][[/noparse]ioByte] ' get byte
SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]ackBit\1] ' send ack bit
INPUT ShtData ' release data line
RETURN
' wait for device to finish measurement (pulls data line low)
' -- timeout after ~1/4 second
'
SHT_Wait:
INPUT ShtData ' data line is input
timeOut = No ' assume no timeout
FOR toDelay = 1 TO 250 ' wait ~1/4 second
IF (ShtData = 0) THEN EXIT
PAUSE 1
NEXT
IF (toDelay = 250) THEN timeOut = Yes ' loop completed = timeout
RETURN
Some radios are very simple AM modulated transmitters and receivers, and you have to send a short preamble to the message to get them ready to receive the real data. Other radios have more or less intelligence built in, and they work more like a modem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
tC VAR Word
send_temp_data:
PULSIN 3, 1,·tC ' temperature value, Pin 3 is data
' Send at 9600 bps, non-inverted.
SEROUT 10, 84, [noparse][[/noparse] "!",tC.HIGHBYTE, tC.LOWBYTE] '
GOTO send_temp_data
·'and here is· for receiver
DegSym CON 186 ' degrees symbol for DEBUG
tC var word
receiver_temp_data:
SERIN 4, 84, [noparse][[/noparse]WAIT("!"), tC.HIGHBYTE, tC.LOWBYTE]
DEBUG CRSRXY, 0, 3,
"tC....... ", DEC (tC / 10), ".", DEC1 tC, DegSym, " ", CR
GOTO receiver_temp_data
Post Edited (Tomvn) : 9/20/2009 3:25:40 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Effort is a two way street. If you don't show much effort, neither will other forum members. Please, tell us what you have tried, what happened, and what you think the problem is.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
"tC...........0
that is.
here my code , i think the Tx is work fine but the problem from receiver i see the the the Tx led on 912mhz flashing.
Post Edited (Tomvn) : 9/21/2009 3:41:45 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
now it work now but other problem is it send not correct temp data ,I Debug on the Tx is 30.0 oC but on Rx 25.2 oC , do you know what wrong ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen