Shop OBEX P1 Docs P2 Docs Learn Events
easy bluetooth module with PIC — Parallax Forums

easy bluetooth module with PIC

soniahsoniah Posts: 1
edited 2012-01-29 09:58 in Accessories
Hi I am trying to control the easy bluetooth module with a PIC microcontroller but I have not been lucky with the communication. I am using the framing model given in the user's manual but still doesn't work. Any suggestions? Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-24 13:22
    There are many things that can go wrong on the PIC end of things and we can't help you with those.

    The first question is whether there is communication between the PIC and the EasyBluetooth module. Are you getting any kind of response? What happens if you monitor the communications with your PC? If you have a TTL to USB serial adapter, you can connect its ground and receive connections to one of the connections between the PIC and EasyBluetooth and monitor the connection with something like HyperTerm.

    Remember that CTS needs to be pulled low for the EasyBluetooth to send data to the PIC. You can either use a PIC I/O pin to do this or connect a 10K resistor from CTS to ground.
  • carlozofjuancarlozofjuan Posts: 4
    edited 2011-01-10 00:05
    I am also using a PIC and the Easy Bluetooth module to communicate with my PC and also having trouble. I do get a response however. I shorted the Rx and Tx pins on the Bluetooth and was able to echo back what I have sent to it from Hyper Terminal or the Serial Communicator feature Mecanique MicroCode Studio. I also have managed to have the PIC send bytes through the Bluetooth to Hyper Terminal or Serial Communicator. With the latter, I am able to tell that the PC is receiving the correct number of bytes (if a carriage return is indeed a bit).

    The problem is the characters are not the string I sent from the PIC nor do they have a pattern that reflect the string I sent. Example, I send "hello" from PIC-Bluetooth and receive something like "pxpxx" choosing "Force to 7-bit ASCII" in Hyper Terminal. Not choosing the option shows the characters from an extended set.

    I did a PIC to PIC async serial communication test and found it to be working fine. One PIC sent a string out the hardware transmit async pin to the hardware receive async pin of the receiving PIC and then outputted the received string to LCD and successfully displayed the characters.

    Assuming the problem is not with the PIC, or maybe just treat the PIC as if it were a STAMP for minute, I wonder what is going on when a string is transmitted from a PIC/STAMP to the Bluetooth if/how the string is altered when it leaves the Bluetooth to be received by the PC.

    Just to clarify, I am using the Easy Bluetooth module that has one PCB attached to another that only has the Vdd, Tx, Rx, and Vss pins that go into my breadboard.

    I'll post the code used as well as the sample program that is available as free download to accompany the Parallax Easy BT module. Any insight is very appreciated!!

    Current code "eBT_hello.pbp" written in PicBasic Pro:
    ' -----[ I/O Definitions ]-------------------------------------------------
     
    RX          Var     portC.6                     ' RX of the Easy Bluetooth
    TX          Var     portC.7                     ' TX of the Easy Bluetooth
    CR          con     13
     
    ' -----[ Constants ]-------------------------------------------------------
     
    Baud      CON     84        ' Baud set at 9600
     
    ' -----[ Variables ]-------------------------------------------------------
     
    myByte    VAR     Byte      ' Byte to establish connection & used for workspace
     
     
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1 ' ? MAY NOT BE IN PBP2.32
    'DEFINE CHAR_PACING 65000
     
     
    RCSTA.4=0 ' CLEAR ANY ERRORS CREN BIT
    RCSTA.4=1 'START RECEPTION 
    RCSTA = %10010000       ' Enable serial port and continuous receive
     
     
    ' -----[ 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 5 seconds
     
    main:
    hserin 1000, main, [myByte]                            ' Waiting for byte
    myByte = 0                                          ' Clear the byte value
     
    ' -----[ Program Code ]----------------------------------------------------
     
    hserout [ "Hello", CR]        'CR carriage return is 13
    
    Is based on:
    ' =========================================================================
    '
    '   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]
    
  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-10 08:07
    We cannot help you with a program for a non-Parallax microcontroller, sorry. I suspect there's some timing problem between the EasyBluetooth and your PIC. I've used PICBasic Pro before and had similar problems with the hardware serial I/O statements in a completely different situation. I was never able to figure out why or how. I ended up using the software-based statements (SERIN / SEROUT) instead and that seemed to work. If you have a scope or a logic analyzer, you might look at the signals going between the PIC and the EasyBluetooth. You might be able to figure out what's wrong.
  • carlozofjuancarlozofjuan Posts: 4
    edited 2011-01-10 10:30
    I will have a look at the SERIN/SEROUT and see if/how I can get my hands on a scope or logic analyzer. Thank you for the insight Mike!
  • eslameslam Posts: 2
    edited 2012-01-29 04:40
    i need help , i have the same problem as u , did this [serin/serout] fix the problem , plzzzz reply ...thanks
  • carlozofjuancarlozofjuan Posts: 4
    edited 2012-01-29 09:58
    Unfortunately I never resolved it. Look into getting a Toothpick by Flexipanel instead, it's a lot friendlier. I got mine from Mouser. Good luck!
Sign In or Register to comment.