MSP430 Voice Control Over Bluetooth HC06 module and Launchpad

MSP430 Voice Control Over Bluetooth

In this tutorial I will demonstrate a MSP430 voice control over Bluetooth, using a HC06 Bluetooth module.  I will be using an Android App I programmed which can be downloaded and installed, the C code for the MSP430 is also downloadable at the end of the tutorial.

**Update 18/01/2015 the Android App has been updated and now includes 23 generic commands

So before we look at everything in further detail, the video below gives a demonstration of what the simple App and basic hardware set/up can do.  Note it was filmed with an older phone, so excuse the quality and dodgy camera angles.

HC06 Bluetooth Module

This is my first foray into bluetooth, I will be looking at Bluetooth 4 (aka BLE) soon, but for now lets take a look at the HC06 bluetooth module.

MSP430 Voice Control Over Bluetooth HC06 module

The image above shows the HC06, the module is shown already soldered to a blue PCB and a connecting wire.  I purchased the whole assembly for under £3.50 including postage and packaging from Ebay.  You can also buy the module on it’s own for even cheaper, but you then need to mount it on a suitable PCB, as well as taking into account a few configuration considerations.  If you want to keep things simple then I recommend buying the same assembly as used in this tutorial.    An alternatively option if you looking for a neater Boosterpack design, is to source some parts from the 43oh website store, they sell the modules and Boosterpack PCB.  So lets look at a few specifications for the module, I have just listed the ones that are pertinent, bear in mind any module you buy may differ slightly.

  • Bluetooth protocal: Bluetooth Specification v2.0+EDR
  • Frequency: 2.4GHz ISM band
  • Emission power: ≤4dBm, Class 2 (~10 meter range)
  • Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
  • Power supply: +3.3VDC 50mA (3.6V ~ 6V on-board regulator input)

The HC06 kits has six external connections, only four have header pins connected these are VCC, GND, TXD and RXD (Wakeup and State are not connected).  The TXD and RXD form the transmit and receive for a serial connection, these will be connected to the Universal Asynchronous Receiver/Transmitter (UART) on the MSP430G2553.

Hardware Set-Up

For this tutorial I kept it very simple, the demonstration uses the Launchpads on-board LED’s. The VCC and GND pins from the bluetooth module are connected to the launchpads VCC and GND pins.  TXD from the module is connected to P1.1 on the launchpad, this is the UART receive, and RXD from the module is connected to P1.2 on the launchpad, this is the UART transmit.  The image below should clarify the connections, as it shows the colour coded wire clearly.

MSP430 Voice Control Over Bluetooth HC06 module connected to Launchpad

Thats all there is to it for the hardware set-up, there was no need to add any further electronics as the potential control applications will become evident.


I was originally just playing around with the UART, and had intended to write a tutorial on this but remembered I had brought the HC06 module, so decided to dig it out.  Before I connected the module I had already tested the UART using a free terminal program called Putty running on Windows.  The MSP430 UART example programs are enough to learn the basics and get you started, the code I used is based on one of the examples.  After having great success with the initial UART tests, I then connected the bluetooth module.  To test the module I needed a similar program to Putty but running on Android, you will find dozens of terminal programs for Android just by searching the Play Store.

After some initial tests this worked fine and I had an LED switching on and off via bluetooth, all for about one hour of playing around.  It was at this point I thought wouldn’t it be cool to have voice control, my Nexus 5 supports ‘Ok Google’ for voice activation and that gave me the idea. Now I have to stress my App doe’s not support ‘Ok Google’  this is the first iteration, in fact you have to hit a button first and then speak the command.  I will write more about the Android App, but first lets go through the MSP430G2553 code.

MSP430G2553 Code

I am only going to run through the code quickly, as it can be downloaded below so will just walk through the main parts.

	/*** Set-up system clocks ***/
	if (CALBC1_1MHZ == 0xFF)
			           while (1);
	DCOCTL = 0;

The first block of code deals with the watchdog and clock set/up, this also ensures the clock is calibrated, the accuracy is required for the UART operation although there is still a small margin of error due to the internal oscillator tolerance.

	/*** Set-up GPIO ***/
	P1SEL = BIT1 + BIT2;
	P1SEL2 = BIT1 + BIT2;
	P1DIR |= BIT6 + BIT0;
	P1OUT &= ~(BIT6 + BIT0);

The GPIO’s are set-up next in lines 2 and 3, P1.1 and P1.2 are used for the UART.  In order to configure these both the GPIO function select registers need to be set to 1, this configures the pins to function with the secondary peripheral module.  If you are not familir with some of the GPIO or registry configuration commands, I would recommend you take a look at my two part MSP430 Programming Tutorial Part/1 and Part/2.  Lines 4 and 5 are used to configure P1.0 and P1.6, these are connected to the on-board LED’s, and are purely used here as a simple demonstration.

	/*** Set-up USCI A ***/
	UCA0BR0 = 104;
	UCA0BR1 = 0;
	__bis_SR_register(LPM0_bits + GIE);

The next block of code is used to configure the Universal Serial Communication Interface (USCI), this supports multiple serial communication modes.  The MSP430G2553 has two USCI modules, USCI_A and USCI_B, USCI_A is used here in UART mode.

Starting with line 2 this configures USCI_A0 control register 1 and sets the clock source as the SMCLK.  Line 3 configures the USCI_A0 baud rate control register 0, using a value of 104.  The SMCLK is running at 1MHz, therefore 1MHz divided by 104 = 9615.4, which is almost 9600 baud. Line 4 configures the USCI_A0 baud rate control register 1, this is used for clock prescaler settings more information can be found in the family guide with relation to this.  Line 5 configures the USCI_A0 modulation control register, this parameter determines the modulation pattern, in short terms this allows extra adjustment depending on the divided clock frequency and desired baud rate.  Therefore providing a mechanism to achieve the most accurate result, with as little deviation from the desired baud rate.  Line 6 configures the USCI_A0 control register 1, this time it performs a software reset which initialises the USCI state machine.  Line 7 enables the interrupt on the USCI_A0 receive buffer.  Line 8 enables low power mode 0 which turns the CPU off and interrupts.

So now that the USCI_A is configured the processor will switch off until data is received, then when the receive buffer has a new byte of information an interrupt will be called.

	Rx_Data = UCA0RXBUF;

The code snippet above is inside the interrupt handler for the USCI_A receive buffer.  Line 1 assigns the data inside the buffer to the variable Rx_Data, line 2 is used to wake up the CPU.

		switch (Rx_Data)
			case 0x41:
				TA0CCTL0 &= ~CCIE;
				P1SEL &= ~BIT6;
				P1OUT |= BIT6 + BIT0;

			case 0x42:
				TA0CCTL0 &= ~CCIE;
				P1SEL &= ~BIT6;
				P1OUT &= ~(BIT6 + BIT0);

The variable Rx_Data is then used in a switch case statement to determine what has been sent over bluetooth.  The App on the phone can be programmed to send a string, but this first iterations simply converts a string into a single ASCII value, which is then sent over bluetooth. In the case of the code running on the MSP430, it is using the switch case to determine the ASCII value represented by a hexadecimal number.  The ASCII value sent and shown in line 3 is 0x41 which is a capital A, and line 4 is 0x42 which is a capital B.  So when you say the word ‘On’ the phone App translates this and sends a capital A to the HC06 bluetooth module, when you say the word ‘Off’ a capital B is sent.  There are other commands and I can and will add more, the full list currently supported is further down the tutorial.

The rest of the code shown is purely for demonstration, basically line 4 and 11 are used to disable a timer interrupt.  The timer interrupt requires disabling as the flash demo is not used if the on or off commands have been given.  Line 5 and 12 are used to change the function of pin P1.6 to a GPIO function.  Line 6 is used to turn the on-board launchpad LED’s on, and line 13 is used to turn the on-board launchpad LED’s off.

Android Voice App

I am not an Android App developer so this was put together quite quickly, literally six or so hours.  I have been testing it with the launchpad and it performs well, there were a few early teething problems but now it seems pretty solid in operation.  The App can currently only be downloaded here, I was going to upload to the Play Store but Google wanted 25$ for the privilege.  So I decided not to upload at this stage, as it may not be of any use to anyone other than me…time will tell!

I am not running through how to code the App here, just showing some screen shots of the operation with some notes, as the video should really cover this.  I have only tested this on my Google Nexus 5, so unsure if the layout will change on other phones.  If I have left any areas unclear or you have issues, leave a comment at the end of the article and I will answer as soon as I can.

Before running the App you need to enable your Bluetooth, wasn’t sure how to do this and it does not prompt you to enable it yet.

MSP430 Voice Control Over Bluetooth HC06 module Android App Not ConnectedOk the first screen capture shows the Apps main and only window, you will notice the big red text that says ‘Not Connected’ .  To connect a bluetooth device tap the blue box with the text ‘Choose BT Device’

MSP430 Voice Control Over Bluetooth HC06 module Android App Bluetooth SelectionYou will then be taken to a screen with a list of bluetooth devices, as you can see I have the HC06 device listed.  To select the device just tap on the listed device.  The HC06 module has a small LED on the board, this flashes when not connected, becoming solid once the device is connected.  If its your first time connecting you will need to pair the devices, the most common password used for the HC06 seems to be ‘1234’.

MSP430 Voice Control Over Bluetooth HC06 module Android App ConnectedAfter a few seconds the screen will return to the main window, and you should notice the red text has now changed green and reads ‘Connected’.  You will notice directly below this text is more black text which says ‘Captured Speech = ?’, this indicates no speech has been captured. By pressing the orange button which says ‘Press Then Give Voice Command’, you will enter the speech capture mode.

MSP430 Voice Control Over Bluetooth HC06 module Android App Capture ModeThe capture mode is just Google’s Speech to Text, this as the name suggests will convert your speech to text.

MSP430 Voice Control Over Bluetooth HC06 module Android App Unaccepted Code WordThe next screen shot demonstrates the captured speech being displayed, this is not a recognised command word shown, it could be in future though.  I have left all words displayed as if Google’s application has misidentified your speech, it’s better to know where the error lies. I guess I could have the recognised word change green for a valid command and red for an invalid one, so will maybe implement that at a future date.  You can disconnect the bluetooth device any time by pressing the red button labelled ‘Disconnect BT’.

A few of the commands supported are as follows:

  • on‘ command then generates a capital A and sends over bluetooth or hex 0x41
  • off‘ command then generates a capital B and sends over bluetooth or hex 0x42
  • flash‘ command then generates a capital C and sends over bluetooth or hex 0x43
  • 1‘ command then generates the number 1 and sends over bluetooth or hex 0x31
  • 2‘ command then generates the number 2 and sends over bluetooth or hex 0x32
  • 3‘ command then generates the number and sends over bluetooth or hex 0x33
  • 4‘ command then generates the number 4 and sends over bluetooth or hex 0x34
  • 5‘ command then generates the number 5 and sends over bluetooth or hex 0x35

I will probably add forward, backward, left, right and a few other obvious command words.

MSP430G2553 C Code

The link below contains the zip file with the full example C code, there is a small advert page first via Adfly, which can be skipped and just takes a few seconds, but helps me to pay towards the hosting of the website.

MSP430 Voice Control Over Bluetooth MSP430G2553 C Code

I take great care when writing all the tutorials and articles, ensuring all the code is fully tested to avoid issues for my readers.  All this takes time and a great deal of work, so please support the site by using the Adfly links etc.  If you have found this useful or have any problems implementing, please feel free to leave a comment and I will do my best to help.

Android App BT_Voice_MCU.apk

**Update 18/01/2015 the Android App has been updated and now includes some additional commands, for a full list see this Excel file, the link below has also been updated.

The link below contains the zip file with the full Android App.apk file.  I guess I need to put some sort of disclaimer here as this is a phone App, and untested on any other phone except my Nexus 5, but it appears 100% stable and has not caused any issues.  If you download and use this App, I am not responsible for any issues you may encounter so you do so at your own risk.

MSP430 Voice Control Over Bluetooth BT_Voice_MCU Android App

*Original* MSP430 Voice Control Over Bluetooth BT_Voice_MCU Android App

47 thoughts on “MSP430 Voice Control Over Bluetooth”

  1. I am not able to any of the download link.
    It is showing Web page blocked while using college campus wifi and “You are not authorized to access this web page as per the dot compliance ” while using mobile net.
    Is there any other way by which i can access the app and C code download link ?

    1. Hi Mahima,

      Sorry for not replying sooner currently traveling for an extended period. If you have adblocking enabled this will prevent you from downloading, as the links are via Adfly.

      Alternatively if you can provide an email address via the contact form on the website I can email the files directly to you.


  2. Hi,

    Thanks a lot for your sharing. I try your code on IAR Embedded Workbench+TI MSP430G2553+HC05(ZS-040). But it “failed to reinitialized, session aborted” when I download and debbug. What do you think the problem might be?
    Your assistance is greatly appreciated!


    1. Hi,

      The code was written using Code Composer Studio so it’s possible there maybe some includes missing, as line 14 in the code is #include msp430g2253.h which may not point to the correct header file name for the microcontroller in IAR. Otherwise the C code should work as the interrupt handler is written with an OR statement and defined for IAR systems.

      One way to solve this maybe to open an MSP430G example which is included with IAR and ideally has an interrupt being used, then copy and paste the code you need over, this way it will have the correct includes and interrupt handler.



      1. Hi,

        Thanks a lot for your advice. I’ve changed line 14 into
        #include “io430.h”
        #include “in430.h”
        and then it works on my IAR 🙂
        But when I successfully connected the bluetooth and press the orange button ” press then give voice command”, a “Runtime Error” appeared, saying that “No Activity found to handle Intent {act=android.speech.action.RECOGNIZE_SPEECH(has extras)}”
        I wonder if it’s still the code compatible problem.


        1. Hi,
          The runtime error you have is on the Android phone, so changing the IDE will not make a difference ad the MSP430 code should be fine.
          Check you have an internet connection when using the App as this is required and also check you have any Google speech recognition related software updated and activated in Android.

          Failing that it’s possible my Android code needs updating as been a few years since I wrote the code, currently don’t have time and will get back to this at some point as want to play around with Google Assistant.


  3. Hi,

    From the android app, before sending out the command like letter ‘A’,
    do you need to format the data before sending out in order to be received by bluesmirf?


    1. Hi,

      I am not 100% sure what the data stream over BT looks like, but the HC06 BT module formats into standard asynchronous signal that UART on the MSP430 receives.


      1. hey I was wondering if I could send data from the microcontroller to the phone app, so instead of turning on led1 in the micro if I send A to the phone it does something…..

  4. I wanted to test how this interesting project works, but I could not get my hands on it. Since the link which you have given does not open.

    1. Hi,

      If you have any kind of adblocker then the download links won’t work, as I use Adfly to generate a tiny income that goes towards the hosting of the site.

      All the download links are working and tested original with Chrome and Firefox.

  5. Hey so the text in the app reads “Commands currently supported are only ‘On’ and ‘Off’. visit the website for more information about the project. More commands to be added soon.

    On and off do work, but flash doesnt. This is the apk i downloaded from the end of the website from It was modified 12/22/14. Thanks for you quick reply

    1. Hi,

      I checked the link and its definitely the latest version, I have emailed you the old and new version as well.


  6. Hey Ant, so i tried running your code on my phone. And the phone app is different from the one shown in your picture. The phone app only supports on and off, and none of hte other commands.

    1. Hi Ja,

      The phone app was tweaked slightly to have more functionality as per some user requests, I added a excel sheet to show the new commands and made a few minor layout tweaks. I haven’t modified it since then so it should be working, there have also been a few hundred downloads but no other user issues.

  7. Thanks for your post. Have you managed to find a good, easy to use BLE module to interface to the launchpad?

    1. Hi Alexandre,

      I have purchased a couple of HM-10 BLE modules, which are in the same format as the HC-06 etc. However not had a chance to test these, from what I understand they should be fairly straightforward to get working. For the more advanced features you will need to use AT commands to set them up though.

      Just do a search on for HM-10 and plenty of cheap options come up.


  8. Hello,
    thanks for sharing this project.
    I have got an error when i debug your code.I’m using msp430FR5739 launchpad.There some ports were different from your msp430.I think thats why your code is not supported to me.
    I have got errors but my software (CCS) is not locate the error location.Thats errors just only location shown.
    Please Help me.How can i fix my problem.

    1. Hi Sajith,

      The code is written for the MSP430G2553, this is probably why you have errors. It’s just a question of looking in the MSP430FR5739 datasheet and looking for the correct ports that the UART is on. Then change them as necessary and also check which port the FR5739 LED is attached to and correct as required.


      1. Thank You Ant.

        Yes.That is why I have got errors.But I’m not very familiar with msp430.So its hard to me change ports alone.
        I’m Still learning this matters.

        Do I need to replace registers that have in msp430FR5739.
        can You give an idea to resolve below errors.I have got that kind of errors.

        unresolved symbol BCSCTL1, first referenced in ./main.obj

        unresolved symbol UCA0BR1, first referenced in ./main.obj

        unresolved symbol UCA0CTL1, first referenced in ./main.obj

        unresolved symbol UCA0MCTL, first referenced in ./main.obj

        1. Hi,

          Its not easy when your first introduced to the MSP430 especially if you are new to microcontrollers, the family guide is very useful and the datasheet for the individual microcontroller you are using. The errors you are are linked to the clock and the UART. I am pretty sure the MSP430FR5739 runs on a faster clock, how the clock is set-up and divided will determine the baud rate. Also the pins on the FR5739 will have a different mapping layout to the MSP430G2553.

          I have not used the FR5739 so don’t have a datasheet to hand, you can download a datasheet from TI, I am also quite sure there is a UART example code in CCS for the FR5759, this would be a good starting point to resolving the issue.


    1. Hi,

      Sorry I am working on this currently and intend to release a new version, but don’t intend to release the source code.


  9. Hello Ant,

    I really found your app and code useful. I am using a ‘G2553 and an HC06, and I would like to connect a 16×2 LCD to mine so I can send a sentence to the display via bluetooth (that and maybe an LED array to put in the back dash of my car to send messages to other drivers). Think maybe we can collaborate on the bluetooth app? I have not developed any android apps yet, but I’m getting started.

    Also, what are you paying for hosting? I might be able to assist you with that. Email me.



    1. Hey Nuetron,

      Glad you found it useful I tried to make it as user friendly as possible. At the minute I have not had time to carry on with any Android development, due to my current course and work commitments. I manage to scrap enough together to cover the site costs from adverts etc, so no worries there. Will put more content up over the summer as have more time. I have your contact details so will drop you a line.


  10. Hi!

    I’m trying to learn about bluetooth data transfer with MSP430g2553 but I’m using another bluetooth module. Can you explain which part of your C code is essential for HC-06 and how would it be possible to use this with another bluetooth module?

    Thanks in advance!

    1. Hi,

      The MSP430 code uses the UART I have not tested on any other Bluetooth devices, but quite confident the code will work with HC-05 devices. There are other Bluetooth 4 devices out there that may require some initial set-up before hand but should also use the UART as well.


  11. Hi, this is a great project! Are you thinking about adding in directional voice commands to the app? That would be fantastic!

    1. Hi John,

      It’s in the works! I should have an updated App soon, with dozens more commands just finding the time to finish it off. I will not update the MSP430 code, but have a list probably a spreadsheet with the new command and the Hex/ASCII value, then all you need to do is copy paste this into the MSP430 or other microcontroller code.


        1. Hi John, added some more commands now and just updated the tutorial. See the Excel file for the full list of generic commands.


  12. Hello,
    I am working on a project for my class which is similar to your project. I was wondering if there is anyway I could see your source code for the app. All credits would be given to you off course, I just need to add some more functions to it such as reading a temperature from a sensor and send the value back to the phone. I really have no clue how to do that yet but I am hoping to do it with some research.

    1. Hi,

      At the moment I am not willing to release it, sorry, I have further plans for the code and just not ready to release just yet. I am planning to have a receive function and display data in a future iteration, just juggling a few projects at the moment.

  13. It tried to get me to download an “Open Download Manager” both times. No biggie, as I ignore and cancel out of that crap all the time. Worth it to make sure you get some hosting offset money.

    1. Hi,

      It should just open up a window, which you can skip after 5 seconds. I don’t want it to put people off,it makes me about $0.0001 per click so might just remove it in future.

      Thanks for your support.


  14. My bad. It appears the files DID download after a while which I did not notice. Hope I supported your cause with the ad. Thanks for sharing the files. Now I can make use of the edX MSP430 class I took online a few months back. Cheers.

    1. Hi,

      No worries, Thanks every little helps and it’s much appreciated. I will add some more commands to the App soon so check back for updates, if you get any issues please provide feedback. I will try to release a new version with more functionality when I have time.

      Did you find the edX MSP430 course useful?


  15. Great project. Is there any way to get your files WITHOUT downloading the download manager software (what I’ll call crapware)???

    1. Hi,
      I downloaded fthe apk from the website but only ‘on’ and ‘off’ commands worked. I need to ‘flash’ command. Can you help me this issue?

      1. Hi,

        I have added the original App for download as well, if you get issues with this then maybe an Android update has caused an issue with both Apps. At the moment I don’t have time to look at them but will do sometime in the new year.


Leave a Reply