Error 507 unable to connect is the device turned on?

Hello friends, I'm new to this. I have a problem: when I try to connect to HC-05, I always get the error 507. I've already tried it with several devices and it still gives me the same error.




ARDUINO CODE:

char Incoming_value = 0;     
void setup() 
{
  Serial.begin(9600);         
  pinMode(13, OUTPUT);       
}

void loop()
{
  if(Serial.available() > 0)  
  {
    Incoming_value = Serial.read();      
    Serial.print(Incoming_value);        
    Serial.print("\n");        
    if(Incoming_value == '1')             
      digitalWrite(13, HIGH);  
    else if(Incoming_value == '0')       
      digitalWrite(13, LOW);   
  }                            
}

Try to ask for connect and scan permissions, then try again, see the following thread

Taifun

...you also need location switched on - you can do that by dragging a location sensor item into the designer - your code can ignore it.

(added to FAQ)

Thanks everyone. It seems that, although the HC-05 worked with the Bluetooth serial monitor but not with MIT App Inventor, I tried another HC-05 and it worked. Apparently, some HC-05s are not compatible with MIT App Inventor, but they are compatible with other applications.

Dear @ANGELO_Escobar,
happy that it works with another HC05 but, honestly, this is pretty weird :grin:

May I suggest you some hints, anyway ?
In your Arduino code I see that you use the UNO pins 0,1 to connect the HC05, but please be aware that those pins are the ones used for the Arduino Monitor (toward the PC), therefore any time you read or write to those pins, you attempt to read and write to both the HC05 and the Arduino monitor as well, thus generating a possible conflict.

I see in your code (please see my //comments):
Incoming_value = Serial.read(); // this row attempts to read from the BT, but also any character received from the PC will load the incoming PC buffer
Serial.print(Incoming_value); // this row sends to both the PC monitor and the BT line the just received char, so your app will receive suddenly the same character that has been sent when the Button1 or Button2 has been pressed, like an echo.

For the time being you don't have implemented any receiving procedure in your app, but as soon as you'll implement a receiving function, the input buffer of the app will be (over)loaded by the echo characters not handled yet, with a probable overload of the buffer.

To solve this, since the UNO board does not have a second hardware serial line, it's better that you allocate the serial line for the BT to other pins (i.e. 10,11) by using the SoftwareSerial library. You can find a lot of examples here on the forum and in the web sites of other power users like @ChrisWard (professorcad.co.uk), @Taifun (puravidapps.com) , and many others ...

On the FAQ managed by @ABG, and linked in his previous post, you can find also how to correctly and safely handle the BT comm's taking care of the various data types. For example, the "text" transmission/receiving are the most robust ones, but you have to take care of the way of sending from Arduino (the last transmission shall end with a BTserial.println();).

Best wishes.

1 Like