0

How do I improve Bluetooth communication?

You will see, in this image using the Bluetooth monitor application, in order to receive the "ON" response, I had to repeatedly send the "O" character:

enter image description here

The code that I'm using now is this:

#include <SoftwareSerial.h>
const int RX_PIN = 0;
const int TX_PIN = 1;
char c = 'F';
boolean activar = false;

SoftwareSerial blueTooth(RX_PIN, TX_PIN);
void setup ()
{
  Serial.begin(9600);
  blueTooth.begin(9600);
}

void loop ()
{
  if(Serial.available() > 0){
    c = Serial.read();
    if(c == 'O'){
      activar = true;
      Serial.println("ON");
    }
    if(c == 'F'){
      activar = false;
      Serial.println("OFF");
    }
  }
  if(activar){
     detectarObstaculos();
  }
}

void detectarObstaculos(){

}

How could I improve the response time?

  • 1
    Why are you using software serial on pins 0 and 1? How do you expect to work alongside hardware serial which also uses pins 0 and 1? – gre_gor Apr 11 '18 at 17:31
  • I see it on a tutorial (instructables.com/id/…) Is that the problem then? – TwoDent Apr 11 '18 at 17:33
  • The (unused) bluetooth SoftwareSerial object is conflicting with the HardwareSerial object on the same pins that you are using. One or the other. Make your mind up. – Majenko Apr 11 '18 at 17:33
  • Instructables is full of crap. It should be deleted from the internet. – Majenko Apr 11 '18 at 17:33
  • Ugh, so the tutorial was bad .... I see. @Majenko, I will change my pins then – TwoDent Apr 11 '18 at 17:35

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.