MCookie-BT
Language | English |
---|
mCookie-BT is low-consumption serial transmission module, which can communicate with other Bluetooth devices such as phone and ipad.
Features
Specification
*** The indicator of both the host and the slave machine keeps on for 100ms every five seconds.
**After connection:
DocumentSupport AT instruction configuration/control: 文件:Microduino-BLE.pdf DevelopmentSerial Communication Requirements
Communicate with other BT devices via CoreUSB
//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
|
Step 1: Download program to mCoookie; |
Step 2: Start to set Android device. Open Bluetooth function of the device, copy and install ".apk " file from testing package to the phone, then open APP and open serial monitor on computer IDE side; Step 3: Click SCAN on top right of the APP and it'll show Bluetooth devices around you as follows: Click the corresponding Microduino Bluetooth number and enter the following interface: Wait for 2-3 seconds and see "Ready" on the screen, meaning a successful connection between the phone and the Bluetooth. Click " Sync RTC With Phone " and see changes of "RT TIME" above and the serial monitor. You'll see the phone receiving message " bluetooth respond " from mCookie and on the other side, the serial monitor also gets the time and content of the message. Thus, bidirectional communication function of Bluetooth can be verified. Communicate with IOS Device
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. 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. |
Enter the following interface after connection: 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. Step 5: Click " Write new value " and pop up text editing interface Enter a character string combined by English characters and numbers and check result from the phone and the serial port. 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. ExtensionUse AT to Check or Change BT Parameters
//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
}
Change Serial Communication PinThe default serial is D0(RX), D1(TX). Users can change serial port according to personal needs, which can refer to: 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
}
}
ProjectRelated Projects: Bluetooth Light Bluetooth Night Lamp
FQA
Pictures |