Difference between revisions of "MCookie-BT"

From Microduino Wiki
Jump to: navigation, search
(Specification)
 
(21 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
|
 
|
 
[[file:mCookie-bt-rect.jpg|400px|thumb|right|mCookie-BT]]
 
[[file:mCookie-bt-rect.jpg|400px|thumb|right|mCookie-BT]]
mCookie-BT is low-consumption serial transmission module, which can communicate with other Bluetooth devices such as phone and ipad.  
+
mCookie-BT is a Bluetooth low-consumption(BLE) serial transmission module, which can communicate with other Bluetooth devices after connection, such as phoneand iPad with the help of the relative APP.  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
==Features==
 
==Features==
 
*Low power consumption.  
 
*Low power consumption.  
*Support iBeacons.  
+
*Support iBeacons mode.  
*Small, stackable and economic.
+
*Small, cheap, stackable and open.
  
 
==Specification==
 
==Specification==
 
* Way of Communication: Serial port transmission and the default serial port is D0(RX), D1(TX);
 
* Way of Communication: Serial port transmission and the default serial port is D0(RX), D1(TX);
*Power supply: +3.3VDC 50mA;
+
*Power supply: +3.3VDC 50mA;
 
*Status indicator:  
 
*Status indicator:  
 
**Before Bluetooth connection  
 
**Before Bluetooth connection  
Line 28: Line 20:
 
*** Slave machine indicator keeps on for one second every two seconds.
 
*** Slave machine indicator keeps on for one second every two seconds.
 
**After connection:
 
**After connection:
*** The indicator of both the host and the slave machine keeps on for 100ms every five seconds.   
+
*** The indicator of both the host and the slave machine keeps on for 100ms every five seconds(twinkle to save power).   
 
* During the transmission, each data package should include less than 120 bytes. The higher the baud rate is, the longer transmission interval is. There exists loss rate during Bluetooth data transmission. So users should be ready for re-transmission or data check.   
 
* During the transmission, each data package should include less than 120 bytes. The higher the baud rate is, the longer transmission interval is. There exists loss rate during Bluetooth data transmission. So users should be ready for re-transmission or data check.   
 
*All AT instructions end with "\r\n " so you should choose "\r\n " while debugging under AT instructions. Most AT instructions work before connection and all data pass through after connection.
 
*All AT instructions end with "\r\n " so you should choose "\r\n " while debugging under AT instructions. Most AT instructions work before connection and all data pass through after connection.
* iBeacon has been integrated. Set by AT instruction “AT+MODE2\r\n” can be achieved only under slave machine.   
+
* iBeacon has been integrated. Set by AT instruction "AT+MODE2\r\n" can be achieved only under slave machine.   
 
** Work mode: 0(transmission), 1(Direct drive) and 2(iBeacon);  
 
** Work mode: 0(transmission), 1(Direct drive) and 2(iBeacon);  
** iBeacon can be tested by Local iBeacons offered on App Store. Here is the reference: http://blog.csdn.net/mzy202/article/details/20365691
+
** iBeacon can be tested by Local iBeacons offered on App Store freely, and it currently displays the distance. For the usage method, please refer to:
[[File:ble-rule.jpg|600px|center|thumb]]
+
 
*Way of Communication: Serial port transmission and the default serial port is D4(RX), D5(TX);
+
[[File:ble-11rule.jpg|600px|center|thumb]]
*Power Supply: +3.3VDC 50mA;
 
*Bluetooth Protocol: Bluetooth Specification V4.0 BLE;
 
*Service Support: Central & Peripheral UUID FFE0,FFE1;
 
*Frequency: 2.4GHz ISM band;
 
*Way of Modulation: GFSK(Gaussian Frequency Shift Keying);
 
*Transmit Power: ≤4dBm;
 
*Flexibility: ≤-84dBm at 0.1% BER;
 
*Transmission Rate:
 
**Asynchronous: 6 kbps;
 
**Synchronous: 6 kbps;
 
*Status Indicator:
 
**Before connection:
 
***Host machine indicator keeps on for 100ms every second when not recording slave machine address; 
 
***Host machine indicator keeps on for 900ms every second when recording slave machine address;
 
***Slave machine indicator keeps on for one second every two seconds.
 
**After connection:
 
**The indicator of both the host and the slave machine keeps on for 100ms every five seconds. 
 
*During the transmission, each data package should include less than 120 bytes. The higher the baud rate is, the longer transmission interval is. There exists loss rate during Bluetooth data transmission. So users should be ready for re-transmission or data check. 
 
*iBeacon has been integrated. Set by AT instruction “AT+MODE2\r\n” can be achieved only under slave machine.
 
**Work mode: 0(transmission), 1(Direct drive) and 2(iBeacon);
 
**iBeacon can be tested by Locate iBeacons offered on App Store. Here is the reference: http://blog.csdn.net/mzy202/article/details/20365691
 
  
 
==Document==
 
==Document==
Line 113: Line 84:
 
[[File:ble-Download2.png|600px|center|thumb|Download]]
 
[[File:ble-Download2.png|600px|center|thumb|Download]]
  
Step 2: Start to set Android device, open the Bluetooth function, the App and the serial monitor on the computer IDE.
+
Step 2: Start to set Android device, open the Bluetooth function, the App and the serial monitor on the computer IDE.
 +
 
 
Step 3: Click SCAN button on the top right of the App, which is for searching Bluetooth devices nearby.  
 
Step 3: Click SCAN button on the top right of the App, which is for searching Bluetooth devices nearby.  
 
Click the corresponding Microduino Bluetooth device to enter the interface, wait for 2-3 seconds until you see "Serial Ready" on the top right of the screen, meaning the phone has been connected with the Bluetooth.
 
Click the corresponding Microduino Bluetooth device to enter the interface, wait for 2-3 seconds until you see "Serial Ready" on the top right of the screen, meaning the phone has been connected with the Bluetooth.
[[File:202KIT-android-ready.jpg|600px|center|thumb|App—手机App]]
+
[[File:202KIT-android-ready.jpg|600px|center|thumb|App—App]]
 
The phone sends characters to mCookie, which will be displayed on the serial monitor while at the same time, the phone will also receive "^_^ Hello,mCookie!" from mCookie, which can verify the bidirectional communication function of Bluetooth.   
 
The phone sends characters to mCookie, which will be displayed on the serial monitor while at the same time, the phone will also receive "^_^ Hello,mCookie!" from mCookie, which can verify the bidirectional communication function of Bluetooth.   
[[File:202KIT-android-system50.jpg|600px|center|thumb|App—串口监视器1]]
+
[[File:202KIT-android-system50.jpg|600px|center|thumb|App—Serial monitor1]]
[[File:202KIT-android-system60.jpg|600px|center|thumb|App—手机App1]]
+
[[File:202KIT-android-system60.jpg|600px|center|thumb|App—App1]]
  
 
===Communicate with IOS Device ===
 
===Communicate with IOS Device ===
Line 147: Line 119:
 
[[File:ble-Connection4.jpg|400px|center|thumb]]
 
[[File:ble-Connection4.jpg|400px|center|thumb]]
 
You can see from the picture that the serial port receives phone data "12345" and the phone side also gets return data " bluetooth respond " from Bluetooth, meaning the bidirectional Bluetooth communication is smooth.
 
You can see from the picture that the serial port receives phone data "12345" and the phone side also gets return data " bluetooth respond " from Bluetooth, meaning the bidirectional Bluetooth communication is smooth.
 +
 +
===Communication with MAC===
 +
The Bluetooth of MAC cannot be connected with the research of the BT directly, and Light Blue is needed to develop, download.
 +
*Connect the mCookie-CoreUSB and module BT to the computer, and download the same code.
 +
*Open Arduino serial monitor, and then open software Light Blue, you can find it has identified Microduino device.
 +
[[File:ble-Connection5.png|400px|center]]
 +
*Click Microduino to connect it with the Bluetooth. After connection, you can see the serial monitor prints Connected. ANd at the same time, the Bluetooth indicator lamp twinkles slightly(the frequency grows quick, and the brightness becomes low).
 +
[[File:ble-Connection6.png|400px|center]]
 +
*Choose accoding to the following picture, and then send message to the BT module, for example: mCookie.
 +
[[File:ble-Connection7.png|800px|center]]
 +
*You can see the serial monitor prints out mCookie.
 +
[[File:ble-Connection8.png|400px|center]]
 +
===Communication with windows===
 +
No password is needed when connecting to the Bluetooth by default, however, if it automatically popup that pairing is needed, the default password is: 000000. If it can't be connected, you need to set the connection needing password in AT command.
 +
*Refer to the following document"Use AT to check or change the parameters of BT".
 +
[[File:ble-Connection9.jpg|600px|center]]
 +
*Open the serial monitor and input "AT+TYPE1" to set the connection needing password. Note to set:"\r\n", "9600baud". If the setting is successful, it will return:"OK+Set:1","Hello World Peripheral".
 +
[[File:ble-Connection10.jpg|300px|center]]
 +
*Then use the computer to connect, and it automatically popup pairing, input: 000000.
 +
[[File:ble-Connection11.jpg|200px|center]]
  
 
==Extension==
 
==Extension==
Line 178: Line 170:
 
**Stack mCookie-BT and mCookie-CoreUSB, plug USB cable to mCookie-CoreUSB on one side and connect to your computer on the other side;  
 
**Stack mCookie-BT and mCookie-CoreUSB, plug USB cable to mCookie-CoreUSB on one side and connect to your computer on the other side;  
 
**Start Arduino IDE, copy program to IDE;   
 
**Start Arduino IDE, copy program to IDE;   
**Choose Microduino CoreUSB from (toools)-> (Board) and select the right serial number from (tools)-> (Serial;  
+
**Choose Microduino CoreUSB from (tools)-> (Board) and select the right serial number from (tools)-> (Serial;  
 
**Click compile button (√) on the top left of IDE and start compiling. After that, click download (->) and burn the program to board;  
 
**Click compile button (√) on the top left of IDE and start compiling. After that, click download (->) and burn the program to board;  
 
*Open serial monitor and set it to: "\r\n " "9600baud "
 
*Open serial monitor and set it to: "\r\n " "9600baud "
Line 219: Line 211:
 
'''Related Projects:'''
 
'''Related Projects:'''
 
[[Bluetooth Light]]
 
[[Bluetooth Light]]
[[Bluetooth Night Lamp]]
+
[[Bluetooth Night Light]]
  
 
+
==FAQ==
==FQA==
+
*If it can't make a pair with win7  
*This module can’t make pair with win7?
+
**You can check the win7 computer to see if it supports BT 4.0 protocol or not. The BT module can only be used in the 4.0 protocol and the default pairing password is 000000.
**Check the BT version in win7, this module only support BLE 4.0 version and default password is 000000.
+
*If you find the module can't be reset normally and can only be reset by power-on 
*Does this module can reset by button?
+
**You can reset by sending AT instruction " AT+RESTART\r\n " via the serial port.
**No, it can be reset by power down.
+
*If it can't make a pair with iPhone or Android phones 
*This module can’t make pair with iphone and Android phone?
+
**The BT module only supports 4.0 BT protocol.
**This issue mostly is caused by the BT version. This module only supports BT4.0 protocol.
 
 
**For Andriod OS: 4.3 release
 
**For Andriod OS: 4.3 release
**For IOS: iPhone4s upper, iPod touch 5 upper, iPad 3 upper and iPad mini upper
+
**For IOS: iPhone4s and higher, iPod touch 5 and higher, iPad 3 and higher or iPad mini and higher.
 
 
  
 
==Pictures==
 
==Pictures==

Latest revision as of 03:29, 4 August 2017

Language: English  • 中文
mCookie-BT

mCookie-BT is a Bluetooth low-consumption(BLE) serial transmission module, which can communicate with other Bluetooth devices after connection, such as phone, and iPad with the help of the relative APP.


Features

  • Low power consumption.
  • Support iBeacons mode.
  • Small, cheap, stackable and open.

Specification

  • Way of Communication: Serial port transmission and the default serial port is D0(RX), D1(TX);
  • Power supply: +3.3VDC 50mA;
  • Status indicator:
    • Before Bluetooth connection
      • Host machine indicator keeps on for 100ms every second when not recording slave machine address; Host machine indicator keeps on for 900ms every second when recording slave machine address;
      • Slave machine indicator keeps on for one second every two seconds.
    • After connection:
      • The indicator of both the host and the slave machine keeps on for 100ms every five seconds(twinkle to save power).
  • During the transmission, each data package should include less than 120 bytes. The higher the baud rate is, the longer transmission interval is. There exists loss rate during Bluetooth data transmission. So users should be ready for re-transmission or data check.
  • All AT instructions end with "\r\n " so you should choose "\r\n " while debugging under AT instructions. Most AT instructions work before connection and all data pass through after connection.
  • iBeacon has been integrated. Set by AT instruction "AT+MODE2\r\n" can be achieved only under slave machine.
    • Work mode: 0(transmission), 1(Direct drive) and 2(iBeacon);
    • iBeacon can be tested by Local iBeacons offered on App Store freely, and it currently displays the distance. For the usage method, please refer to:
Ble-11rule.jpg

Document

Support AT instruction configuration/control: File:Microduino-BLE.pdf

Development

Serial Communication Requirements

  • Default serial port configuration is:
    • Baud rate:9600
    • No check
    • data bit: 8
    • Stop bit: 1
    • Set as:" \r\n " "9600baud "
Serial-mcookie.jpg

Communicate with other BT devices via CoreUSB

  • Program
//Use soft SoftwareSerial
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5);

//#define my_Serial mySerial
#define my_Serial Serial1 //Define serial communication as Serial1 
String msg = ""; //Define a string of characters 

void setup()
{
  // Initialize Bluetooth communication baud rate  
  my_Serial.begin(9600);
  // Initialize serial monitor communication baud rate 
  Serial.begin(9600);
}
void loop()
{
  //Receives signal once and give feedback once to the other communication side. 
  if (my_Serial.available() > 0)  //If there is data input in serial port 
  {
    msg = my_Serial.readStringUntil('\n'); //All content before acquiring line break
    Serial.println(msg);                   //Display character string of msg in the serial monitor  
    my_Serial.println("bluetooth respond");  //Send data to the other side of Bluetooth communication 
  }
}

Communicate with Android Device

  • Only version 4.3 or higher phone can communicate with mCookie-BT module
  • Download Android communication software and install it on the phone.
Ble-serial.gif

Step 1: Download program to mCoookie;

Download

Step 2: Start to set Android device, open the Bluetooth function, the App and the serial monitor on the computer IDE.

Step 3: Click SCAN button on the top right of the App, which is for searching Bluetooth devices nearby. Click the corresponding Microduino Bluetooth device to enter the interface, wait for 2-3 seconds until you see "Serial Ready" on the top right of the screen, meaning the phone has been connected with the Bluetooth.

App—App

The phone sends characters to mCookie, which will be displayed on the serial monitor while at the same time, the phone will also receive "^_^ Hello,mCookie!" from mCookie, which can verify the bidirectional communication function of Bluetooth.

App—Serial monitor1
App—App1

Communicate with IOS Device

  • iPhone4s or higher, iPod touch 5 or higher, iPad 3 or higher and iPad mini or higher;
  • Come to App Store and download LightBlue
LightBlue

Step 1: Download program to mCookie;

Step 2: Install "LightBlue", open the software and start to set IOS device. And then open IOS device's Bluetooth function and open serial monitor on the computer's IDE side.

LightBlue on ble.jpg

Step 3: Open LightBlue: Enter Bluetooth device searching interface, find Microduino Bluetooth device from "Peripherals Nearby", Click this item and make its connection your phone.

Connection1

Enter the following interface after connection:

Connection2

Step 4: Select and click "Characteristic6" and see encoding format on the top right of the screen. (The default is Hex 16 band encoding.) Click Hex button if you need to display character strings and choose UTF-8 encoding format, click "Listen for notifications" and let your phone enter monitoring state.

Ble-Connection5.jpg

Step 5: Click " Write new value " and pop up text editing interface

Ble-Connection2.jpg

Enter a character string combined by English characters and numbers and check result from the phone and the serial port.

Ble-Connection3.jpg
Ble-Connection4.jpg

You can see from the picture that the serial port receives phone data "12345" and the phone side also gets return data " bluetooth respond " from Bluetooth, meaning the bidirectional Bluetooth communication is smooth.

Communication with MAC

The Bluetooth of MAC cannot be connected with the research of the BT directly, and Light Blue is needed to develop, download.

  • Connect the mCookie-CoreUSB and module BT to the computer, and download the same code.
  • Open Arduino serial monitor, and then open software Light Blue, you can find it has identified Microduino device.
Ble-Connection5.png
  • Click Microduino to connect it with the Bluetooth. After connection, you can see the serial monitor prints Connected. ANd at the same time, the Bluetooth indicator lamp twinkles slightly(the frequency grows quick, and the brightness becomes low).
Ble-Connection6.png
  • Choose accoding to the following picture, and then send message to the BT module, for example: mCookie.
Ble-Connection7.png
  • You can see the serial monitor prints out mCookie.
Ble-Connection8.png

Communication with windows

No password is needed when connecting to the Bluetooth by default, however, if it automatically popup that pairing is needed, the default password is: 000000. If it can't be connected, you need to set the connection needing password in AT command.

  • Refer to the following document"Use AT to check or change the parameters of BT".
  • Open the serial monitor and input "AT+TYPE1" to set the connection needing password. Note to set:"\r\n", "9600baud". If the setting is successful, it will return:"OK+Set:1","Hello World Peripheral".
  • Then use the computer to connect, and it automatically popup pairing, input: 000000.

Extension

Use AT to Check or Change BT Parameters

  • AT instruction configuration/control document:

File:Microduino-BLE.pdf

  • Program
//Use other soft serial port " SoftwareSerial"   
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // RX, TX

//#define my_Serial mySerial
#define my_Serial Serial1 //Define serial ports of CoreUSB and BT  

void setup()
{
  Serial.begin(9600);//Serial monitor communication & Baud rate
  my_Serial.begin(9600);//BT communication baud rate 
}

void loop()
{
  if (Serial.available())//Monitor data from serial monitor 
    my_Serial.write(Serial.read());//Wrote data into BT  
  if (my_Serial.available())//Monitor serial data of BT
    Serial.write(my_Serial.read());//Print data in the serial monitor 
}
  • Download program
    • Stack mCookie-BT and mCookie-CoreUSB, plug USB cable to mCookie-CoreUSB on one side and connect to your computer on the other side;
    • Start Arduino IDE, copy program to IDE;
    • Choose Microduino CoreUSB from (tools)-> (Board) and select the right serial number from (tools)-> (Serial;
    • Click compile button (√) on the top left of IDE and start compiling. After that, click download (->) and burn the program to board;
  • Open serial monitor and set it to: "\r\n " "9600baud "
Serial
  • Enter fixed instructions in the serial monitor and you'll return result. (This reference file can change BT's parameters. )
AT

Change Serial Communication Pin

The default serial is D0(RX), D1(TX). Users can change serial port according to personal needs, which can refer to:

Ble-Serial-change.jpg

Use soft communication program:

//Use other soft serial "SoftwareSerial"  
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5);//Select the corresponding port numbers--(2,3) or (4,5) according to the serial ports.

#define my_Serial mySerial

String msg = "";

void setup()
{
  // Initialize Bluetooth communication baud rate 
  my_Serial.begin(9600);
  // Initialize serial monitor communication baud rate  
  Serial.begin(9600);
}
void loop()
{
  //Receive signal once and then give feedback to the other side of the communication.
  if (my_Serial.available() > 0)  //If serial port has data input 
  {
    msg = my_Serial.readStringUntil('\n'); //Acquire all content before line break  
    Serial.println(msg);                   //Receive character strings of msg in the serial monitor  
    my_Serial.println("bluetooth respond");  //Sending data to the other side of the Bluetooth communication 
  }
}

Project

Related Projects: Bluetooth Light Bluetooth Night Light

FAQ

  • If it can't make a pair with win7
    • You can check the win7 computer to see if it supports BT 4.0 protocol or not. The BT module can only be used in the 4.0 protocol and the default pairing password is 000000.
  • If you find the module can't be reset normally and can only be reset by power-on
    • You can reset by sending AT instruction " AT+RESTART\r\n " via the serial port.
  • If it can't make a pair with iPhone or Android phones
    • The BT module only supports 4.0 BT protocol.
    • For Andriod OS: 4.3 release
    • For IOS: iPhone4s and higher, iPod touch 5 and higher, iPad 3 and higher or iPad mini and higher.

Pictures

MCookie-BT-t1.jpg
MCookie-BT-b1.jpg
mCookie-BT Front
mCookie-BT Back