Tutorial: Bluetooth
Bluetooth (HC-06)

Procedure
1. Connect the bluetooth module(HC-06) and the MCU.
For using USART1, select PA9(TX) and PA10(RX).
BT(TX) - PA10(RX)
BT(RX)- PA9(TX)

2. Search and add the bluetooth named "HC-06(n)". (n = 01, 02, ... )

3. Enter the password "1234".

4. If it's connected normally, you can connect the serial port with Teraterm.

Sample Code
Assumes you have
ecUART2.h
#include "ecSTM32F4v2.h"
// this should include #include "ecUART2.h"
//#include "ecUART2.h"
static volatile uint8_t PC_Data = 0;
static volatile uint8_t BT_Data = 0;
uint8_t PC_string[]="Hi_BT\r\n";
void setup(void){
RCC_PLL_init();
SysTick_init();
// USART1: BT serial init
UART1_init();
UART1_baud(BAUD_9600);
}
int main(void){
setup();
//printf("MCU Initialized\r\n");
while(1){
// USART Receive: Use Interrupt only
// USART Transmit: Interrupt or Polling
USART1_write(PC_string, 7);
delay_ms(2000);
}
}
Last updated
Was this helpful?