PDA

View Full Version : Communication using a Bluetooth module



Balachandar
- 1st November 2013, 10:36
Hi,

I am using my cell phone to communicate with a device that has a PIC 12F683 and an HC-06 Bluetooth module (Linvor). Initially, certain parameters are set from the cell phone and then the device goes to sleep. When the device wakes up, it waits to connect to the cell phone. When I connect to the device from the cell phone using the app Blueterm, I get the message "Connected to Linvor". Once I see this message, I type '1' on the phone. When this '1' is received by the device, it executes a subroutine. Here's my question.

Is there a way to detect that the device has been connected to the phone by reading the value of some register of the PIC? If the answer is Yes, then I don't need to type '1' on the phone. The device can check the value of the register to know whether the connection has been established. If there is no connection, it keeps waiting. If the connection has already taken place, the device goes ahead with the next command to be executed.

I am using DEBUGIN and DEBUG for communication at 9600 baud rate, 8 data bits, no parity, 1 stop bit (8N1). 12F683 does not have a hardware USART and hence I will have to rely on software commands like DEBUGIN, DEBUG and SERIN, SEROUT.

Would highly appreciate any help.

Bala

Demon
- 1st November 2013, 13:09
This is for HC05:
http://m.instructables.com/files/orig/F3O/K70G/H1LWQ0PO/F3OK70GH1LWQ0PO.pdf

Page 10, can you check PI09 output while using automatic connection feature?

(Never used this device yet)

Robert

Amoque
- 1st November 2013, 13:21
Presuming it is not possible from the PIC, you may investigate "Tasker" or "ITTT" (If This Then That), both Android applications (I believe ITTT has an Apple version) that automate functions on your cell. For example, Tasker turns off the screen lock on my cell in range of my Wi-Fi and turns it on when I leave range. It also logs onto my website and performs "housecleaning" chores Tuesdays at 9:00pm and notifies Pebble of various telephony conditions. Quite capable of sending (or responding to) specifically worded texts and emails as well... I am confident it would recognize and respond as you wish. Seems like a perfect compliment to Bluetooth automation, even if (sadly) it does not resolve your specific need.

comwarrior
- 2nd November 2013, 02:15
The HC-06 module (if you have the backplane with it too) has a state output...
This output toggles on and off when not paired and is solid on if it it...
So, you can write a routing that looks to see if this pin is on or off and waits to see if it's status changes.

Also, the pic can send an "AT" to the HC-06, if it receives an "OK" then the module is NOT paired...
However, if the module IS paired and an "AT" is sent then the "AT" is transmitted to the phone where the phone could be programmed to reply with it's own code... or not reply at all... In ether case the pic will know it's paired...

Balachandar
- 2nd November 2013, 08:56
Thanks a lot, Robert, Amoque and comwarrior for your helpful replies.

Replies from Robert and comwarrior give me the following idea: Once the device wakes up from sleep, keep checking pin 24 (Status LED) of the BT module for high pulse width. If and when the pin is continuously high, it means that the connection with the phone is established.

Amoque, I am using Samsung Android phone and the app Tasker (or ITTT) has many uses and I am sure, I will be using it for one of my future projects.

Bala