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.