Shop OBEX P1 Docs P2 Docs Learn Events
Easy Bluetooth — Parallax Forums

Easy Bluetooth

mademoisellemademoiselle Posts: 10
edited 2012-02-15 19:31 in BASIC Stamp
Hi, I'm new to pbasic and i'm working on a project where I need to send my BS2 data via easy bluetooth to my PC or handphone, do anybody have any example tutorial on how to achieve that?
thanks!

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-06 08:32
    Hi, the product page has a number of examples of using the Easy Bluetooth in different settings:

    http://www.parallax.com/tabid/768/ProductID/550/Default.aspx

    Look in the Downloads & Resources section and open up the zip files for samples. I've used other Bluetooth modules and the Easy Bluetooth looks similar. As long as you match the baud rate and settings of the Basic Stamp to those expected by the Easy Bluetooth module they look just like any other serial communication link.
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-06 08:55
    I downloaded easy bluetooth education sample code, but they gave me the code itself, i do not know how to run it or link to my PC.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-06 09:15
    I would really suggest reading through the product PDF on the page I linked to. It has a helpful quick start that will get your working and the picture shows how to properly install the module onto the BOE. But the summary is install the module in the app mode socket, making sure it is in the row with pins 0 and 2 because that has 5 volt instead of V bat. Now give the BOE some power. Next initiate device pairing from the PC to the Bluetooth module with these steps from the PDF

    Creating a new Bluetooth Connection
    1. Be sure that the Bluetooth dongle that you installed on your PC is working correctly and is turned
    on (see Bluetooth Dongle user manual for specific instructions to ensure proper operation).
    a. Open Control Panel, click “Printer and Other Hardware” and then click Bluetooth Devices.
    If in Classic View double click “Bluetooth Devices”.
    b. Click “Add”.
    c. Check “My Device is set up and ready to be found” in the “Add Bluetooth Device Wizard”
    and click "Next".
    d. Select "EasyBT" from the displayed Bluetooth devices and click “Next”.
    e. Select “Use the passkey found in the documentation" and enter the Passkey Code 0000
    (zero four times) and click “Next”.
    f. Bluetooth Manager should display and designate an Outgoing and Incoming COM port for
    the Easy Bluetooth device: make a note of the COM ports because these are the ports
    you will use to communicate with the Easy Bluetooth.
    g. Select "Finish" to complete the Bluetooth device configuration.
    2. To close the “Bluetooth Devices” window click “OK”

    At that point you'll have a new COM port on your PC that will connect to the Bluetooth module and the BS2 will see a serial link on pins 0 and 2 back to the PC. Some of the PBasic sample code shows how to do the serial input and output on pins 0 and 2.
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-06 17:04
    Yes I've run and linked to my pc using the sample code given in the pdf, but when i tried to use easy bluetooth education sample codes - "hello" its not showing me anything,
  • FranklinFranklin Posts: 4,747
    edited 2012-02-06 18:33
    but when i tried to use easy bluetooth education sample codes - "hello" its not showing me anything,
    could you ATTACH your actual code to your next post?
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-06 19:12
    ' =========================================================================
    '
    ' File...... Easy Bluetooth _ Hello.bs2
    ' Purpose... Displaying uni-directional communcation with a PC & Bluetooth
    ' Author.... Technical Support & Education
    ' E-mail.... support@parallax.com
    ' Started... Jan 16th 2009
    ' Updated... April 1st 2009
    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    ' =========================================================================
    '
    '
    '
    [ Program Description ]
    '
    ' This program displays a bi-directional communication between the Easy Bluetooth
    ' and a Terminal Window.
    '
    '
    [ Revision History ]
    '
    ' revised 4/1/09 for the new Easy Bluetooth module
    '
    '
    [ I/O Definitions ]


    RX PIN 2 ' RX of the Easy Bluetooth
    TX PIN 0 ' TX of the Easy Bluetooth


    '
    [ Constants ]


    Baud CON 84 ' Baud set at 9600


    '
    [ Variables ]


    myByte VAR Byte ' Byte to establish connection & used for workspace


    '
    [ Initialization ]


    ' The Easy Bluetooth Module is waiting for a Byte to establish connection;
    ' press any key in the TOP window pane of the DEBUG or PST to do this.


    PAUSE 250 ' Waits 1/4 second
    SERIN RX, Baud, [myByte] ' Waiting for byte
    myByte = 0 ' Clear the byte value


    '
    [ Program Code ]


    SEROUT TX, Baud, ["Hello", CR]

    This is my code, could you teach me how to show it out on my pc? Sorry i'm very new to this.
    thanks alot for your help!
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-07 03:59
    OK, after you have loaded that program with the Basic Stamp IDE it will run. A quarter of a second later it will write hello to the bluetooth serial port of your PC. So you will need a serial terminal on the pc to display it. At the top of the IDE is a toolbar and one of the functions launches a new serial terminal. Create one and in the upper left is a drop down to select the com port. Select the one you created for the bluetooth module during pairing. Now when you run the program it will display hello in this serial port.

    You can also remove the programming cable from the beginning and look mom no wires!
  • Mike4421Mike4421 Posts: 131
    edited 2012-02-07 14:12
    @ mademoiselle
    this can be fixed easy, its a matter of knowing how the PBasic IDE works.....


    what you did was correct, but by "default" your Bluetooth COM port is turned Off on the PBasic IDE side. So to fix this just tell PBasic IDE to use it and stop ignoreing it.

    Follow these steps, (this is done on the PBasic IDE); your code and Bluetooth setup in the PC is correct.

    1- go to the "Edit" section on your top left
    2- "Select" Preferences
    3- go to the "Debug Port TAB"
    - you will see your Main COM port tab in front, select one of the back ones like Terminal 2, or 3, or4
    4- cliclk on "Edit Ports"
    - you will see the "Avilable" COM ports that can be used
    - most likely your "Bluetooth connection COM port" will be in ITALICS, that means PBasic IDE see it, But will not use it.
    - to tell PBasic IDE to use it, do this....
    5- "RIGHT" click on your Bluetooth COM port (OUT)
    6- Select "Include port (COM #)"
    7- to Finish select the "Accept" button, at the bottom of window.

    This will let you finish your sample program; leave your UBS or RS232 connected to the Board of Education, etc,... Run the program; your "Default" COM# that is connected to the Basic Stamp will open a Debug window (not the Bluetooth one), leave it open...:nerd:
    OPEN a NEW Debug window and select your Bluetooth COM# (OUT), that should complete your sample code.


    I belive there is also one were youcan type something and it will show on your screen.... same as above but,........ then type something there (your Bluetooth Debug window) and it will be displayed on your "Default Debug wired window"
  • Mike4421Mike4421 Posts: 131
    edited 2012-02-07 14:23
    one more thing I forgot to state.... if your use your Bluetooth COM ("IN #") on your code it will just...... wait, wait,wait,wait, or Freeeze the CPU..... use your COM (OUT #) for this sample program.
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-09 00:13
    Thanks alot! i'm able to try that out.
    Now what i have is a bluetooth sender code :

    ' ' '' ' '' ' ' Declarations ' ' '' ' '' ' '' ' ''


    RX PIN 2
    TX PIN 0
    '
    [ I/O Definitions ]
    CS PIN 1 ' chip select (ADC0831.1)
    Clock PIN 3 ' clock (ADC0831.7)


    DataIn PIN 5 ' data (ADC0831.6)
    '
    [ Constants ]
    Cnts2Mv CON $139C ' x 19.6 (to millivolts)
    counter VAR Word
    result VAR Byte ' result of conversion
    mVolts VAR Word ' millivolts


    'Place the values for each part of the address in the constants below; whereas the first part of the address will be placed in
    'addy1 and the second in addy2; for example the address A1:B2:C3:D4:E5:F6 would be edited to look like the following:


    ' addy1 CON $00 ' <--- 00 from 00:17:A0:01:69:C7
    ' addy2 CON $17 '<--- 17 from 00:17:A0:01:69:C7
    ' addy3 CON $A0 '<--- A0 from 00:17:A0:01:69:C7
    ' addy4 CON $01 '<--- 01 from 00:17:A0:01:69:C7
    ' addy5 CON $69 ' <--- 69 from 00:17:A0:01:69:C7
    ' addy6 CON $C7 '<--- C7 from 00:17:A0:01:69:C7


    ' Place the address for the receiving Easy Bluetooth modules below
    '( the address for the Easy Bluetooth module used in the example is 00:17:A0:01:56:65 00:17:A0:01:69:BB)


    addy1 CON $00'$B8
    addy2 CON $17'$FF
    addy3 CON $A0'$FE
    addy4 CON $01'$27'
    addy5 CON $69'$68'
    addy6 CON $BB' $29'


    #SELECT $STAMP
    #CASE BS2, BS2E, BS2PE
    Baud CON 84
    #CASE BS2SX, BS2P
    Baud CON 240
    #CASE BS2PX
    Baud CON 396
    #ENDSELECT


    ' ' '' ' '' ' ' Program ' ' '' ' '' ' '' ' ''


    Program_Start:
    DEBUG CLS
    PAUSE 3000


    DEBUG CR,"Establishing SPP connection..."


    SEROUT TX, Baud, [$02,$52,$0A,$08,$00,$64,$01,addy6,addy5,addy4,addy3,addy2,addy1,$01,$03]
    PAUSE 5000


    DEBUG CR,"Entering Transparent mode...",CR


    'Entering Transparent mode
    SEROUT TX, Baud, [$02,$52,$11,$01,$00,$64,$01,$03]
    PAUSE 3000
    '
    [ Initialization ]
    Reset:
    DEBUG CLS, ' create report screen
    "Counter" ,CR,
    "ADC.... ", CR,
    "Volts... "
    'Transmitting counter variable to remote Bluetooth device and to the DEBUG terminal
    DO


    GOSUB Read_0831 ' read the ADC
    mVolts = result */ Cnts2Mv ' convert to millivolts
    SEROUT TX, Baud, [counter]
    counter = mVolts
    PAUSE 500


    DEBUG HOME ,
    CRSRXY, 9, 0, DEC counter, CLREOL,
    CRSRXY, 9, 1, DEC result, CLREOL,
    CRSRXY, 9, 2, DEC mVolts DIG 3,".", DEC3 mVolts , CLREOL
    LOOP


    '
    [ Subroutines ]
    Read_0831:
    LOW CS ' enable ADC
    SHIFTIN DataIn, Clock, MSBPOST, [result\9] ' read ADC
    HIGH CS ' disable ADC
    RETURN

    i need to send my values to another easy bluetooth receiver, may i know what have gone wrong in my codes? and do anybody have any tutorial codes for bluetooth values to mobile phones?thanks!

    this is my easy bluetooth receiver codes:
    ' ' '' ' '' ' ' Declarations ' ' '' ' '' ' '' ' ''


    RX PIN 2
    TX PIN 0


    Temp VAR Word
    result VAR Word
    mVolts VAR Word


    #SELECT $STAMP
    #CASE BS2, BS2E, BS2PE
    Baud CON 84
    #CASE BS2SX, BS2P
    Baud CON 240
    #CASE BS2PX
    Baud CON 396
    #ENDSELECT


    ' ' '' ' '' ' ' Program ' ' '' ' '' ' '' ' ''


    DO
    GOSUB GETVAL
    GOSUB DISPLAY
    PAUSE 5
    LOOP


    ' ' '' ' '' ' ' Subroutines ' ' '' ' '' ' '' '


    GETVAL:
    SERIN RX, Baud, [Temp] ' Waits for a BYTE and puts that value in Temp
    SERIN RX, Baud, [result]
    SERIN RX, Baud, [mvolts]
    RETURN


    DISPLAY:
    DEBUG HOME,
    "Counter = ",DEC Temp,CLREOL,CR, ' Displays the decimal value for Temp
    CRSRXY, 9, 0, DEC Temp, CLREOL,
    CRSRXY, 9, 1, DEC result, CLREOL,
    CRSRXY, 9, 2, DEC mVolts DIG 3,".", DEC3 mVolts , CLREOL
    RETURN
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-09 03:48
    Glad to hear you are making progress. You are moving beyond what I've done with bluetooth devices, as I have only done microcontroller to PC. But in reading the app note on the page I linked to, I think it will work. Sorry I can't help.
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-09 17:25
    Is it able to program it to be able to receive my data values to my PC automatically? and is it able to bluetooth more that 5 values at a go?
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-10 06:30
    Is it able to program it to be able to receive my data values to my PC automatically? and is it able to bluetooth more that 5 values at a go?

    I read through this app note http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/AppNoteforEasyBluetooth.pdf carefully. First there are two separate BS2 programs. Make sure when you load the first BOE with the first program, and the second BOE with the second program. While you use the code from the app note, you replace the address in the code with the address of your bluetooth module from step seven and eight of the app note. This is the code from the sample:
         addy1   CON  $00 
         addy2   CON  $17 
         addy3   CON  $A0 
         addy4   CON  $01 
         addy5   CON  $56 
         addy6   CON  $65
    

    and this is the code you pasted:
    addy1 CON $00'$B8
    addy2 CON $17'$FF
    addy3 CON $A0'$FE
    addy4 CON $01'$27'
    addy5 CON $69'$68'
    addy6 CON $BB' $29'
    

    It doesn't look like you did the address replacement correctly and there's no wiggle room for error here. Bluetooth is a networking technology and sends packets to that address. If it doesn't match the intended receiver the packets won't be heard.
  • mademoisellemademoiselle Posts: 10
    edited 2012-02-12 22:23
    Hi! thank alot i'm able to solve my codes to communicate from easy bluetooth to another easy bluetooth. I'm doing a temperature recording module hence i would like to ask you is there any possibility or codes for me to record and store my highest temperature and over right it if there is another higher value? thanks alot for your help.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-15 19:31
    Glad to hear that it is working.

    That should be possible. You should store data in the eprom and then read it to compare with the new value. The basic stamp manual has information on eprom access commands.
Sign In or Register to comment.