Communication between Arduino & HC-05 Bluetooth module with PC

I'm trying to communicate between PC(on W7) and Arduino Uno through Bluetooth with HC-05 module.

I can't communicate with Arduino on both ways, I can only send data from PC to Arduino but I can't receive data from Arduino to PC.

I follow this tutorial and read other tutorials to find a solution but without success.

I reach to do these steps :

  • connect wires
  • pair HC-05 with PC
  • send data to Arduino
  • led light On or light Off according to sent data

I fail in this step :

  • receive data from Arduino BT in terminal

Here is my Arduino Uno code :

#include <SoftwareSerial.h>

SoftwareSerial Mojo(10, 11);           // RX, TX
int ledpin=12;
int BluetoothData;

void setup() {
  Serial.begin(9600);                  // Init serial communication to verify data through serial monitor
  Serial.println("Hello serial!");     // Send init (I receive this)

  Mojo.begin(9600);                    // Init BT communication
  Mojo.println("Hello BT!");           // Send init (I do NOT receive this message)

  pinMode(ledpin,OUTPUT);
}

void loop() {
   if (Mojo.available()){              // If BT available
     BluetoothData=Mojo.read();        // Read data sent from PC to Arduino through BT
     Serial.write(BluetoothData);      // Write in serial what I sent

     if(BluetoothData=='1'){                  // If sent data is 1
       digitalWrite(ledpin,1);                // Led On
       Mojo.write(" || Mojo led ON");         // Write me the led is On (I do NOT receive this message)
       Serial.write(" || Serial led ON");     // Write me the led is On
     }

     if (BluetoothData=='0'){                 // If sent data is 
       digitalWrite(ledpin,0);                // Led Off
       Mojo.write(" || Mojo led OFF");        // Write me the led is Off (I do NOT receive this message)
       Serial.write(" || Serial led OFF");    // Write me the led is Off
     }
  }
  delay(100);
}

I use Tera Term to open a serial connection (also tried with Putty, same result). I open a new connection with serial link on standard bluetoothn on COM5. I type 1 in the serial, the led is On but nothing is written. I type 0 in the serial, the led is Off but nothing is written.

The setup of the serial port is Port: COM5 Baud rate: 9600 Data: 8 bit Parity: none Stop: 1 bit Flow control: none Transmit delay: 0msec/char 0msec/line

I can't figure out why I cannot see the message from the BT in my serial connection like in the tutorial.

Does someone have a solution on that problem ?

To me, the problem comes from the serial communication terminal and not from BT but I can't solve it.

Thank you for your help.

Ps : Excuse me for my english, it's not really my strength.

I know there are lots of topics everyday but I would like to put this topic up.

I'm not asking for an all inclusive answer but if someone has a clue. :slight_smile:

Try this

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

If nothing else, it involves a lot less code. It is also more useful for testing.

Thank you for you help, these documents helped me a lot by simplifying the process and understanding basics.
I started over from scratch and it works.

Hi Everyone,

Would anyone happen to have a working copy of the code for sending the data from the arduino back to the pc?

Thanks

Serial.print() should do the trick.

Serial.begin(9600);
Serial.println(F("Current data in sector:"));

Remember you are just hooking up to the serial lines of the processor. Make sure you get the connection the right way around. I don't have one hooked up right now to look and tell you.