Error 507, unable to connect

Maybe this can help you :

1 Like

not getting anything salman brother, isnt there anything which you can change in my blocks so that i can use the app?? I am going into some sort of depression now :sob: :sob:

Ah, I see - the equivalent of Fritzing. HC-05 Module is Bluetooth v2.0 + EDR. So, you are only wireless to the Arduino, the household devices are wired to the Arduino.

Utakarsha, have you ever heard the phrase "less haste, more speed"? It definitely applies to you :grin:

I'm attaching a Basic Setup project for sending text. It should work straight-out-of-the-box, many other people have used it as the base of their project.

For now, see if it solves your connection fault.

Next, we can test sending commands.

Finally, I will show you how to drive commands with speech.

BT_Basic_Setup_Send.aia (7.8 KB)

.... the Sketch needs some work :owl:

The Sketch, once we get over the other hurdles, should be like this:

AppToArduino_Cmds.txt (1.5 KB)

Note that speech commands must be "short and sweet".

//Receive commands from App

//vars
string sgCommand;
unsigned int igUpdateTime;

void setup()
{
              Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
         igUpdateTime = millis(); // loop timer
}

void loop()
{
         //Execute loop every 10 seconds
	     if((millis() - igUpdateTime) > 10000)
         {
               igUpdateTime = millis();

               if(Serial.available() > 0)
               {
                     sgCommand = Serial.read();

                     switch (sgCommand)
                     {

                       case "light on":
                                digitalWrite(5, HIGH);
                                break;

                       case "light off":
                                digitalWrite(5, LOW);
                                break;

                       case "fan on":
                                digitalWrite(6, HIGH);
                                break;

                       case "fan off":
                                digitalWrite(6, LOW);
                                break;

                       case "all on":
                                digitalWrite(5, HIGH);
                                digitalWrite(6, HIGH);
                                break;

                       case "all off":
                                digitalWrite(5, LOW);
                                digitalWrite(6, LOW);
                                break;
                     }
               }
         }
}

Utakarsha

I'm taking a lunch break. When you have got the connection working, let me know here and I will upload an Enhanced Project that can handle Speech Commands (it is an update of the Basic Project)

Proteus Simulation for Bluetooth Module

Has no one in this thread yet mentioned that the error 507 happens when you try to send Bluetooth data but the BlueTooth device is not yet connected?

I don't see any code in the Original Poster's app that prevents this from happening.

The ChrisWard sample app does this by disabling the button that sends text until the BlueTooth component is connected.

Hi ABG - the Basic Project I uploaded addresses that issue.

Waiting for your feedback Utakarsha.

Hi,
are you sure of the HW connections ?
I don't see any power and ground lines to the HC06 in your schematic so I think that they aren't simply drawn, but you connected them.
More: the RX of the HC06 shall work @3.3 Volts, then a voltage divider is better for HC06 health.
Something like this:
image
It's a stupid hint, I believe, but before fighting with software be sure that the hardware is correct :slight_smile:
Cheers.

This is not my circuit, it is a Youtube tutorial by an author named Ibrahim kamr.
Look at the tutorial, it works for him.
I only put it to give an idea to any reader, the way to simulate Arduino, Bluetooth and a smartphone.
Here's another one, it's not mine either :slight_smile:

Oooops I replied to the wrong post.... :upside_down_face:
I wanted to reply to Utakarsha's drawing :grin: :grin: :grin:
My apologies Juan Antonio !!!

PS anyway a voltage divider could be safer for the BT shield..HC-05_Bluetooth.pdf (3.1 MB)

PPSS Utakarsha, in the annex file you can find a data sheet of the HC05, where you can read that originally the HC05 is factory set at 38400 (like mine bougth at AZDelivery in June 2020) . BUT, according to Patrick's post here below, some others have a 9600 baudrate default setting. If you don't have set a specific baudrate on your own, you can use the following chunk of code to scan the baudrate and discover which is set on your HC05 shield.
Hoping it can help.


/*Wire the HC-05 Rx pin to UNO pin 11 (possibly with a voltage divider) and HC05 Tx pin to UNO pin 10. Take care to connect UNO pin2 to EN pin of HC05
BEFORE YOU CONNECT THE ARDUINO TO THE USB remove the VCC (power)  wire from the HC-05 so it's not getting any power from the Arduino. All other wires are still connected.
Now connect the Arduino Uno to the USB cable  from your PC.
Re-connect the Arduino Uno 5V wire to the HC-05's VCC (5V power) pin. 
Verify theat the HC-05 LED will blink on and off at about 2 second intervals. If so,  the HC-05 is in AT command mode ready to accept commands to change configuration and settings. Start the serial monitor on the PC.
The code here below scans various baudrates to find which one is set. Once found you should see an "OK", if not: please check the wiring.
*/
#include <avr/io.h>
#include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11); // RX, TX

String command = ""; // Stores response of the HC-06 Bluetooth device
long baud;

void setup() 
{
  pinMode(2, OUTPUT);  // this pin will pull the HC-05 pin 34 (EN pin) HIGH to switch module to AT mode
  digitalWrite(2, HIGH);
  // Open serial communications:
  Serial.begin(115200);                       // Toward serial monitor
  baud = 9600;
  provatx();
  baud = 19200;
  provatx();
  baud = 38400;
  provatx();
  baud = 57600;
  provatx();
  baud = 115200;
  provatx();
}


void provatx()
{
     Serial.print("Checking communication at "); 
     Serial.println(baud);
     mySerial.begin(baud);                                    //toward HC05
     delay(10);
     mySerial.write("AT\r\n");
     delay(500);
     if(mySerial.available())
     {
      while(mySerial.available()) 
      { 
        command += (char)mySerial.read();
      }
     }
     Serial.print("Received: ");
     Serial.println(command);
     delay(2000);
}



void loop()
{
// nothing to do   
}

All the hc-05 and hc-06 I bought had a standard speed of 9600, not 38400. Recently, there was a post by one person who set the script speed to 38400 and the application did not work. After changing to 9600, it was ok.

1 Like

I think @Utakarsha wants to connect a mobile with the Proteus circuit simulator program via Bluetooth. In the simulator he has put an Arduino and a Bluetooth module.

It is necessary that the laptop has Bluetooth or a PC with a Bluetooth dongle, in my case I have used a PC-Desktop with a Bluetooth dongle.

I have made this connection:

In the Arduino of the simulator I have loaded this sketch:

// Juan A. Villalpando
// http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm

#define Pin12 12
#define Pin13 13
char caracter;

void setup() {
Serial.begin(9600);
pinMode(Pin12, OUTPUT);
pinMode(Pin13, OUTPUT);
}

void loop() {
if(Serial.available()) {
caracter = Serial.read();

if(caracter == 'a'){ digitalWrite(Pin12, HIGH);}
if(caracter == 'b'){ digitalWrite(Pin12, LOW);} 
if(caracter == 'c'){ digitalWrite(Pin13, HIGH);}
if(caracter == 'd'){ digitalWrite(Pin13, LOW);}

}

}

In App Inventor I have used this code:

  • Device Manager.

Hi Utakarsha

Attached is an Enhanced Project that works with the actual Arduino Hardware + Sketch that I have already posted, AppToArduino_Cmds.txt.

As I mentioned before, keep the spoken commands short for best possible success with speech-to-text. In my code, when the User speaks, the result is compared to a list of the available commands - if found, the command is sent, if not found, the User is asked to try again.

BT_Basic_Setup_Send_Cmds.aia (9.9 KB)

Click on the Blocks image to see it full-size.
The voice command method I show here has been proven to work, used to drive a robot.

Another Youtube video, this video contains the code this topic refers to.
Voice Controlled Home Automation Using Arduino & Bluetooth Module | Android App on MIT APP Inventor

A few things wrong in the App Code of that Video, I would discourage people from trying to reproduce it.

Edit:
The Speech Recognizer Blocks are not used correctly, nor is the speech recognition itself - for example, whatever the User says is simply sent to the device without checking it's validity.

See my posts above for an example Application and matching Arduino Sketch that have been proven to work.

5 posts were merged into an existing topic: Im trying to connect my HC05 to my app but i dont know what im doing this is for my finals project