Multiwii Bluetooth – Change Baud Rate with Arduino

One great thing about Multiwii is, you can connect it to your computer, or Android phone/tablet via Bluetooth! It means you can adjust PID and other settings via the wireless Bluetooth connection, and there is no USB connection required. However the Bluetooth module might require some change of default settings (baud rate) beforehand.

I have an Arduino bluetooth transceiver module lying around, so I decided to give it a try. It connected successfully, but the Android app prompted there is no data received. I realized the Serial connection baud rate of Multiwii by default is 115200, but the default baud rate of the Bluetooth module is at 9600. That means I would have to change the default baud rate on the BT module for it to work.

A couple of ways to do this, first way is using a ISP programmer to connect the BT module and use Hyperterminal on Windows to send AT commands. Second way is to use Arduino as the programmer, and its serial monitor to send AT commands.

I prefer the second way (using Arduino), because I don’t have an ISP programmer, so here I will describe how I did it.

Connecting Arduino with Bluetooth Module

arduino-bluetooth-change-baud-rate-connection

WIRING

  • BT Module GND — Arduino GND Pin
  • BT Module VCC (5V) — Arduino 5V
  • BT Module TX — Arduino Pin 10 (soft RX)
  • BT Module RX — Arduino Pin11 (soft TX)
  • BT Module Key (PIN 34) — Arduino Pin 9

 

arduino-bluetooth-change-baud-rate

Arduino Code

This Arduino code takes the AT commands from Serial Monitor and sends those commands to the BT module, then reads the output of the BT module and displays it on the Serial Monitor.

The Arduino communicates with the BT module using the SoftwareSerial ports while the Arduino communicates with the user via the Serial Monitor.

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup(){
  pinMode(9, OUTPUT);  // this pin will pull the BT Module pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(9600);  // your own BT Module default speed in AT command more
}

void loop(){

  // Keep reading from BT Module and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to BT Module
  if (Serial.available())
    BTSerial.write(Serial.read());
}

After connected the components and uploaded the code, it’s time to test it. You can do a ping test by entering AT in the serial monitor. If communication is successful the BT module would return “OK”.

Changing Bluetooth Default Baud Rate

If we have passed the ping test above, we can now attempt to change the baud rate of the BT module.

The bluetooth module baud rates are set by an hexadecimal index from ‘1’ to ‘C’.
Indexes are: 1:1200, 2:2400, 3:4800, 4:9600, 5:19200, 6:38400, 7:57600, 8:115200, 9:230400, A:460800, B:921600, C:1382400

To set a default baud rate, enter this command

AT+BAUD<index>

For example for multiwii, we need 115200 as the BT baud rate, we would enter AT+BAUD8.

If successful you should be returned “OK” in the serial monitor.

More AT Command for HC06 (Linvor 1.5)

Set Bluetooth Device Name

Send: AT+NAME
Response: OK

Set Bluetooth PIN Code

Send: AT+PIN
Response: OK

Check Firmware Revision

Send: AT+VERSION
Response: Linvor1.5

Examples

AT
OK

AT+VERSION
Linvor1.5

AT+BAUD4
OK9600

AT+NAMEBlueBee
OKBlueBee

AT+PIN1234
OK1234

10 thoughts on “Multiwii Bluetooth – Change Baud Rate with Arduino

  1. Ludo De Greef

    Hello Oscar,
    Thank you for all the info. I’m learning a lot here.

    I have some small questions. I’m rather new in Arduino, (just learning) …
    My BT-module is the one from ReadyToFlyQuad5.com
    It mentions:
    YFROBOT
    2013
    BT_Board v1.2

    Will it be possible to contact this BT-module via the Arduino-Board? Have tried it but no luck yet. getting some strange symbols as response when sending AT-commands in the Serial Monitor.

    Also, This BT-module has the following connections:
    SET
    VCC
    GND
    RXD
    TXD
    CLR
    Do you think I presume correctly that SET equals the PIN-connector?

    thx!!

    Reply
    1. Oscar Post author

      not sure what module you have, strange symbols means your Arduino IDE serial monitor baud rate is wrong, try changing it until you get readable characters.

      Reply
  2. Sam

    Hi, I have a problem when setting the baud rate of my Bluetooth module. At baud rates less than 115200, everything works fine, but when its at 115200, I get responses like this:

    Enter AT commands:
    OéO)+™vo¹+L þ

    Is there anyway of fixing this?
    Thanks in advance.

    Reply
  3. edu

    Just found your blog ,and your great tutorials

    I am trying to connect this bluetooth device from banggood to the acronaze using the el gui configurator apk. For android
    banggood.com/MWC-Multiwii-Bluetooth-Parameter-Debugging-Programmer-Module-p-86049.htmlIt connects but does not download data.

    Isuspects the problem is the baud rate as you state in your tutorial

    I have used your sketch in my frduino nano with no success trying to change it.

    I get green light and flashing red light.

    Perhaps it’s because my bluetooth device is not like yours

    , it only has 4 wires, doesn’t have Module Key (PIN 34) wire.

    I am not familiar with sketches and was wondering if you could help me to modify your sketch so I could try changing the baud rate.

    In my frduino tx and rx are pins 0 and 1 if it helps

    thanks in advance

    Reply
    1. Oscar Post author

      Hi Edu
      I am not sure about this module, it looks different to mine and doesn’t key pin which is required to change baud rate.
      But since it’s designed for Multiwii, it should also work for Naze32 out of the box.
      have you tried swapping RX/TX?
      you can also change serial baud rate on the Naze32 (in CLI) to match the BT module, but I would suggest to leave it alone, because I haven’t tried it myself, and it might cause other problems.
      thanks
      Oscar

      Reply
      1. KUBAIS

        Hi,

        I have same BT module like edu and it´s also not working for me. I tried changing baudrate in Sketch, but only command that works for me is AT, no response for any other command. Also tried changing buadrate in CF to 9600 for UART1 and to no avail.
        BT module is working (can connect to it with android phone) but it does not send/receive any data, thus in Naze32 configurator I get connected (name of BT even preconfigured ad “ZMR”) but no data receiving/sending.
        Do you have any other idea that could make this module work?
        If not should I rather try buying HC-05 or HC-06?

  4. etheli

    The bluetooth baudrate can also be setup using an FTDI (serial) adapter. I did it using these directions: wiki.openpilot.org/display/WIKI/Bluetooth+Setup+for+Telemetry

    Reply
  5. Kim

    I Have an arduino Flight board.
    and upload the multiwii open source.
    i am going to use the blutooth module hc-06 to use multiwii configurator.
    and i don’t know how to coding the blutooth, software
    i am not good at english sorry.
    do i need a necessary code?

    Reply
  6. Wayne

    I have a Window Laptop with WIN 7 and no Hyperterm program. I also don’t have a Arduino board.

    Any suggestion how I can change the BT baud rate?

    Wayne

    Reply
    1. Oscar Post author

      you will need at least a ISP programmer or arduino to do that, so get one.
      Ever windows install should have Hyperterminal, you can find the hyper terminal here

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you Robot? *

I only check blog comments once or twice a week, if you want a quick reply you can post your question on this forum IntoFPV.com... You might get a faster response from me there (multirotor related only).