Quadrocopter MultiWii, serial Bluetooth connection
Important: If you use the USB-Port, disconnect the Bluetooth module.
Yes, there is a cheap and working Serial-To-Bluetooth module available. This can be used in Slave function to get a wireless serial link to a Host computer for control.
I am using an Arduino Nano 3 with integrated Mini-USB port as the controller. Because there are 1 KOhm resistors between FT232 (USB-Serial converter) and CPU serial port, you can also connect the Bluetooth Serial module for serial communication. This is also the case for the Arduino Mega (ATMega 1280 CPU) controller.
You can use an Android App to change parameters.
You can use the MultiWiiConfig program, if the RXTXcomm.jar library is up to date (version 2.2pre2).
Serial Bluetooth Module
Attracted from a low price (about 8 EUR incl. shipping) I ordered a Serial-To-Bluetooth module Serial Bluetooth RF Transceiver Module RS232 w/ Backplane Enable & State Pin
Size: 40 x 16 mm
Coverage: about 10 m
Baudrate, default: 9600 baud 8N1
Bluetooth pairing code: 1234
Bluetooth name: lenvor, Type: HC06 - slave only
Power supply: 5V, 10 mA (Chip has 3.3V)
Type Information from Klaus DJ7OO:
Type HC-06 is Slave only, so connection ONLY can be initiated by a Master. Master could be e.g. PC, Smartphone, Tablet.
Type HC-05 can be used as Slave (default) as well as Master. Master mode is selectable by choosing Command mode and sending appropriate AT command.
BC-04 or BLK-MD-BC04-B seems to come from another group of manufacturers. It also can be used as Slave (default) or as Master. In case it's SW/HW selection pin is connected to ground, mode selection simply can be done by switching it's pin named Master/Slave.
All those modules are using default baud rate 9600bps, but can be set to other baud rates by using AT commands.
- Using one module as Slave and the other one as Master can replace wire connection for bidirectionally sending asynchronous serial data. Data rates used on Master and Slave side must NOT be identical.
I will just document the technical details for use. A more detailed guide is found on Fangin.com
In order to use this Serial Bluetooth Module for a wireless serial link to the MultiWiiControl (MWC) you have to configure it first with some AT control commands.
Hardware connection to the Serial Bluetooth Module for configuration with a PC:
CP2102 Module Modul USB to TTL Converter Konverter for about 4 EUR.
Nokia CA-42 cable. In this case you have to cut off the Nokia plug and solder your own connector to the cable. Beware that there is a blue or black USB plug housing, which have different chips inside. You will find more details about in DockStarSerialLink (Eng.) or GPIBtoUSB (Ger.).
MWC plug - BT J1 pin -------------------- +5 V -> 2, 5V (VCC, red wire) GND <> 3, GND RXI <- 4, TX data (3.3 V) TXO -> 5, Rx data use an USB-to-Serial converter or a Nokia C-42 cable (Ebay) to test and change parameters. Under Mac OS X using "CoolTerm": Set local echo ON Under Linux using PUTTY or "CoolTerm": Set local echo ON Text from the clipboard is inserted into the terminal window via the middle mouse key. Do not use Carriage Return CR or Line Feed LF! All commands (Input) should be entered in a Terminal window with copy and paste, just typing AT (fast, repeating) is ok. The Serial Bluetooth module does not echo the input characters. You can do that with the terminal program. For example, change name from "lenvor" to "MultiWii" and baudrate from 9600 to 115200 baud for MultiWii: Input, no echo Output Note ----------------------------------- AT OK for test AT+NAMEMultiWii OKsetname AT+BAUD8 OK115200 re-connect with new baudrate 115200 AT+PIN1234 OK1234 Note: if it does not work, try to swap RX/TX lines on one side.
The Bluetooth module itself needs a supply voltage of 3.3 V. The backplane has a 3.3 V regulator on board and has 6 connection pins, spaced 2.54 mm.
In order to avoid any conflict with +5 V data line, you should insert a 1 KOhm resistor in series to the RXD data line of the Bluetooth module. The transmit signal TXD has a 3.3V output level and must override the signal from the FT232RL USB/Serial converter, which is connected via a 1 KOhm series resistor to the CPU.
Android App MultiWii Configurator
There is an Android App by Nando (Android MultiWii Configurator, version 0.3.4) to adjust the PID parameters and more. On a LG P500 smart phone (display 320 x 480 pixel) it works, just the last parameter RC EXPO is not readable because of the small display. But you can scroll the screen vertical, so RC EXPO is reachable.
It supports MultiWii conf version 1.7, 1.8p2 and 1.9. Not 2.2.
There is also a second screen mask (AUX switching), you see it if you touch and move your finger horizontal over the screen. That allows to configure the AUX switching, for example LEVEL (ACC) and BARO.
Under Menu/Calibrate you can calibrate the ACC and MAG sensor.
In order to use the program, you first have to pair the Serial Bluetooth module with the PIN (default = 1234) under Menu/Settings->Select Bluetooth device. Here you can see the name of all to the smartphone known Bluetooth devices, tap on the device name which is connected to the MultiWiiControl.
Next you tap on Menu/Connect to connect to the Bluetooth device (e.g. named MultiWii). It can take a few seconds. The blinking LED on the Serial Bluetooth module will lit permanent if the connection is established.
Tap on Read for reading the Parameters from the MultiWiiControl.
- Make your change on a parameter.
Tap on Write to write all parameters back to the MWC.
Under Menu/Extras you can tap on Screenshot in order to save the screen contents to the folder amwc on the SC-Card, the name is AndMwcScreenshot_...png.
You can also save and load a set of named parameters in a profile file on the SD-Card in folder amwc with the entered name name.mwc.
Android App MultiWii EZ-GUI
It works with MultiWii version 2.2. I tried version 3.45. * It has an Exit button, and switches off Bluetooth and GPS at exit.
Android App NAZE32 Configurator
It works with MultiWii version 2.2. I tried version 1.49.
There is no Exit button, and it does not switch off Bluetooth.
Function Matrix of Operating Systems
In all operating systems it did not work on the first try. Partially it has to do with the RXTX library version (see Links).
Mac OS X 10.6.8
Arduino V.22 - Serial Port is /dev/tty.MultiWii-DevB
Opening the Serial Monitor works. Automatic Downloading does not work, because a DTR connection for CPU-Reset is missing.
MultiWiiConfig_1_8_patch2 - works
MultiWiiConfig_1_9 - does not work
Ubuntu 11.04, see problems below
- Arduino V.22 - /dev/rfcomm0 - Serial Monitor OK
- Use Terminal with command to connect: $ sudo rfcomm connect 0
MultiWiiConfig_1_8_patch2 - Port: /dev/rfcomm0 OK (application.linux/lib/RXTXcomm.jar version 2.1-7 does not work, you have to use version 2.2pre2)
MultiWiiConfig_1_9 - Port: /dev/rfcomm0 OK, it just takes a few seconds to start.
- Arduino V.22 - /dev/rfcomm0 - Serial Monitor OK
Windows 7 64 Bit, a new "rxtxSerial.dll" from 2011-03-17 was needed, see Links.
- Arduino V.22 - Port: COM6, Serial Monitor OK
MultiWiiConfig_1_8_patch2 - Port: COM6, OK
Problem Linux, Ubuntu 1104
While Bluetooth pairing to device MultiWii you have to take the pre defined PIN "1234".
The following tools are used for setup and debug:
hcitool scan - search Bluetooth devices
sdptool browse MAC - ( Service Discovery Protocol) shows available services of the remote device
Bluetooth service status for the build in or USB device:
$ sudo service bluetooth status * bluetooth is running
Infos about rfcomm0 udev:
$ udevadm info --query=all --name=/dev/rfcomm0 P: /devices/virtual/tty/rfcomm0 N: rfcomm0 E: UDEV_LOG=3 E: DEVPATH=/devices/virtual/tty/rfcomm0 E: MAJOR=216 E: MINOR=0 E: DEVNAME=/dev/rfcomm0 E: SUBSYSTEM=tty E: ID_MM_CANDIDATE=1 $ udevadm info --attribute-walk --name=/dev/rfcomm0 Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device. looking at device '/devices/virtual/tty/rfcomm0': KERNEL=="rfcomm0" SUBSYSTEM=="tty" DRIVER=="" ATTR{address}=="00:11:08:05:07:91" ATTR{channel}=="1" $ lsmod | grep usb btusb 18160 2 bluetooth 65493 9 rfcomm,sco,bnep,l2cap,btusb usbhid 41704 0 hid 77084 1 usbhid usb_storage 43946 3 # usbserial is NOT loaded $ lsof /dev/rfcomm0 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 1931 rudi 48u CHR 216,0 0t0 23372 /dev/rfcomm0
Infos about Bluetooth-Stack
$ hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 00:02:72:A6:EE:2A ACL MTU: 1021:7 SCO MTU: 64:1 UP RUNNING PSCAN ISCAN RX bytes:219552 acl:4230 sco:0 events:913 errors:0 TX bytes:22179 acl:1616 sco:0 commands:47 errors:0
Setup for automatic connection to your Serial Bluetooth device.
With gnome-bluetooth the MultiWii bluetooth serial module (00:11:08:05:07:91) was found and the code "1234" was entered for pairing.
For automatic access to the serial Bluetooth profile, the file /etc/bluetooth/rfcomm.conf must be adopted.
You have to declare your remote serial devices. After editing you have to reboot, in order to get automatic device /dev/rfcomm0 or more.
In the example rfcomm.conf file I have declared 2 Bluetooth Serial devices rfcomm0 and rfcomm1, in order to better show the syntax.
# first Bluetooth Serial device rfcomm0 { bind yes; device 00:11:08:05:07:91; channel 1; comment "MultiWii"; } # second Bluetooth Serial device rfcomm1 { bind yes; device 00:11:08:05:07:84; channel 1; comment "MultiWii2"; }
Manual connection to your Serial Bluetooth device, for debug
The rfcomm0 device must be setup manually in the terminal, until automated with the file /etc/bluetooth/rfcomm.conf, see above:
# bind does not work $ sudo rfcomm bind MultiWii $ rfcomm rfcomm0: 00:11:08:05:07:91 channel 1 clean $ rfcomm connect 0 Can't create RFCOMM TTY: Address already in use # better use connect $ sudo rfcomm release 0 $ sudo rfcomm connect MultiWii Connected /dev/rfcomm0 to 00:11:08:05:07:91 on channel 1 Press CTRL-C for hangup # LED on Bluetooth serial module lits # PUTTY does work now with serial rfcomm0 and 115200 baud.
The RXTX library 2.1.7 does not look for a /dev/rfcomm0 device.
adding the serial port string in the starting shell script (MultiWiiConf_1_8_patch2_BT) does not help.
-Dgnu.io.rxtx.SerialPorts="/dev/rfcomm0"
After plugging in an USB-serial converter, then device rfcomm0 was recognized.
$ lsmod bluetooth 65493 9 rfcomm,sco,bnep,l2cap,btusb
- From the Mindstorms help page I got the hint for automating rfcomm:
# file /etc/rc.local add before exit 0 /usr/bin/rfcomm bind all
Excerpt from dmesg, after plugging in an USB-serial converter:
[ 14.753473] Bluetooth: RFCOMM TTY layer initialized [ 14.753493] Bluetooth: RFCOMM socket layer initialized [ 14.753500] Bluetooth: RFCOMM ver 1.11 ... [ 169.558762] rfcomm_tty_ioctl: TIOCGSERIAL is not supported [ 251.228231] usb 3-2: new full speed USB device using uhci_hcd and address 2 [ 251.448729] usbcore: registered new interface driver usbserial [ 251.448786] USB Serial support registered for generic [ 251.448921] usbcore: registered new interface driver usbserial_generic [ 251.448929] usbserial: USB Serial Driver core [ 251.463504] USB Serial support registered for pl2303 [ 251.463609] pl2303 3-2:1.0: pl2303 converter detected [ 251.475286] usb 3-2: pl2303 converter now attached to ttyUSB0 [ 251.475366] usbcore: registered new interface driver pl2303 [ 251.475374] pl2303: Prolific PL2303 USB to serial adaptor driver [ 529.254870] rfcomm_tty_ioctl: TIOCSERGETLSR is not supported
Linux, Ubuntu 1104, works after update
There is a problem with the RXTX Library version 2.1-7. You have to use version 2.2pre2, see above.
For the MultiWii conf program to work with rfcomm0, you have to compile it with the Processing tool (see Links), which must have an updated RXTX library version 2.2pre2.
Processing is the Cross Operating System development tool for Arduino and MultiWii conf.
Problem Windows 32
With a Bluetooth dongle inserted the Arduino IDE and the Config Program has a major start delay, and problems finding the serial ports.
A solution was worked out by "eried" in the Arduino forum: Road to solve the delay on the Arduino IDE
You have to replace the file rxtxserial.dll in the Arduino folder. This file can be downloaded from the given web address (version from 2009-03-17).
In my case on Win7-64 the serial ports COM6 and COM7 are created for the Bluetooth connection. When you look on the property page (Eigenschaften), you will see on the service (Dienste) tab "Serieller Anschluss (SPP) Dev B COM6".
The Bluetooth pairing with code "1234" does work without problem.
When I try with the program PUTTY to open a serial connection on port COM6 I will get an error: "Unable to open connection to COM6. Unable to open serial port".
The ArduinoBT also has a problem, see Arduino BT connection problems, which is solved with a modified boot loader. Unfortunately it will not help in my case.
Links
- DUN = Dial Up Network
Re: Road to solve the delay on the Arduino IDE, rxtxSerial.dll
List of pages in this category:
-- RudolfReuter 2011-09-27 10:08:08
Go back to CategoryQuadrocopter or FrontPage ; KontaktEmail (ContactEmail)