2

This is my first post. I hope that I am posting in the right section of the forum. Otherwise, could an admin move this topic to the appropriate section please?

Board : Arduino Pro Mini 3.3V 8MHz

Arduino IDE : 1.6.12 Arduino is powered by a FTDI Board and USB Mini-B cable from the computer USB port in the following order :

Arduino FTDI

BLK GND

GND CTS

VCC VCC

RXi TX

TXo RX

DTR DTR

Also, I have connected a HC-06 bluetooth module in the following order :

Arduino HC-06

GND GND

VCC VCC

D10 TXD

D11 RXD

The Serial Monitor is open on COM4, Newline, 9600 baud.

The code that I'm trying to run is :

#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); 
void setup()  
{
  pinMode(13, OUTPUT);
  BT.begin(9600);
  // Send test message to other device
  BT.println("Hello from BTSerial");

  Serial.begin(9600);
  Serial.println("Hello from Serial");
}

char a; // stores incoming character from other device
void loop() 
{

  if (BT.available())
  // if text arrived in from BT serial...
  {
    a=(BT.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
      BT.println("LED on");
    }
    if (a=='2')
    {
      digitalWrite(13, LOW);
      BT.println("LED off");
    }
    if (a=='?')
    {
      BT.println("Send '1' to turn LED on");
      BT.println("Send '2' to turn LED on");
    }
    Serial.println(a);
  }
}

I am trying to communicate with the HC-06 from an Android phone. I am posting in this section of the forum because when I send a message from the phone to Arduino the following is printed in the Serial Monitor :

à„…€ƒ¦¤„„‡…§¤¦„‡Å„EóAãbBãbHãb

When I am trying to send a message from Arduino to the phone, nothing is received on the phone.

Could someone please explain why I get garbage output on the Serial Monitor even though the baud rate is the same in the code as it is in Serial Monitor window? Is there a problem with the Arduino IDE?

Edit 12.11.2016

This is what I get when I open the Serial Monitor in the Arduino IDE with this code : Newline, Baud rate 9600

‚Ƈ¥Ç$¤†Fó

If I change the Serial Monitor properties to Newline, Baud rate 19200 this is what I receive :

Hello from Serial

On the Android phone application I do not get anything printed.

Also, please note that this question is also addressed on the Arduino forum at the following link : http://forum.arduino.cc/index.php?topic=434623.0 I will try and answer in both places as I am not sure that everybody has an account on the forum

  • 1
    Is there any possibility that your HC-06 have not configured to run at 9600 baud? – dhimaspw Nov 11 '16 at 8:21
  • Was about to say the same thing as @dpw, there's a huge chance the HC-06 runs at a different baud rate. A simple Google search shows that 38400 is a common (or even default) baud rate of the HC-05 and HC-06. This definitely would explain the gibberish you're receiving. – Len Nov 11 '16 at 15:17
  • Changed this through TeraTerm. I got the confirmation message that the Baud rate was changed. Still, no change. – Luca Andrei Nov 12 '16 at 18:24
1

Flip the RX and TX wires of the HC06. This is because this statement : SoftwareSerial BT(10, 11); actually means SoftwareSerial BT(RXpin, TXpin);. Considering this, 10 is your Rx and 11 is your Tx. In this case, you have to connect pin 10 (software Rx) of your Arduino to the Tx pin of your HC06 and pin 11 (software Tx) to the Rx pin.

  • I think I typed wrong in the main question because this is how I have them connected. Sorry for misleading you. – Luca Andrei Nov 12 '16 at 18:22
1

BLK GND

GND CTS

That looks backwards to me. Connect GND to GND and CTS to BLK.

The bluetooth module operates at a predefined baud rate. You need to ensure that your Arduino communicates at that baud rate - you don't get to pick any old baud rate.

The baud rate can be changed with the AT+UART=x command (where x is a single digit representing the baud rate: 1=1200, 2=2400, 3=4800, 4=9600 (default), 5=19200, 6=38400, 7=57600, 8=115200, 9=230400, A=460800, B=921600, C=1382400). If the HC-06 isn't on the default baud rate of 9600 (which is highly possible) then you will have to guess what the right baud rate is. Work through the possible ones listed there in yopur BT.begin(...) function to see if one of them starts working.

  • He's actually right. It isn't backwards. – Dat Ha Nov 10 '16 at 22:25
0

Could someone please explain why I get garbage output on the Serial Monitor even though the baud rate is the same in the code as it is in Serial Monitor window? Is there a problem with the Arduino IDE?

Even if the baud of serial monitor and the code is same, there is a possibility that you have not configured your HC-06 to works on the same baud. There are many ways to check and configure it by using AT-Command. You will easily found them since many tutorial has been written, here is some of the example :
link 1
link 2

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.