Shop OBEX P1 Docs P2 Docs Learn Events
help temperature sensor with 912mhz RF modules — Parallax Forums

help temperature sensor with 912mhz RF modules

TomvnTomvn Posts: 103
edited 2009-09-24 07:56 in BASIC Stamp
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

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2009-09-18 01:10
    Tomvn

    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
  • TomvnTomvn Posts: 103
    edited 2009-09-18 09:20
    Hi , i use Serin and Serout to send the signal back and for, but i have no idea to send temperature to other stamp the code i use the test code in documment.
    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
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2009-09-18 16:33
    Okay, what 912 mHz radios are you using? The first step is to send "Hello world, counting 1, 2, 3" from your transmitter to your receiver. Have you done that?

    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
  • TomvnTomvn Posts: 103
    edited 2009-09-19 02:36
    I use two 912mhz modules from parallax one on each end , and i know how to send the character back and for ,but no idea to send the temps data .
  • FranklinFranklin Posts: 4,747
    edited 2009-09-19 03:55
    Could you link to the module page? I can't seem to find it. Thanks. If you can send characters back and forth you just use serin/serout instead of debug in the sample code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SRLMSRLM Posts: 5,045
    edited 2009-09-19 06:21
    Here is a page with some code and the reason why they were discontinued: http://forums.parallax.com/showthread.php?p=755918
  • TomvnTomvn Posts: 103
    edited 2009-09-19 17:24
    sorry i got two from parallax last year ,and i dont find anymore now. My problem is i like to receiver the temperature data with other Bs2 then display by computer.
  • FranklinFranklin Posts: 4,747
    edited 2009-09-20 02:42
    Attach the code you have so far and tell us what it does not do that you want it to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TomvnTomvn Posts: 103
    edited 2009-09-20 03:18
    Here· my code


    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
  • FranklinFranklin Posts: 4,747
    edited 2009-09-20 15:53
    What are you getting when you run the programs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TomvnTomvn Posts: 103
    edited 2009-09-20 16:56
    just blank in debug window ,so you have any point?
  • SRLMSRLM Posts: 5,045
    edited 2009-09-20 19:30
    @Tomvn

    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.
  • FranklinFranklin Posts: 4,747
    edited 2009-09-20 20:20
    You might try a timeout in the receive side since if it was working you should at least see the text of the debug command so it probably locks up in the serin command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TomvnTomvn Posts: 103
    edited 2009-09-21 15:18
    when i run the code , Debug window show

    "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
  • FranklinFranklin Posts: 4,747
    edited 2009-09-21 18:01
    You must have something wrong cause you should get a soT..... before your tC........ if the code you attached ran correctly. Try assigning values to the variables and comment out the serins and see if the display works correctly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TomvnTomvn Posts: 103
    edited 2009-09-23 14:52
    Thanks Stephen, i will try when i get back home.
  • TomvnTomvn Posts: 103
    edited 2009-09-23 17:30
    Hi 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 ?
  • FranklinFranklin Posts: 4,747
    edited 2009-09-24 00:03
    Well, you are transmitting three values and receiving two. Might make a difference.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TomvnTomvn Posts: 103
    edited 2009-09-24 07:56
    Yes , it transmitting and i can receiver the value but , but the value it not correct ,the value on TX it correct but difference that far.?
Sign In or Register to comment.