Arduino Zero HC-05 Bluetooth help

Hi All,

I've connected a HC-05 Bluetooth module to my Arduino Zero.

Arduino Pins Bluetooth Pins

RX (Pin 0) ———-> TX

TX (Pin 1) ———-> RX

5V ———-> VCC

GND ———-> GND

This is the code I have.

char data = 0;            //Variable for storing received data
void setup()
{
    Serial.begin(9600);   //Sets the baud for serial data transmission                               
}
void loop()
{
   if(Serial.available() > 0)      // Send data only when you receive data:
   {
      data = Serial.read();        //Read the incoming data & store into data
      Serial.print(data);          //Print Value inside data in Serial monitor
      Serial.print("\n");        
   }
}

When paired to the HC-05 and trying to send over serial data of 0 or 1 it does not seem to even pick it up. I can not even see it in the serial monitor. Using the same setup and code with an Arduino Uno work's perfectly. What am I missing with the Zero?

I think you might need to change the Serial.xxx commands to Serial1.xxx. I would be glad if you could confirm this. I have published basic notes on bluetooth, which you don't need, and will update them

Hi Nick_Pyner,

I've made these changes see here and uploaded the new code. Unfortunately still no luck. Any other ideas?

char data = 0;            //Variable for storing received data
void setup()
{
    Serial1.begin(9600);   //Sets the baud for serial data transmission                               
}
void loop()
{
   if(Serial1.available() > 0)      // Send data only when you receive data:
   {
      data = Serial1.read();        //Read the incoming data & store into data
      Serial1.print(data);          //Print Value inside data in Serial monitor
      Serial1.print("\n");        
   }
}

Try this

String readString;
char c;
void setup()
{
    pinMode(0, INPUT_PULLUP);// only needed for  JY-MCU v1.06?
    Serial1.begin(9600);
    Serial1.println("OK then, you first, say something.....");
    Serial1.println("Go on, type something in the space above");
    Serial1.println(" and hit Send or Enter,");
    Serial1.println("then I will repeat it!");
    Serial1.println("");
}

void loop() {
    while (Serial1.available())     //Check if there is an available byte to read
  {
    delay(3);                      //Delay added to make thing stable 
    c = Serial1.read();             //Conduct a Serial1 read
    readString += c;               //build up the string
  }                                // end while
  if (readString.length() >0) 
  {  
    Serial1.write(c);  
   readString="";  
  }                                // end if
}

Note the Serial1.write

Thanks Nick_Pyner. Still nothing unfortunately. Nothing in the serial monitor.

OK, I think we have been at cross purposes here. While I am an advocate for using hardware serial so that the programme can be tested on the serial monitor, this is where the monitor substitutes for bluetooth, and does not apply with Zero or Leonardo anyway.

No matter what sort of Arduino you have, you cannot communicate with the serial monitor via bluetooth. The monitor is not for that purpose, it is really just there for debugging purposes.

You CAN communicate with your PC via bluetooth using a kosher terminal programme. I use RealTerm. There are others and all are free.

I would recommend using an Android rather than a PC, particularly if the latter is a desktop. I think phone and bluetooth just make better bedfellows.

I stripped back the code to as little as possible.

void setup()
{
    Serial.begin(9600);
}

void loop() {
    Serial.println("Hello World");
}

NOTE: Changed Serial1 back to Serial.

I still couldn't see anything in the Serial Monitor which I thought was strange. After reading up I discovered I was actually using the Native USB port on the board to upload the sketch. I changed this to the Programming Port, uploaded the sketch again and BINGO! I can now see Hello World being printed in the Serial Monitor.

I downloaded RealTerm, thanks for the tip. I'll follow up with how I get om with my HC-05 module.

Many thanks Nick_Pyner