How do I increase the available baud rate of the bluetooth module for the Raspberry P1 3 model B?

I have tried editing the /boot/config.txt file with:

but that did not solve my issue, nor did trying

I have the script running at 9600 Baud and 115200 Baud, but would ideally like to have it running on 921600 baud, to get the sampling rate I am after.

My system

Raspberry Pi 3 model B connected via bluetooth t0 an arduino Nano (with a HC-05 Module and accelerometer attached). Acquisition code for the Raspberry Pi side is;

#!/usr/bin/env python3
Reads accererometer data sent through via the sensor node and
saves as a .csv file
Usage: Data_Acquisition.py [options]
    -o=SAVE_FILE           The file to write to [Default: ./data.csv]
    -b=BAUD --baud=BAUD    The Baud Rate [Default: 9600]
    -p=PORT --port=PORT    The serial port to listen to [Default: /dev/ttyUSB0]
    -t=TIMEOUT --timeout=TIMEOUT
                       Set the timeout for the read operation [Default: 5]
    -h --help              Show this help information
    -V --version           Print the version information
__version__ = '0.1.0'

import serial
import struct
import csv
import time
import sys
import docopt

def main(args):
    save_file = args.get('-o', './data.csv')

    # Open serial connection with node
    ser = serial.Serial(args['--port'],
    # Allow time for serial to initlise and send start byte

    # open .csv file with write
    with open(save_file, 'w') as f:
        writer = csv.writer(f)

            while True:
                raw = ser.read(16)
                if len(raw)==0:
                    print('Program End')
                data = struct.unpack('Ifff',raw)
        except KeyboardInterrupt:
            # end read when keyboard interrupt
            print('Program end: User interrupt')

if __name__ == '__main__':
    args = docopt.docopt(__doc__, version=__version__)

I set up the HC-05 bluetooth module as rfcomm1 and run the script (setting the bluetooth module and arduino script to the right baud) but I do not receive any data

  • "I have tried editing the /boot/config.txt file with: init_uart_baud=1000000" -> Why didn't you use 921600 if that is what you want? The default is 115200 with a 3 Mhz clock, so it is not as if they have to divide evenly into each other. I know it is reliable at least for test data at 1000000, so it is not a matter of it not being fast enough either. – goldilocks Jul 26 '16 at 12:14
  • @goldilocks I used the 1000000 baud as that is what the source I was using had. I am unsure is having the initial uart as 921600 will change anything, as you said, the default is 115200, and my initial testing was done at 9600, so it should work if the baud I set is less than the initial. I may be completely wrong, so I will try when I next have the chance. My thought is that the is a bluetooth config file that I also have to change, to increase the available baud to the ble module. However, I'm not that confident that I'll recognize what I need to change. – mlawes Aug 2 '16 at 12:11
  • "so it should work if the baud I set is less than the initial." -> Yes actually that's my experience, although I haven't tested that rigorously, and keep in mind 9600 is an even factor of 115200. It may be that 921600 just plain is not support(ed/able). But it is worth trying in config.txt anyway -- much of the stuff in there seems to be explicitly about configuring hardware and not the OS, which is the ideal way to go if possible. – goldilocks Aug 2 '16 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.