Trouble connecting to HC-05 bluetooth module

first of all thanks for lot’s of good information on this forum. I’ve been reading a lot more than writing. Hopfully i can contribute more in the future!

I am attempting to use a HC-05 bluetooth module with my spark. For testing purposes i am using a my Android phone and a small application developed in MIT App Inventor 2. I have verified that the HC-05 module is working by connecting it using loopback (direct connection between the TX and RX on the bluetooth module) and the data are sent back to my phone.

However, when I try to establish serial connection with the bluetooth module, the serial connection is not established.
The module is connected as @timb has explained in this thread:

My code is shown below. When i start the code the blue led stays solid. I have tried connecting to the HC-05 module both after and before resetting the spark core.

Any help would be greatly appreciated!

char val; // variable to receive data from the serial port
int ledpin = D7; // LED connected to pin 48 (on-board LED)

void setup() {

pinMode(ledpin,OUTPUT); // Turn on the D7 led so we know it’s time
digitalWrite(ledpin,HIGH); // to open the Serial Terminal.

while(!Serial.available()); // Wait here until the user presses ENTER in the Serial Terminal

digitalWrite(ledpin,LOW); // Turn off the D7 led … your serial is serializing!

Serial.println("Spark Core serial initialized ");


void loop() {

if( Serial.available() )       // if data is available to read
    val =;         // read it and store it in 'val'
    Serial.print("Received: ");  // report back
   delay(100);                    // 10 blinks a sec indicates serial is available
     digitalWrite(ledpin,HIGH);  // 3 blinks a sec indicates serial is not available


Hi @EspenL

It looks like your code is using Serial which is the USB serial port on the Spark core. Did you want to use Serial1, the serial port on the RX/TX core pins instead?

Ah, that would explain it. I will try it out!

Took a while, I keep having to factory reset the core in order to upload the new code, but using Serial1 worked!

Thanks a lot @bko!

1 Like