Configuring Bluetooth module settings

The Bluetooth module can be set to one of two different modes using the KEY pin.

In a normal operation, serial messages are sent over Bluetooth; however, if we need to change the settings of the Bluetooth module itself, we can do so by connecting the KEY pin to 3V3 and putting it into AT mode.

AT mode allows us to directly configure the module, allowing us to change the baud rate, the pairing code, the device name, or even set it up as a master/slave device.

You can use miniterm, which is part of pySerial, to send the required messages, as shown in the following code:

python3 -m serial.tools.miniterm  

The miniterm program, when started, will prompt you for the port to use:

Enter port name: /dev/ttyAMA0  

You can send the following commands (you will need to do this quickly, or paste them in, as the module will time out if there is a gap and respond with an error):

  • AT: This command should respond with OK.
  • AT+UART?: This command will report the current settings as UART=<Param1>,<Param2>,<Param3>. The output of this command will be OK.
  • To change the current settings, use AT+UART=<Param1>,<Param2>,<Param3>, that is, AT+UART=19200,0,0.
HC-05 AT mode AT+UART command parameters

Zak Kemble has written an excellent guide on how to configure modules as paired master and slave devices (for example, between two Raspberry Pi devices). It is available at the following link:

http://blog.zakkemble.co.uk/getting-bluetooth-modules-talking-to-each-other/.

For additional documentation on the HC-05 module, visit the following link:

http://www.robotshop.com/media/files/pdf/rb-ite-12-bluetooth_hc05.pdf.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.93.12