Serial monitor is not printing

Hello,
I am using the library SoftwareSerial, Arduino UNO and/or Leonardo and bluetooth HC-05, I used some tutorials to follow the comunication and configuration and my serial monitor is not printing the comunication with the bluetooth, blank always.

Inside the website I took this, there are comments from ppl saying thanks that is working… so…

#include <SoftwareSerial.h>

SoftwareSerial BT1(10, 11); // RX | TX
void setup()
   { pinMode(8, OUTPUT);       
     pinMode(9, OUTPUT);      
     digitalWrite(9, HIGH);
     delay (500) ;             
     Serial.begin(9600);
     Serial.println("Levantando el modulo HC-05"); // NOT PRINTING
     digitalWrite (8, HIGH);   
     Serial.println("Esperando comandos AT:"); // NOT PRINTING
     BT1.begin(57600); 
   }

void loop() // NOT WORKING / NOT PRINTING
   {  if (BT1.available())
            Serial.write(BT1.read());
      if (Serial.available())
            BT1.write(Serial.read());
   }

Any idea if just the code or me? I just want to discard things… I having the same problem with ESP2866 module, not reading serial comunication.

PS: The schematics are uploading well because I am using other kind of projects with no serial communication and they are working fine.

Thanks!

SoftwareSerial does not work very well. Try it at 9600 baud. And make sure your HC05 is also working at 9600 baud.

...R

Robin2:
SoftwareSerial does not work very well. Try it at 9600 baud. And make sure your HC05 is also working at 9600 baud.

...R

Hello, thanks for fast answer, I am using at 9600 baud and is supposed that my hc05 is using 9600 baud at default. But why works for everybody but not for me?

rokimoki:
Hello, thanks for fast answer, I am using at 9600 baud and is supposed that my hc05 is using 9600 baud at default. But why works for everybody but not for me?

this suggests you are using something other than 9600 baud:

BT1.begin(57600);

personally, I haven't seen issues with SoftwareSerial...

As the print statements in setup() don't work, check the communication parameters of the Serial monitor first (and fix if needed).

If that does not help, remove all software serial and try again.

BulldogLowell:
this suggests you are using something other than 9600 baud:

BT1.begin(57600);

personally, I haven’t seen issues with SoftwareSerial…

I updated my code like this:

#include <SoftwareSerial.h>

SoftwareSerial BT1(10, 11); // RX | TX
void setup()
{
  pinMode(8, OUTPUT);       
  pinMode(9, OUTPUT);      
  digitalWrite(9, HIGH);
  delay(500);
  Serial.begin(19200);
  while (!Serial); // For my Leonardo
  digitalWrite (8, HIGH);   
  Serial.println("Waiting AT command:");
  BT1.begin(9600); 
}

void loop()
{
  if (BT1.available()) Serial.write(BT1.read());
  if (Serial.available()) BT1.write(Serial.read());
}

Now it prints the “waiting AT command:”, but not anything related with the bluetooth, I swapped baud from serial and bluetooth, nothing.

sterretje:
As the print statements in setup() don’t work, check the communication parameters of the Serial monitor first (and fix if needed).

If that does not help, remove all software serial and try again.

I added that line of code because I am using Leonardo, and now that part is printing but not the bluetooth part.

while (!Serial); // For my Leonardo

PS: I added a 3.3v converter for RDX and TDX for HC05 in case that cause bad communications using 5v. (for logic 1 and logic 0 recognition for module hc05). I read that many people don’t use 3.3v tension and works…

Is this what you're using? Serial Port Bluetooth Module (Master/Slave) : HC-05 - ITEAD Wiki

Default baudrate 38400; your code is using 57600.

sterretje:
Is this what you're using? Serial Port Bluetooth Module (Master/Slave) : HC-05 - ITEAD Wiki

Default baudrate 38400; your code is using 57600.

Hello, I used all baud rates possible from 300 to 250000 and nothing happens.

I bought HC05 from ebay for a couple of euro so I suppose is that... This is my module:

Can you answer few questions?
Hope they show up in bold font

And I will not ask if your read the manual or know anything how “AT” commands work.

And even if the baud rate is wrong, you WILL get some , albeit garbled data if the device is asked to respond.

#include <SoftwareSerial.h>

SoftwareSerial BT1(10, 11); // RX | TX
void setup()
{

[b]what do these lines do?[/b]
  pinMode(8, OUTPUT);       
  pinMode(9, OUTPUT);     
  digitalWrite(9, HIGH);
  delay(500);
b]what do these lines do?[/b]


  Serial.begin(19200);
  while (!Serial); // For my Leonardo

[b]and this one ?[/b]
  digitalWrite (8, HIGH);
[b]and this one ?[/b]   

  Serial.println("Waiting AT command:");

  BT1.begin(9600);
}

void loop()
{
  if (BT1.available()) Serial.write(BT1.read());

[b]where is a printout when the above "if" fails?[/b]


  if (Serial.available()) BT1.write(Serial.read());

[b]where is a printout when the above "if"  fails?[/b]

}

Vaclav:
Can you answer few questions?
Hope they show up in bold font

And I will not ask if your read the manual or know anything how “AT” commands work.

And even if the baud rate is wrong, you WILL get some , albeit garbled data if the device is asked to respond.

#include <SoftwareSerial.h>

SoftwareSerial BT1(10, 11); // RX | TX
void setup()
{

what do these lines do?
  pinMode(8, OUTPUT);     
  pinMode(9, OUTPUT);   
  digitalWrite(9, HIGH);
  delay(500);
b]what do these lines do?[/b]

Serial.begin(19200);
  while (!Serial); // For my Leonardo

and this one ?
  digitalWrite (8, HIGH);
and this one ?

Serial.println(“Waiting AT command:”);

BT1.begin(9600);
}

void loop()
{
  if (BT1.available()) Serial.write(BT1.read());

where is a printout when the above “if” fails?

if (Serial.available()) BT1.write(Serial.read());

where is a printout when the above “if”  fails?

}

Hello, thanks for your answer, I didn’t reach the AT commands part yet because I cannot receive even the OK from AT command and I have the PDF manual ready to be used when the communications part is done.

I know if the baudrate is wrong you receive text or garbage and thats a signal that you must match the correct baudrate, I tried all baudrates possible and nothing.

That code you posted I simplified a lot following other guides like this. And they have the same loop part, they don’t need an else because if master (arduino) don’t get any message just keep cheking till master gets any message.

But I don’t receive anything from bluetooth…

rokimoki:
Hello, thanks for your answer, I didn't reach the AT commands part yet because I cannot receive even the OK from AT command and I have the PDF manual ready to be used when the communications part is done.

I know if the baudrate is wrong you receive text or garbage and thats a signal that you must match the correct baudrate, I tried all baudrates possible and nothing.

That code you posted I simplified a lot following other guides like this. And they have the same loop part, they don't need an else because if master (arduino) don't get any message just keep cheking till master gets any message.

But I don't receive anything from bluetooth...

OK , I asked few questions and you have not answer any, just repeated what have been already said.

There is nice sample code in the reference you have posted which will work without any simplification.
It is bare bones minimum you need.
But you also need to have ways to monitor your Bluetooth device directly as Bluetooth device - using suitable terminal as mentioned in same reference.

You have not mentioned having such terminal software running on your PC to monitor your communication between Arduino COM port and Bluetooth COM port.

But it is not your fault that this discussion turned into usual bashing of "SoftwareSerial" and than all that nonsense about trying different baud rates.

Stick with the manual sample code and you will do just fine.

Good luck

Moderator edit: Tag correction. Again.

To possibly help in your trouble shooting, you might try the following to communicate directly with the bluetooth module using the serial monitor:

  1. Disconnect the bluetooth module from the arduino.

  2. Load the below non serial dummy program on the arduino.

  3. Reconnect the bluetooth module to the arduino (per the below note).

  4. Communicate with the bluetooth module directly with the serial monitor.

Edit: Note that for direct communiction you will need to connect the bluetooth Tx to the arduino Tx and the bluetooth Rx to the arduino Rx pins.

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

zoomkat:
To possibly help in your trouble shooting, you might try the following to communicate directly with the bluetooth module using the serial monitor:

  1. Disconnect the bluetooth module from the arduino.

  2. Load the below non serial dummy program on the arduino.

  3. Reconnect the bluetooth module to the arduino (per the below note).

  4. Communicate with the bluetooth module directly with the serial monitor.

Edit: Note that for direct communiction you will need to connect the bluetooth Tx to the arduino Tx and the bluetooth Rx to the arduino Rx pins.

void setup() {

// put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Good idea, but than you would have to "talk AT " , right?
From what I gather so far Bluetooth is "just" wireless modem as far as interface goes , and this project is definitely not in "under the hood" mode, not yet.

Good idea, but than you would have to "talk AT " , right?

Possibly, just depends on what the bluetooth adapter is communicating with. This test setup just removes the arduino from the mix for bluetooth communication testing with the remote gizmo.

Vaclav:
OK , I asked few questions and you have not answer any, just repeated what have been already said.

There is nice sample code in the reference you have posted which will work without any simplification.
It is bare bones minimum you need.
But you also need to have ways to monitor your Bluetooth device directly as Bluetooth device - using suitable terminal as mentioned in same reference.

You have not mentioned having such terminal software running on your PC to monitor your communication between Arduino COM port and Bluetooth COM port.

But it is not your fault that this discussion turned into usual bashing of "SoftwareSerial" and than all that nonsense about trying different baud rates.

Stick with the manual sample code and you will do just fine.

Good luck

Moderator edit: Tag correction. Again.

Hello again, I did not answer any question because I considered that was not usefull to you because I changed my code, sorry for that.

zoomkat:
To possibly help in your trouble shooting, you might try the following to communicate directly with the bluetooth module using the serial monitor:

  1. Disconnect the bluetooth module from the arduino.

  2. Load the below non serial dummy program on the arduino.

  3. Reconnect the bluetooth module to the arduino (per the below note).

  4. Communicate with the bluetooth module directly with the serial monitor.

Edit: Note that for direct communiction you will need to connect the bluetooth Tx to the arduino Tx and the bluetooth Rx to the arduino Rx pins.

void setup() {

// put your setup code here, to run once:

}

void loop() {
 // put your main code here, to run repeatedly:

}

Is not supposed that TX goes to RX and RX to TX? anyway I did as you said and I don't receive anything from bluetooth.

Updated:
I discovered that iOS is not finding any HC module (only HM) so I grabed my old android device and installed a bluetooth terminal and I paired them, everything OK (at 9600 baudrate), if I send text from android I can read in serial monitor in my PC, but if I send from my serial monitor my android app don't read anything.

Also I discovered that my module enter in AT mode if I connect vcc while pressing the button from the module, that should work at 38400 baudrate, so I can't pair any device in this mode and the only way is via serial monitor, and of course I still don't get any data from the module.

Thanks.

Vaclav:
Good idea, but than you would have to "talk AT " , right?
From what I gather so far Bluetooth is "just" wireless modem as far as interface goes , and this project is definitely not in "under the hood" mode, not yet.

Actually this is for my "RC car" that is actually working, but I have some problems with RC and IR (I tested both), and I want some robust communication to use my phone as controller, not a RC controller, etc...

if I send text from android I can read in serial monitor in my PC, but if I send from my serial monitor my android app don't read anything.

Perhaps your android application expects to see the data being recieved ended with a line feed or carriage return. You can set this in the serial monitor settings at the bottom of the serial monitor window.

It the BT module; is marked "TXD" and "RXD" and the manual / spec talks about "AT" the communication protocol is modem protocol.

So you do have Bluetooth terminal software and the sample code still does not work?

Vaclav:
It the BT module; is marked "TXD" and "RXD" and the manual / spec talks about "AT" the communication protocol is modem protocol.

So you do have Bluetooth terminal software and the sample code still does not work?

Just if I send from android bt terminal to arduino, but I think is enough for my project but I want everything working for the future. I mean, if I send from arduino to BT is not recognized (nothing happens)

Can yu post your current code ?

Just if I send from android bt terminal to arduino,

In the test setup I recommended, if what is being sent from the android is being displayed on new lines in the serial monitor, the the android application is adding a cr/lf to what it is sending. If that is a fact, then the android application probably expects what is being sent to it to have a cr/lf at the end.