Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Plug-in Bluetooth on Android and Arduino+HC-6.
Started by pannikser Apr 09 2019 08:50 AM

2 replies to this topic
plug-in bluetooth android arduino hc-6
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

pannikser

[GLOBAL: userInfoPane.html]
pannikser
  • Observer

  • 2 posts
  • Corona SDK

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.

 



[TOPIC: post.html]
#2

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,807 posts
  • Enterprise

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



[TOPIC: post.html]
#3

pannikser

[GLOBAL: userInfoPane.html]
pannikser
  • Observer

  • 2 posts
  • Corona SDK

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?



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: plug-in bluetooth, android, arduino, hc-6