Plug-in Bluetooth on Android and Arduino+HC-6.

On the Android device, the plug-in “bluetooth-demo” of Scott Harrison in the original version is installed (the device tried different-a tablet GS700 with android 4.4.2, a smartphone Sony Xperia M5 with android 6.0 and Samsung Galaxy J1 MiniPrime with android 6.1).

HC-06 is connected to Arduino UNO and a simple sketch is filled:

int LED = 13;

void setup()

 {

   Serial.begin(9600); 

   pinMode(LED, OUTPUT);

 }

void loop() 

 {

  delay(1000);

  Serial.print(“0123456789”);

  delay(1000);

 }

The connection is established normally, a message pops up:

if (event.type == “connected”) then   native.showAlert( “Connected to device”, “Name:”…event.deviceName, {“Ok”} )

But the message does not come, i.e. the message delivery window does not pop up:

if (event.type == “message”) then   native.showAlert( “Message Received”, “Name:”…event.error, {“Ok”} )

We need to get a string from Arduino to Android.

Please tell me where there may be a mistake?

Additional information to help:

With the help of this plug-in installed on the Android device, we can send messages to Arduino with the Bluetooth module HC-06. It works well.

With the help of the bluetooth terminal installed on android, it is possible to both receive and send messages to Arduino.

Have you tried these plugins?

https://marketplace.coronalabs.com/corona-plugins/hc-module

https://marketplace.coronalabs.com/corona-plugins/bluetooth-bytes

The data returned by the device is probably  not a string

The first plugin did not try.

The second tried. In the sketch we change:

  Serial.write(45);

I tried to send different types of data to the bluetooth terminal. He defines them according to type.

From the Arduino documentation:

"Characters and strings are sent as is.

Serial.print(“Hello world.”) gives “Hello world.”

Drew attention to the fact that if you set the speed in the sketch is NOT 9600, then the bluetooth terminal on Android accepts the wrong data or does not accept at all.

Maybe this is the problem?

On the Android device, the plug-in “bluetooth-demo” of Scott Harrison in the original version is installed (the device tried different-a tablet GS700 with android 4.4.2, a smartphone Sony Xperia M5 with android 6.0 and Samsung Galaxy J1 MiniPrime with android 6.1).

HC-06 is connected to Arduino UNO and a simple sketch is filled:

int LED = 13;

void setup()

 {

   Serial.begin(9600); 

   pinMode(LED, OUTPUT);

 }

void loop() 

 {

  delay(1000);

  Serial.print(“0123456789”);

  delay(1000);

 }

The connection is established normally, a message pops up:

if (event.type == “connected”) then   native.showAlert( “Connected to device”, “Name:”…event.deviceName, {“Ok”} )

But the message does not come, i.e. the message delivery window does not pop up:

if (event.type == “message”) then   native.showAlert( “Message Received”, “Name:”…event.error, {“Ok”} )

We need to get a string from Arduino to Android.

Please tell me where there may be a mistake?

Additional information to help:

With the help of this plug-in installed on the Android device, we can send messages to Arduino with the Bluetooth module HC-06. It works well.

With the help of the bluetooth terminal installed on android, it is possible to both receive and send messages to Arduino.

Hi guys,

I’ve been playing with Scott’s “bluetooth plugin”. If u want to read data from arduino, you must transform the message into a string:

tostring(event.message)

Cheers