Bluetooth Tx to android

Hi,

I’m new to arduino. I’m trying to do some basic BLE TX to Android.

I can’t figure out how to get simple button status from any pins to a Android. I tried println to Serial1 but no luck. Printing to Serial works for serial monitor but I can’t figure out the Bluetooth portion. I tried many Android apps but can’t seem to receive anything. I started studying MITappInventor assuming that it’s Android that I need to work on.

Can anyone help. Thanks

Do you mean Serial1.write(“blah”) and get the string at Android side? You must set notify on for the TX characteristic.

Could you please post your example sketch here?

#define BAUD_RATE 9600


 int pirSensor = 16;

void setup() {
    Serial1.begin(BAUD_RATE);
    
    while (!Serial1 ) {
        ; // wait for serial port to connect. Needed for Leonardo only
    }
    
    Serial.begin(BAUD_RATE);
    
    while (!Serial ) {
        ; // wait for serial port to connect. Needed for Leonardo only
    }
    pinMode(pirSensor, INPUT);
    
}

void loop() {
 
     
   if (digitalRead(pirSensor) == HIGH ) 
   Serial1.println("Motion Detected");
    
  
    if (digitalRead(pirSensor) == LOW )
    Serial1.println("No Motion");

   if (digitalRead(pirSensor) == HIGH ) 
   Serial.println("Motion Detected");
    
  
    if (digitalRead(pirSensor) == LOW )
    Serial.println("No Motion");   
  
}

I’m new to arduino. I just started reading about UUID and Notify but I don’t know how to implement it.

Can you give me a example.

Also, if I use the Android Bluo app, will that read all incoming data or do I need to specify which uuids and characteristics to listen for?

Thanks for the help

Have you tried the app Bluo? Please do following steps

  1. Scan devices and connect to ZeroBeacon.
  2. Check service 0xFFF0 and tx characteristic 0xFFF1
  3. Set notify on
  4. Use Serial1.write(“your data”) to send data

I suggest you upload the sketch hardwareSerialMonitor to BlueDuino first. So you can use the serial monitor to send data directly

Where do I Check service 0xFFF0 and tx characteristic 0xFFF1?

How do i Set notify on?

Can you show me screenshots of this working by you.

I would like to recommend your product for all of our school projects but the documentation is very little. So far I can’t get a working system. I’m trying to convince my staff to order from you but I have nothing to show them.

I appreciate your help

Our engineer will post screenshot for you later.

Please check the photo.

We tested this with these steps

  1. Install bluo at Nexus 5
  2. upload sketch hardwareSerialMonitor to blueduino, the firmware for bluetooth is 2.1.7. You can check this with command AT+VERS?
  3. Open app bluo
  4. Tap the magnifier icon to scan devices
  5. connect the device ZeroBeacon
  6. tap on Start button after connected
  7. send “abc” or other strings at bluo, you will see “abc” at Arduino IDE’s serial monitor
  8. type “hello” at serial monitor, you will see “hello” in app bluo

Let me know if this work for you

Hi

I followed your instructions. It worked. I was able to get the Bluo app to talk to Serial monitor.

But…

If I run my own sketch, the Blueduino will only transmit data if I print to Serial1 AND Serial.
And it only transmits data if I first open serial monitor and then close serial monitor.

If I just print to Serial1, the Blueduino won’t transmit. And if I print to Serial1 AND Serial, but I don’t open and close serial monitor, the Blueduino won’t transmit either.

It seems like Serial needs to be activated before Serial1 will activate.

This won’t work for a standalone project where the Blueduino isn’t connected to a computer.

What do you suggest?

I’m on firmware 2.1.5

Please remove these line if the blueduino isn’t connected to PC. Because Serial for ATMega32u4 is a virtual serial port. It only be available when connected to PC.

while (!Serial ) {
        ; // wait for serial port to connect. Needed for Leonardo only
}

These lines are not needed. Serial1 is always available. It’s a hardware serial port.

while (!Serial1 ) {
        ; // wait for serial port to connect. Needed for Leonardo only
}

Hi, I tried that. I shortened my code but it didn’t help. I don’t get any text in the Bluo app

 int pirSensor = 16;

void setup() {

    Serial1.begin(9600);
    
    pinMode(pirSensor, INPUT);
}

void loop() {
 
   if (digitalRead(pirSensor) == HIGH ) 
   Serial1.println("Motion Detected");
    
    if (digitalRead(pirSensor) == LOW )
    Serial1.println("No Motion");

   }

Please test this sketch. I can get “Motion Detected” every 2 seconds at app bluo.

void setup() {
    Serial1.begin(9600);
    pinMode(pirSensor, INPUT);
}

void loop() {
   Serial1.println("Motion Detected");
   delay(2000);
}

Yay it works!

Adding the delay() fixed it.

Thank you for all the help!
Thank you thank you