Difference between revisions of "Microduino BLE Android-202KIT"

From Microduino Wiki
Jump to: navigation, search
(Created page with "{{Language|Microduino_BLE_Android-202KIT}} {| style="width: 800px;" |- | ==Outline== Project:Microduino BT communicates with Android device Objective:Android mobile send ...")
 
 
Line 4: Line 4:
 
|
 
|
 
==Outline==
 
==Outline==
Project:Microduino BT communicates with Android device
+
Project: Microduino-BT communicates with Android devices.
  
Objective:Android mobile send the character to Microduino-Core and Microduino BT and display on OLED.
+
Objective: Android phones can send character strings to Microduino-Core and Microduino-BT via phone App, and display character data via the serial monitor.  
  
Difficulty:Elementary
+
Difficulty: Primary
  
Time-consuming:30mins
+
Time-consuming: 30mins
  
Maker:Microduino Studio-YLB
+
Maker: Microduino Studio-YLB
 
|-
 
|-
 
|
 
|
  
==Bill of Materials==
+
==Bill of Materials ==
*Microduino device
+
*Microduino Equipment
 
{|class="wikitable"
 
{|class="wikitable"
 
|-
 
|-
|Module||Number||Function
+
|Module||Number||Function  
 
|-
 
|-
|Microduino-Core||1||core module
+
|[[Microduino-Core]]||1||Core board
 
|-
 
|-
|Microduino-FT232R ||1||Download program
+
|[[Microduino-USBTTL]] ||1||Program download 
 
|-
 
|-
|Microduino-BT||1||BT communication
+
|[[Microduino-BT]]||1||Bluetooth communication  
|-
 
|Microduino-S1||1||Connect the OLED
 
|-
 
|Microduino-OLED||1||Display
 
  
 
|}
 
|}
 
|-
 
|-
 
|
 
|
[[File:Android-202KIT-module.jpg|600px|center|thumb|202KIT图片]]
+
[[File:Android-202KIT2-module.png|600px|center|thumb|202KIT图片]]
 
|-
 
|-
 
|
 
|
*Software
+
*Software Equipment 
Arduino IDE (1.0 release and upper),
+
Arduino IDE(Version 1.0 and higher)
Downlaod 4.0 BT Android assistant:http://www.jnhuamao.cn/download.asp?page=2&ID=0;
 
  
*Other equipment
+
*Other Equipment
**Android device support BT 4.0, the OS should be 4.3 upper.
+
**Android devices(Version 4.3 and higher) , which supports Bluetooth 4.0. _
**micro usb cable.
+
**Micro USB cable  
  
 
==Document==
 
==Document==
Download test program:
+
Test program and App download:[[File:BT—APP.zip]]
https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_KIT/kit_android_BT
+
 
 
|-
 
|-
 
|
 
|
==Debug==
+
 
 +
==Debugging==
 
|-
 
|-
 
|
 
|
Step 1:Start Arduino IED, open the test program, select the board "Microduino Core (Atmega328P@16M,5V)";
+
    Step 1: Stack Microduino-Core and Microduino-USBTTL together, connect them to a computer with a USB cable, start Arduino IDE, open test program M_ble_Serial.ino, select Microduino Core (Atmega328P@16M,5V) from (tools)-> (Board) and choose the corresponding serial port from(tools)-> (Serial) . After that, please click the button "√" on the top left of IDE, compile the program, and then click "√" to burn the program into the board;
 
|-
 
|-
 
|
 
|
[[File:ble-Download.jpg|600px|center|thumb|Download]]
+
[[File:ble-Download2.png|600px|center|thumb|Download]]
OLED interface when download success.
+
 
[[File:BlE-OLED-success.jpg|600px|center|thumb|OLED]]
+
    Step 2: Stack all modules after the download, connect them to the computer with a USB cable and install after power-off.
Step 2:After finished download program, power off, then plug in all module.
 
 
|-
 
|-
 
|
 
|
[[File:202KIT-android-system.jpg|600px|center|thumb|202KIT-OK]]
+
[[File:202KIT-android-system1.jpg|600px|center|thumb|202KIT-OK]]
Step 3:Set Android device, start Android device's BT function;
+
 
 +
    Step 3: Start to set IOS device, get the Bluetooth function activated, install and open ".apk " file, then open the serial monitor in the IDE side of the computer.
 +
 
 +
    Step 4: Click the SCAN button on the top right of the App and you'll see peripheral Bluetooth devices as follows:
 +
[[File:202KIT-android-system3.jpg|600px|center|thumb|App—蓝牙搜索]]
 +
    Click the correpsonding Bluetooth number and enter the following interface: 
 +
[[File:202KIT-android-system4.jpg|600px|center|thumb|App—蓝牙通信]]
 +
    Wait for 203 seconds until you see "ready" on the screen, meaning the phone has established connection with the Bluetooth; By clicking the button " Sync RTC With Phone " in the middle of the screen and watch the change of the serial monitor as well as "RTC TIME" on the top of the button. 
 +
[[File:202KIT-android-system6.jpg|600px|center|thumb|App—手机App]]
 +
[[File:202KIT-android-system5.jpg|600px|center|thumb|App—串口监视器]]
  
Step 4:Open the BLE assistant;
+
You can see RTC content change on the phone and receive the corresponding data on the serial monitor side, which means the bidirectional communication function of Bluetooth.
[[File:202KIT-ble-serial.jpg|600px|center|thumb|202KIT-OK]]
 
Step 5:Click the "search device", you can find the Microduino BT device;
 
[[File:202KIT-ble-serial2.jpg|600px|center|thumb|202KIT-OK]]
 
Step 6:Click the searched equipment to match connection, mobile phone will prompte the connection process
 
|-
 
|
 
[[File:202KIT-ble-Connection.jpg|600px|center|thumb|Connection]]
 
Connect successed, LED will light.
 
|-
 
|
 
[[File:android-BlE-LED.jpg|600px|center|thumb|LED]]
 
Step 7: Enter any text in the text input box, and then click send, you can see the sent text on the OLED (English characters).
 
[[File:BlE-OLED.jpg|600px|center|thumb|OLED]]
 
Send "clean" to clear the data on OLED.
 
[[File:BlE-android-clean.jpg|600px|center|thumb|OLED]]
 
  
|-
+
==Analysis of Test Code==
|
+
<source lang="cpp">
 +
#include <SoftwareSerial.h>
 +
// RX, TX ; Use default Bluetooth communication serial 4 and 5.
 +
SoftwareSerial mySerial(4, 5);
 +
#define my_Serial mySerial
 +
String msg = "";
 +
void setup()
 +
{
 +
    // Initialize the baud rate of the serial communication.
 +
    my_Serial.begin(9600);
 +
    Serial.begin(9600);
 +
}
 +
void loop()
 +
{
 +
    //Every time it receives signal, it'll give feedback once to the other communication side.
 +
    if (my_Serial.available() > 0)  //If there is serial data input 
 +
    {
 +
        msg = my_Serial.readStringUntil('\n');  //Acquire all content before a line break. 
 +
        Serial.println(msg);  //Display character strings on "msg" in the serial monitor.
 +
        my_Serial.println("bluetooth respond");  //Send data to the other side of the Bluetooth communication.
 +
    }
 +
}
 +
</source>
  
 
==Result==
 
==Result==
Microduino Core module and Android mobile can set up connection easily by Microduino BT module.
+
By Microduino-BT, Microduino core can communicate with an Android phone.  
==Note==
+
==Caution==
*Set the serial baud rate to 9600.
+
*Serial baud rate must be 9,600 or the receiving character will cause messy codes.  
*If use the default jumper (RX0,TX1),when download the program, need plug out the Microduino BT4.0 module. After finished download, then power off to plug in again.
+
*If keeping the default jumper wire(RX0,TX1), please unplug Microduino-BT 4.0 while downloading the program, and then power off and install after the download.  
*If changed the jumper, need to change serial connection of Microduino BT4.0 and Core module, the origianl connection is TX-RX0, RX-TX1, need change to following connection:
+
*If adopting jumper wire changing method, then you can change the serial connection of Microduino-BT and Microduino-Core from TX-RX-, RX-TX1 to:
**TX-D2, RX-D3 (Corresponding to Core+'s Serial1)
+
**TX-D2, RX-D3(Serial1 for Core+
**TX-D9, RX-D10 (invoke the SoftwareSeria library to resolve this issue)
+
**TX-D9, RX-D10(You can use SoftwareSeria library to handle it.
 
 
==Video==
 
http://v.youku.com/v_show/id_XNjk0MTMyMzc2.html
 
|}
 

Latest revision as of 07:13, 16 November 2015

Language: English  • 中文

Outline

Project: Microduino-BT communicates with Android devices.

Objective: Android phones can send character strings to Microduino-Core and Microduino-BT via phone App, and display character data via the serial monitor.

Difficulty: Primary

Time-consuming: 30mins

Maker: Microduino Studio-YLB

Bill of Materials

  • Microduino Equipment
Module Number Function
Microduino-Core 1 Core board
Microduino-USBTTL 1 Program download
Microduino-BT 1 Bluetooth communication
202KIT图片
  • Software Equipment

Arduino IDE(Version 1.0 and higher)

  • Other Equipment
    • Android devices(Version 4.3 and higher) , which supports Bluetooth 4.0. _
    • Micro USB cable

Document

Test program and App download:File:BT—APP.zip

Debugging

   Step 1: Stack Microduino-Core and Microduino-USBTTL together, connect them to a computer with a USB cable, start Arduino IDE, open test program M_ble_Serial.ino, select Microduino Core (Atmega328P@16M,5V) from (tools)-> (Board) and choose the corresponding serial port from(tools)-> (Serial) . After that, please click the button "√" on the top left of IDE, compile the program, and then click "√" to burn the program into the board;
Download
   Step 2: Stack all modules after the download, connect them to the computer with a USB cable and install after power-off.
202KIT-OK
   Step 3: Start to set IOS device, get the Bluetooth function activated, install and open ".apk " file, then open the serial monitor in the IDE side of the computer. 
   Step 4: Click the SCAN button on the top right of the App and you'll see peripheral Bluetooth devices as follows: 
App—蓝牙搜索
   Click the correpsonding Bluetooth number and enter the following interface:  
App—蓝牙通信
   Wait for 203 seconds until you see "ready" on the screen, meaning the phone has established connection with the Bluetooth; By clicking the button " Sync RTC With Phone " in the middle of the screen and watch the change of the serial monitor as well as "RTC TIME" on the top of the button.  
App—手机App
App—串口监视器

You can see RTC content change on the phone and receive the corresponding data on the serial monitor side, which means the bidirectional communication function of Bluetooth.

Analysis of Test Code

#include <SoftwareSerial.h> 
// RX, TX ; Use default Bluetooth communication serial 4 and 5. 
SoftwareSerial mySerial(4, 5); 
#define my_Serial mySerial 
String msg = ""; 
void setup() 
{ 
    // Initialize the baud rate of the serial communication. 
    my_Serial.begin(9600); 
    Serial.begin(9600); 
} 
void loop() 
{ 
    //Every time it receives signal, it'll give feedback once to the other communication side. 
    if (my_Serial.available() > 0)  //If there is serial data input  
    { 
        msg = my_Serial.readStringUntil('\n');  //Acquire all content before a line break.  
        Serial.println(msg);  //Display character strings on "msg" in the serial monitor. 
        my_Serial.println("bluetooth respond");  //Send data to the other side of the Bluetooth communication. 
    } 
}

Result

By Microduino-BT, Microduino core can communicate with an Android phone.

Caution

  • Serial baud rate must be 9,600 or the receiving character will cause messy codes.
  • If keeping the default jumper wire(RX0,TX1), please unplug Microduino-BT 4.0 while downloading the program, and then power off and install after the download.
  • If adopting jumper wire changing method, then you can change the serial connection of Microduino-BT and Microduino-Core from TX-RX-, RX-TX1 to:
    • TX-D2, RX-D3(Serial1 for Core+)
    • TX-D9, RX-D10(You can use SoftwareSeria library to handle it.)