Arduino Bluetooth Shield can send data, but does not read

I’m using an Arduino Uno and a Bluetooth Shield to connect to my phone (Windows 10). I have a bluetooth terminal app that can send and read data. If I type something in the Arduino Terminal, I receive that value on my phone. However if I type something on my phone, it does not appear on the Arduino Terminal.

This is the code that checks if something is received:

void loop()
   {
       while(blueToothSerial.available()){
           myChar = blueToothSerial.read();
           Serial.print(myChar);
       }

       while(Serial.available()){
           myChar = Serial.read();
           blueToothSerial.print(myChar);
       }
   }

This is the code that sets up the Bluetooth connection:

blueToothSerial.begin(9600);  

blueToothSerial.print("AT");
delay(400); 

blueToothSerial.print("AT+DEFAULT");
delay(2000); 

blueToothSerial.print("AT+NAMEArduinoBot");
delay(400);

blueToothSerial.print("AT+PIN0000");
delay(400);

blueToothSerial.print("AT+AUTH1");
delay(400);    

blueToothSerial.flush();

On this image you can see everything is connected on my phone, and I can receive the message that my Arduino has send to my phone, but I do not receive what my phone has send to the Arduino

You need to post a complete program so we can see how all the variables etc are defined.

You may find the examples in Serial Input Basics useful.

...R

Sorry, this is the complete code:

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 7
#define TxD 6

SoftwareSerial blueToothSerial(RxD,TxD);
char myChar;

void setup()
{
    Serial.begin(9600);
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    setupBlueToothConnection();

}

void loop()
{
    if(blueToothSerial.available()){
        Serial.print("Received message: ");
        myChar = blueToothSerial.read();
        Serial.print(myChar);
    }

    if(Serial.available()){
        myChar = Serial.read();
        blueToothSerial.print(myChar);
    }
}

void setupBlueToothConnection()
{          
	blueToothSerial.begin(9600);  
	
	blueToothSerial.print("AT");
	delay(400); 

	blueToothSerial.print("AT+DEFAULT");
	delay(2000); 

	blueToothSerial.print("AT+ROLES");
	delay(400); 
	
	blueToothSerial.print("AT+NAMEArduinoBot");
	delay(400);
	
    blueToothSerial.print("AT+PIN0000");
	delay(400);
	
	blueToothSerial.print("AT+AUTH1");
    delay(400);    

    blueToothSerial.flush();
}

This is how the bluetooth shield looks like.

And this is the app I’m using to send/receive data on my phone

This will not receive a message - only a single character

if(blueToothSerial.available()){
        Serial.print("Received message: ");
        myChar = blueToothSerial.read();
        Serial.print(myChar);
    }

Have you studied the programs in the link I gave you?

...R

Yes I have, but the problem is that I'm not receiving anything at all.

nerdiator:
Yes I have, but the problem is that I'm not receiving anything at all.

Does that mean that you tried my example and it did not work?

If so, please post the actual program that YOU used and I will see if I can help.

...R

What I posted above is the actual code that I am using. The problem is that the if(blueToothSerial.available()) statement is always false.

I don't see any code that sets up Serial.

nerdiator:
What I posted above is the actual code that I am using. The problem is that the if(blueToothSerial.available()) statement is always false.

I had hoped that you would take the hint from Reply #5 and try my code.

...R