Android Question Interfacing Bluetooth(via Serial Communication) to PIC16F877A

Gagandeep Singh

Member
Licensed User
Hi,
Firstly, i am just a beginner. I came across almost all the tutorial's which have been posted by Erel.
I have a task to do. I want to interface a Bluetooth device to my PIC board(via HC-06) and want to transmit a String of characters to the HC-06.
All i know is i can use AsyncStreamsText from the tutorial and transmit the same but i haven't been able to taste much success. Can anyone please guide me through?
 

Beja

Expert
Licensed User
Longtime User
Hi,
That's easy if you have RS485 port on the PIC PCB or controller.
I assume you already familiar with the HC-06 4-pins.. +, -, Rx and Tx. then simply cross the Rx-Tx pins of the HC-06 to the Rx-Tx pins of the controller.. that
means you connect the Rx of the PIC to the Tx of the HC-06 and Tx to the Rx.. (you know the logic) Usually the pins are already crossed
so you don't need to peal the belt cable.
Then depending on the data type (ascii string or byte) you define your data and send it using AsyncStreams. You can read many Bluetooth examples
on this forum.
 
Upvote 0

Gagandeep Singh

Member
Licensed User
Hi,
I have interfaced the Hc-06 to the PCB Board and it's even getting paired to my Smartphone.
I really don't have much problem as far as hardware is concerned.

As far as software part is concerned, I want to develop an application which can transfer the schedule,
Something like,
Schedule 1(Time) :- 12:00
Schedule 2(Time) :- 15:00
Schedule 3(Time) :- 17:00

So the above stated schedule are just used as examples to explain this is what i am expected to do.

Later, the schedule which i have made i am expected to store in the EEPROM memory of the Microcontroller.

All i want to know is, how am i supposed to transmit this schedule from the Android application i build using AsyncStreamsText.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Looks like string variables.. I had a similar project but in larger scale.
I would put these lines in a ListView and then output them one by one to the controller. Use handshaking
so you make sure the first line was successfully received on the other side before sending a new one.

For the discovery and pairing, I wrote a small app just to discover and pair.. then return to your app and use
the BT MAC address directly instead of each time going to the discovery process.
 
Upvote 0

Gagandeep Singh

Member
Licensed User
Alright. Alright.
Your work in the same domain sounds interesting.

If you don't mind then could you share the application so that i may try to make a connection with my HC-06 and try transmitting a string of variables over it.
Any help in this would be highly appreciated.
Thanks.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
That depends on how the controller would like to receive the data.. as a file or as commands one at a time. Your controller server.
will the first line be overwritten by the new line, or the old line is shifted in memory and make room for a new one (stack register).
According to this you send the data.
 
Upvote 0

Gagandeep Singh

Member
Licensed User
Hi Erel,
For now i have been trying to infuse the AsyncStreamText object which you had shared in your tutorial with the Bluetooth Code.
I haven't been able to do much in it as i am getting error in the program.
Here in, i am attaching the error and my code. Please go through it and if possible let me know what the problem is.
 

Attachments

  • BluetoothTXT.zip
    59.5 KB · Views: 274
  • Screenshot_2016-03-22-14-31-35.png
    Screenshot_2016-03-22-14-31-35.png
    44.6 KB · Views: 226
Upvote 0

Beja

Expert
Licensed User
Longtime User
I tested your project on my LG G Stylus and it worked fine. I didn't get that error.
Try the attached APK that I generated from your code.
 

Attachments

  • Bluetooth.apk
    133.9 KB · Views: 239
Upvote 0

Gagandeep Singh

Member
Licensed User
Hey, i am unable to install the apk file; reason being, i already have the inbuilt app by the name of Bluetooth. Could you please share the zip file in case you have done any changes in the app made by me? Or could you please give me tips to overcome the error i am getting after installing the app?
 
Upvote 0
Top