0

I have a hm-10 module attached to Arduino Leonardo board, I'm using a bluetooth terminal app to send some text.

The problem is I can send data from the Serial monitor to my phone but when I send from my phone, there is no output in the serial monitor.

It works fine if I test it on Arduino Uno. I'm struggling with something that should be simple.

Can someone please help me?

Here is my code:-

#include <SoftwareSerial.h> 

SoftwareSerial BTSerial(4, 5); 

void setup(){
  Serial.begin(115200);            
  Serial.println("Hello!");      
  BTSerial.begin(115200);
}

void loop(){
  while (BTSerial.available()){ 
    byte data = BTSerial.read();
    Serial.write(data);
  }  

  while (Serial.available()){
    byte data = Serial.read();
    BTSerial.write(data); 
  }
}
1
  • 1
    Leonardo has Serial1. You don't need to use SoftwareSerial
    – Juraj
    Sep 24, 2021 at 4:33

1 Answer 1

1

I GOT IT!! It was problem with the pin settings.

According to SoftwareSerial library documentation, only pins 8,9,10,11,14,15,16 can be used for RX pin. But i used pin 4 for RX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.