I'm using PIC16F1824, Xtal 8Mhz and bluetooth module with baud rate 9600. When I sent data using hyperterminal to the BT module, it works fine. But when I send the same data using Android (Amarino), the data received was corrupted.

What went wrong?

Additional Info: Corrupted data. @Kevin: Original Data: 1234567890 But when I sent using Android, it reads as 1234!!0 Some how 56789 was missing.**

Another example: ABCDEF, but it only reads as ABCD!! Basically it only know how to read the first 4 characters.

  • 2
    \$\begingroup\$ We need much more detail then this. There are tons of things that could have gone wrong. \$\endgroup\$ – Kellenjb Jun 28 '11 at 18:49
  • \$\begingroup\$ Sure the settings of the Amarino match those of your Hyperterminal? Looks like that kind of problem. \$\endgroup\$ – stevenvh Jun 28 '11 at 18:50
  • 2
    \$\begingroup\$ Can you describe what you mean by "Corrupted"? Did you actually scope it? \$\endgroup\$ – Kevin Vermeer Jun 28 '11 at 19:59
  • \$\begingroup\$ what they are trying to say is that a simple scope shot of the data on the line will tell you where the problem is originating. \$\endgroup\$ – Kortuk Jun 29 '11 at 7:39
  • \$\begingroup\$ the same corrupted characters both times with different data means this is almost guaranteed to be intentional from either android or the module. \$\endgroup\$ – Kortuk Jun 29 '11 at 13:35

You didn't give much information, but this smells like a serial port configuration problem. Are you really sure the baud rate, number of data bits, parity, and number of stop bits is the same in both cases. Probably not. Since it's working with Hyperterm, see what it's set to, then make sure the Android is set to the same thing.

Also look at how flow control is handled. If the unit is expecting to use RTS/CTS and the Android doesn't have those lines hooked up or doesn't have that turned on it could make it not work.

| improve this answer | |
  • \$\begingroup\$ where he has two different platforms for terminals, this does seem likely. \$\endgroup\$ – JustJeff Jun 28 '11 at 23:51
  • \$\begingroup\$ Thanks @Olin. I will look into RTS/CTS stuff. There is no settings for Baud rate, Parity or RTS/CTS in Android. I will do more research on this. Normally all settings are done in the bluetooth module. Which I've set the BT Module 9600 8 N 1 and it works for Hyperterminal. One more thing, I have another MCU, PIC18F452. It works perfectly ok. Using the same BT module, I can send data using Hyperter and Android. The difference is PIC18F452 uses USART while PIC16F1824 uses ENHANCED USART. \$\endgroup\$ – mlam Jun 29 '11 at 2:47
  • \$\begingroup\$ @Olin, the fact that some of the data makes it through unharmed but some does not tells me it is more dastardly then baud rate. If it was baud rate his data would be corrupted on the whole. With a bug like this someone is corrupting the data, almost gaurantee it is in the Android phone, even though I love android. \$\endgroup\$ – Kortuk Jun 29 '11 at 7:40
  • \$\begingroup\$ Thanks @Kortuk. At the beginning, I didn't give much details about the data and the code. So based on that info, @Olin asked me to check RTS/CTS. \$\endgroup\$ – mlam Jun 29 '11 at 10:56
  • \$\begingroup\$ @mlam, now that you have given more information, it could possibly be a buffer overrun problem. That might mean the module is expecting some sort of flow control that the Android isn't doing. \$\endgroup\$ – Olin Lathrop Jun 29 '11 at 12:32

I have tried this using a Sena Bluetooth app in Android for my android. I ensured that my CTS and RTS of my bluetooth module were connected to each other. My bluetooth app required that I set the baud rate to 115200. I was successful in data transfer.

You will have to power up your bluetooth module and change the baud rate settings. Refer to the link below:

how do I change baud rate for bluesmirf without connecting to pc?

| improve this answer | |
  • \$\begingroup\$ Thanks @Sai. I don't get what you mean with " I ensured that my CTS and RTS of my bluetooth module were connected to each other." My baud rate settings look ok, 9600 8 N 1. It works with Hyperter. \$\endgroup\$ – mlam Jun 29 '11 at 4:44
  • \$\begingroup\$ Please don't use signatures. Your gravatar, username, reputation, badge count, and so on are all in the lower right corner of your answer. \$\endgroup\$ – Kevin Vermeer Jun 29 '11 at 18:53
  • 1
    \$\begingroup\$ Unless you're using flow control, you can short your CTS (clear to send) and RTS (ready to send) pins to each other to indicate that the device is always ready to send and always ready to receive. \$\endgroup\$ – pfyon Jun 29 '11 at 18:54
  • \$\begingroup\$ Also, edits should be mostly independent of the comments, and leave your answer mostly contiguous: You want it to be as easy to read and understand as possible! To answer @mlam's question, you should clarify why you connected CTS and RTS in the second sentence, not as an edit, or respond directly in a comment if you don't feel that the information belongs in your answer, or both. \$\endgroup\$ – Kevin Vermeer Jun 29 '11 at 18:55
  • \$\begingroup\$ @Kevin: Sorry about that. I was not able to comment for mlam's post. I am able to do so now \$\endgroup\$ – Sai Jul 1 '11 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.