HC-05 bluetooth module

Hello everyone. I've recently bought a bluetooth module, and I was introduced to this site and app. I'm trying to establish a connection between arduino and my phone (I basically want the sensors data read by my module and displayed on the phone), but apparently everytime I tried it never displayed anything. In the pic above you can see my program for the screen I'm having an issue with. Assuming I've already made the phone and the module connect in the previous screen, I personally don't see something wrong with it, but perhaps you can help me. Thanks in advance

If you want to use bluetooth, give up multiple screens. The bluetooth disconnects when changing the screen. You can use multiple arrangements that you can hide and show to create virtual screens.

Yeah that's a good point, but I've also tried to put a listpicker for bluetooth connection in the same screen and it started giving me error 515. Do you think it's because I've cast a bluetooth connection twice in different screens? I wouldn't want to exploit your suggestion (which is a long process, reprogramming everything) and then finding out it has the same problem. If you know arduino, can you tell me what to put? Maybe I've wronged in that part, but I simply put a serial.begin and serial.print so I don't think it's because of that.

You can think of individual screens as individual programs - for all intents and purposes, they are, hence the Bluetooth problem. If you use Arrangements to make Virtual Screens on one 'real' Screen, that avoids the issue.

Try this:
BT_Basic_Setup_Receive.aia (8.4 KB)

This is a basic project, used by (and butchered by) many and so known to work.

Here is the most basic of Sketches:
ClassicBt_Arduino_ToApp.txt (654 Bytes)

Ensure that Location is switched on (on your phone).

I think I found the problem. It had a problem with the function Serial.available. Although my program didn't recognize your function .connected as "belonging of the hardwareserial class" (do I need a specific library for it?), I commented the if part and I made it only print, and it actually worked.

Serial1 would either be an extra hardware channel or yes, a channel added via a lib. My example used Serial, available on all Arduino boards. For a software Serial: #include<SoftwareSerial.h>

1 Like

Error 515 will occur when you send data from "clock1" component before establishing bluetooth connection. So first connect BT and then turn on "clock1" to send and receive data.

1 Like

Even though I included Software.Serial, the program still doesn't recognize the function, how can I use that Serial.connected you used?

There is no serial.connected () function on the arduino side. Arduino has no hardware detection if the BT module is connected. you can do it by connecting to arduino pin "state" from BT module and checking the state of this output.

1 Like

Oh okay, thank you! I will try remaking the app now that I have to put everything in one screen, and I will also help myself with that example you sent me, those are some nice good advices. Thank you so much!

This can be done like this:

//ArduinoToApp.ino  Chris Ward 29/10/2019 21:56:22

//Fake data stream to test App

//vars
unsigned long lgUpdateTime;

void setup()
{
       Serial.begin(9600);
       lgUpdateTime = millis();
       pinMode(5, INPUT);        //STATE pin from HC05 module connect to pin5 in arduino
}

void loop()
{
    if(millis() - lgUpdateTime > 1000) //Loop approx every 1 seconds
      {
           lgUpdateTime = millis();



           if (digitalRead(5) == HIGH) //check the status of the HC05 module
           {
                     //To App via Bluetooth
                     Serial.print("Hello");
                     Serial.println();  //This tells App "End of Data"
                                        //= Ascii LineFeed Char Num 10
           }
      }

}
1 Like

One question: why does the app need the location enabled? Won't it work properly without it?

If you are using classic bluetooth, localization is not needed. With BLE it is necessary.

1 Like