Easy Bluetooth
mademoiselle
Posts: 10
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!
thanks!
Comments
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.
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.
'
' 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!
You can also remove the programming cable from the beginning and look mom no wires!
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"
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
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:
and this is the code you pasted:
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.
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.