Introduction: STM32F103: Bluetooth Module HC05 / HC06(using Mbed.h)

Picture of STM32F103: Bluetooth Module HC05 / HC06(using Mbed.h)

In this Project, we will be interfacing Bluetooth Module (HC05 or HC06 both will work) with our Nucleo F103 Board. We will write a code which will send a incremented float value to our Smart Phone, every second.

Components required:

  1. Nucleo Board (STM32F103RB6) with a cable to connect to PC.
  2. Bluetooth Module (HC05 or HC06)
  3. 4x Male-Female Connecting Wires
  4. A Smart Phone for receiving values.

This Tutorial Consists of following steps:

  1. Setting Up Hardware
  2. Coding...
  3. Visualizing the ouput

[Image Source]

Step 1: Setting Up Hardware

Make Connections as stated below:

  1. Bluetooth Module Vcc -> Nucleo +5V
  2. Bluetooth Module GND -> Nucleo GND
  3. Bluetooth "<- Rx" -> Nucleo D8 (PA_9)
  4. Bluetooth "->Tx" ->Nucleo D2 (PA_10)

Step 2: Coding

Open up and Sign In to mbed Compiler . Click NEW. Make sure that NUCLEO-F103EB Platform is selected. From template, select Blinky LED Hello World. Enter Program Name and click OK. Now, open main.cpp file and remove all the code written there. and Paste in following Code:

#include "mbed.h"

//bluetooth module employs Serial Communication. Serial blutooth(PA_9, PA_10);//Tx, Rx

DigitalOut myled(LED1); //LED on your Nucleo Board DigitalIn btn1(PC_13); //Button on your Nucleo Board

int main() { float i = 1; //This will print Hello World onto your SmartPhone blutooth.printf("Hello World !\r\n"); while(1) { wait(1); blutooth.printf("This program runs since %f seconds.\r\n", i++); if(btn1) { myled=1; } else { myled=0; } } }

Compile and Download the .bin file to Nucleo Board.

Step 3: Visualizing the Output

In Order to Visualize the output, This time you will need a SmartPhone with a Bluetooth module.

Now, go to Apps Store (like Google Play Store on Android or Store in Windows). Search for "Bluetooth Terminal".

Now, from the list of Apps select an App with relatively good rating which claims to show data being received via Bluetooth. (For Android, I would prefer "Blue Term" application)

Now, open this application. If they ask for Bluetooth permission, give them. Go to Connect Device (or any option like this) and search for new devices. Now, with your HC05/HC06 connected with Nucleo Board and running, you must be able to see HC05/HC06 in that list. Select that. Enter "1234" as pin.

Now, you must be connected to your Bluetooth module and must be able to see the values being sent from Nucleo Board.

NOTE:

  1. If you are not receiving anything on SmartPhone, try pressing that BLACK RESET button on Nucleo Board.
  2. If you are not receiving anything on SmartPhone, Make sure that you application is connected to BT module.
  3. If you are not receiving anything on SmartPhone, try interchanging the Tx and Rx Pins

Comments

About This Instructable

4,934views

7favorites

License:

More by ARK4579:Getting Keil and STM32CubeMX readySTM32103: esp8266 NodeMCU ThingSpeak [using mbed.h]STM32F103: esp8266 nodeMCU Getting Started [using mbed.h]
Add instructable to: