Bluetooth Communication between Mobile and MCU
7 June
Week15 Embedded Networking and Communications
This week I used a bluetooth module, HC-05, to connect the microcontroller to my mobile phone. The steps are as follows.

---HC-05---
The datasheet of the HC-05 told me the rational under the hood. Basically to setup a bluetooth connection, it should go through the process of initialization, pair-up, and data transformation through serial ports. All are done by AT Commands. For example, the command for device connection is AT+LINK= Bluetooth address of remote device>, the responsesa are either OK or FAIL.
---Connection---
I connected HC-05's DX pin to the TX pin of the microcontroller, and HC-05's TX to DX, VCC to VCC, and GND to GND.

My goal is to connect the microcontroller to the mobile phone so I have downloaded an app to test the bluetooth connection on my android phone first. Google play is not accessible in China from time to time therefore I have downloaded an Chinese app called BLE string test if translated literally.
I set the serial port to 9600 and asked it to send a message 'hello Pheobe' when it's connected to the mobile phone. And I added a delay after this action in a while command. Thus the microcontroller should repeat sending this message to the paired device from time to time.
After I've programmed the MCU, I opened the app. When the screen showed the message, I know the two has been connected.

I also tried it on another board with an LED and define the pin controlling the LED as OUTPUT. And I also defined the delay period to 500ms so that I can tell if the data has been transfered by the tempo the LED blinks.
Connect an Mobile App to Microcontroller through HC-05
This part has been added after week16 when I developed my first app to control the tea brewer. The rational would be the same as setting up connection between the HC-05 and the MCU. The difference is that the App Inventor I used to develope an App actually uses Java instead of C.
A video showing how an app I made in my final project connecting to the microcontroller through HC-05 can be found here: presentation.mp4
The code file can be found here: hello_bluetooth.c hello_bluetooth.make