Change the world

Control Software

The following example programs will demonstrate the principles of using the HC-06 Bluetooth module:  

These examples can then be used in conjunction with one of the following:

  1. serial port monitor application (such as Termite) on a PC.  The PC will connect using either a Bluetooth dongle or a built-in Bluetooth module in the PC and the user will then use the application to send the raw messages to the STM32F4 device via the HC-06.
  2. A Visual Basic (VB.NET) program running on a PC, also via either a Bluetooth dongle or built-in module
  3. A Basic4Android example on an Android device.  The program will then use the Android device's bluetooth module to establish communication with the STM32F4 device.

 


Basic4Android

This is the corresponding Basic4Android code for the above sample code.  It will create Android application(s) to connect serially to the the STM32F4 device via the Android device's built-in bluetooth module.

Download:

 


VB.NET

This is the corresponding VB.NET code for the above sample code.  It will create Visual Basic .NET application(s) to connect serially to the the STM32F4 device via a PC's built-in bluetooth module or usb bluetooth dongle.

Download:

 


How to use a USB Bluetooth dongle on a PC for the VB.NET examples

The following steps will guide you through the steps to succesfully create a SPP (Serial Port Profile) from a PC's USB Bluetooth dongle to the HC-06 Bluetooth module on the STM32F4 to use with the VB.NET examples:

  1. Plug the Bluetooth dongle into a USB port on the PC.
  2. Wait for all the drivers to be installed.  The drivers are usually generic and should automatically download and install from Microsoft.
  3. Sometimes a new COM port will be created after the Bluetooth dongle was installed and will appear as "Standard Serial over Bluetooth link (COM XX)".  This is NOT the COM port we are going to use.
  4. Make sure the STM32 device and HC-06 is powered up.
  5. The STM32 device with the HC-06 module now needs to be added as a device to the PC.  Click on Start -> Devices and Printers.
  6. Click Add a device
  7. Wait for the PC to detect your device.  If it doesn't detect your device, try removing the Bluetooth dongle from the PC briefly and plug it in again.  Go back to step 5 again.
  8. Select you device in the list and click Next.
  9. Wait for the PC to make a connection to the device.
  10. Click Enter the device's pairing code.
  11. Type "1234" (or whatever you changed the pin to) and click Next
  12. Click Close
  13. Still in the Add Device window, right click on your HC06 device and select Properties.
  14. Select the Services tab.
  15. Make sure that Serial Port (SPP) is selected.  If it isn't, selelect it now and a new COM port will be created.  This COM port (the one that appears next to the Serial Port (SPP) option) is the COM port to use in your example code.
  16. You can also use a Serial Port Monitor application, such as Termite, to connect to the STM32F4 device.

 


How to use a built-in Bluetooth module on a PC for the VB.NET examples

The following steps will guide you through the steps to succesfully create a SPP (Serial Port Profile) from a PC's built-in Bluetooth module to the HC-06 Bluetooth module on the STM32F4 to use with the VB.NET examples:

  1. Make sure the Bluetooth function is enabled on the PC.
  2. Sometimes a COM port for the Bluetooth module already exists and will appear as "Standard Serial over Bluetooth link (COM XX)".  This is NOT the COM port we are going to use.
  3. Make sure the STM32 device and HC-06 is powered up.
  4. The STM32 device with the HC-06 module now needs to be added as a device to the PC.  Click on Start -> Devices and Printers.
  5. Click Add a device
  6. Wait for the PC to detect your device. 
  7. Select you device in the list and click Next.
  8. Wait for the PC to make a connection to the device.
  9. Click Enter the device's pairing code.
  10. Type "1234" (or whatever you changed the pin to) and click Next
  11. Click Close
  12. Still in the Add Device window, right click on your HC06 device and select Properties.
  13. Select the Services tab.
  14. Make sure that Serial Port (SPP) is selected.  If it isn't, selelect it now and a new COM port will be created.  This COM port (the one that appears next to the Serial Port (SPP) option) is the COM port to use in your example code.
  15. You can also use a Serial Port Monitor application, such as Termite, to connect to the STM32F4 device.