Arduino sending data to Android app via Bluetooth

This might be a very basic question but i'll still ask cause i'm a noob.

Explaining the complete project here is irrelevant so i'll just talk about what i want to achieve.

I want the Arduino ( UNO ) to send some kind of data/notification to my android app (App inventor). I've done all i could but i dont know why the app is not receiving is not displaying what i want it show.

I'm not sure where i'm mistaken.

To keep it simple ill just add the relevant part of the code:

 SoftwareSerial Bluetooth(2,3); 
int BLUE;
void setup()  
{
  Serial.begin(9600);        
  Bluetooth.begin(9600);}
void loop()                    
{
  Bluetooth.listen();
  delay(500); 
   if (Bluetooth.available()) 
   {
    BLUE = Bluetooth.read();
    Serial.write(BLUE);   
    
   }
   LOCK_UNLOCK(); }
LOCK_UNLOCK(){
if (BLUE== '6')
  {
      Bluetooth.println("data from outdoor to app");
  }
}

Try Serial.print, not Serial.write...

I tried but wont it print "data from outdoor to app" to the serial monitor :frowning: :confused: . I want "data from outdoor to app" to go get displayed in the app's interface

Okey, I thought it was a debug/test print You wanted to do.
Is the app properly set up to read the USB port?
If Serial monitor is off it ought to be possible to pick up data from the USB port.
Check the difference between Seril.write and Serial.print!

The following codes that you have posted (with two errors: #include<SoftwareSerial.h> is missing; void is missing before LOCK_UNLOCK()) are working alright in my following setup:
Arduino UNO + Android Smart Phone + HC05

hc5-1.png

#include<SoftwareSerial.h>
SoftwareSerial Bluetooth(2, 3);
int BLUE;

void setup()
{
  Serial.begin(9600);
  Bluetooth.begin(9600);
}

void loop()
{
  Bluetooth.listen();
  delay(500);
  if (Bluetooth.available())
  {
    BLUE = Bluetooth.read();
    Serial.write(BLUE);

  }
  LOCK_UNLOCK();
}

void LOCK_UNLOCK() 
{
  if (BLUE == '6')
  {
    Bluetooth.println("data from outdoor to app");
  }
}

hc5-1.png

I only added the relevant part of the code but yes it was kinda stupid of me to skip #include<SoftwareSerial.h> here, but it is included in the original code i assure you that.

I'm sure the app's code is perfectly fine, cause every where on the internet it says do this and that and i followed it perfectly

You have not said if your system is working or not?

App is not showing expected info....

Rest of the system is working fine but the app is not showing expected info, im not sure if the app is not able to receive it OR the arduino is not able to send the info

Geeky_Goku:
not sure if the app is not able to receive it OR the arduino is not able to send the info

Why not just try to send the data to a plain-vanilla terminal?