DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Trending

  • Message Construction: Enhancing Enterprise Integration Patterns
  • Modular Software Architecture: Advantages and Disadvantages of Using Monolith, Microservices and Modular Monolith
  • Unleashing the Power of Microservices With Spring Cloud
  • How To Aim for High GC Throughput

Enabling Nucleo ST F401RE mbed Communication with HC-06 Bluetooth

STMicro announced an mbed enabled development board called the Nucleo. This Internet of Things tutorial shows how to enable the Nucleo with HC-06 Bluetooth.

Hema Chowdary user avatar by
Hema Chowdary
·
Jun. 06, 15 · Interview
Like (0)
Save
Tweet
Share
7.55K Views

Join the DZone community and get the full member experience.

Join For Free

ARM mbed is designed to provide highly productive Internet of Things solutions. There are numerous boards available in market with different configurations from different vendors. Some of the most popular boards are mbed LPC1768 from NXP, mbed LPC 11U24, Seeeduino-Arch etc.

STMicroelectronics (STMicro) has announced an mbed enabled development board named STM32 Nucleo. These Nucleo boards will allow developers to re-use hardware and software IP for multiple projects thereby making them more scalable. This will also bestows a wide variety of shields that supports functions such as Bluetooth Low Energy (BLE), Wi-Fi connectivity, GPS, proximity sensing etc. ST Nucleo F103RB, ST Nucleo L053R8, ST Nucleo F401RE and ST Nucleo F302R8 are some of the boards from STMicroelectronics.

By default the bluetooth communication is not enabled on the Nucleo ST F401RE board. This blog will walk you through the process to enable the communication between Bluetooth module HC-06 and Nucleo ST F401RE, an mbed enabled Nucleo board.

Firmware Upgradation:

As Nucleo boards are having some issue with the firmwares installed it is mandatory to have the latest firmware installed on the board. For smoother functioning of the board ensure that the board will have latest version of firmware installed on it. If not, follow the steps mentioned belo

  • Download and install the ST-Link drivers
  • To install ST-Link drivers :
    • Extract the Zip folder and run either dpinst_amd64.exe or dpinst_x86.exe depending on PC configuration     
    • Follow the prompts and finish the installation
  • Download latest version firmware  from here
  • To Verify the firmware upgradation:
    • Download latest firmware version from here
    • Run the STLinkUpgrade.exe program and press connect
    • Device details will be prompted if the ST-Link drivers were properly installed  and then press yes
    • This ensures firmware was upgraded successfully 

Bluetooth HC-06 and Nucleo ST F401RE:

Nucleo board has arduino supported header pins thereby allowing the board to use with other Arduino supported devices/modules. In mbed repository there was variety of libraries and programs that illustrates Bluetooth communication using different modules. There are no libraries for Bluetooth HC-06 module. Hence I explored on how to communicate Arduino Bluetooth HC-06 Slave module with Nucleo ST F401RE. These are the steps to be followed to establish communication between them:

Bluetooth HC-06 has 4 pins namely RXD, TXD, GND and VCC. Connect bluetooth module to nucleo board as follows:

Bluetooth HC-06

Nucleo ST F401RE

RXD

TX

TXD

RX

Remember, TX/Do and RX/D1 pins of Nucleo Arduino connectors are not enabled by default. In order to enable them, some of the solder bridge configurations (open/close of some pins) are required. Instead of using this procedure I feel comfortable in using the default receiver and transmitter pins of Nucleo board. D10 and D2 pins are configured by default. Here is how to operate an LED using Bluetooth from a mobile and PC terminal.

Connect HC-06 module to Arduino headers on Nucleo ST F401RE as shown in fig below

circuit connections


  • Connect Nucleo board to PC and ensure that Nucleo has detected as a drive
  • Go to online mbed controller and import any sample code and replace it with the below code.



    #include "mbed.h"
    Serial bt(D10,D2);
    Serial pc(USBTX,USBRX);
    DigitalOut myled(D13);
    
    int main() {
        bt.baud(9600);
    
        //prints data on mobile
        bt.printf("Connection Established");
    
        //print data on pc terminal
        pc.printf("Connection Established");
        while(1) {
    
            //For reading and writing data from/to bluetooth HC-06
            //check if bluetooth is readable and execute commands to toggle LED
            if (bt.readable()) {
               char input_key=  bt.putc(bt.getc());
    
                //tutn on LED if "y" is entered
                if(input_key == 'y') {
                    myled = 1;
                    bt.printf("LED is ON");
                }
    
                //tutn on LED if "n" is entered
                if(input_key == 'n') {
                    myled = 0;
                    bt.printf("LED is OFF");
                }
            }
    
            //For reading and writing data from/to pc terminal
            //check if pc is readable and execute commands  to toggle LED
            if (pc.readable()) {
                char input_key=  pc.putc(pc.getc());
                if(input_key == 'y') {
                    myled = 1;
                    pc.printf("LED is ON");
                }
                if(input_key == 'n') {
                    myled = 0;
                    pc.printf("LED is OFF");
                }
            }
        } 
    
    }
  • Compile the code and save it onto Nucleo board
  • Install Bluetooth SPP Manager app on android  mobile  and HTerm software on PC
  • Pair up and connect android mobile with Bluetooth HC-06
  • On HTerm give COM port number and baud rate as 9600 and click on connect
  • Start sending commands from mobile and Hterm to control LED

Thus the communication between bluetooth HC06 module and Nucleo board can be established using HTerm and Bluetooth SPP Manager.

Mbed

Opinions expressed by DZone contributors are their own.


Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: