Wireless Comparison by Sparkfun



Bluetooth is a standardized communication protocol that operates in the ISM Band from 2.4 to 2.485 GHz. Bluetooth is optimal for short range (under 100m) transfers of small packets of data. This protocol consists of a collection of profiles including Serial Port Profile (SPP), Human Interface Device (HID), Hands-Free Profile (HPF), Advanced Audio Distribution Profile (A2DP), or A/V Remote Control Profile (AVRCP).

Sparkfun provides a comprehensive introduction to bluetooth technology, which can be read here.



Bluetooth Modules

Perhaps more commonly known is Broadcom's BCM2042 SoC (System on a Chip). Nintendo utilized Broadcom's technology to create the wireless functionality in a Wii remote. The Wii remote follows the HID (Human Interface Device) protocol.


Devices with bluetooth modules that are attached to a compatible device in a network contribute to the Internet of Things. More recently, boards such as the WeMos D1 have grown in popularity due to their low price point and ease of use.


Communicating with the Wii Remote

All bluetooth devices have a unique 48-bit address (BD_ADDR) represented as a 12 digit hexadecimal value. Given that the 24 most significant bits idintify the manufacturer, we are left with the 24 least significant bits to distinguish between devices.

After installing the CWiiD python package, the Raspberry Pi will be capable of regonizing a the Wii remote when performing a scan. Simultaneously holding down the 1 and 2 buttons allows the remote to enter its Discoverable State, thanks to the BCM2042.

We can see the 12 bit hexadecimal value displayed on the terminal, which is the remote's bluetooth address. The binary representation of this value is writted in reverse order. For this particular unit, the 6 Byte array would be:

0xab 0xd0 0x58 0xe8 0x1a 0x00

Each of these bytes are responsible for flags, reporting, and much more that is thoroughly discussed here. What was important to note, however, was the binary value each button returned. Knowing this would allow us to utilize the remote as a controller for any output device. The package we installed earlier assisted in obtaining the binary values for each button as a decimal. We were then able to map the decimals to each button.


These were the values of the buttons pressed one at a time. Pressing any combination of buttons results in the addition of their decimal number. This allows for a single packet to be transferred at a time, as opposed to two separate ones. Each combination results in a unique number, which makes it possible to decode the sum of the two numbers into its components.



Control Scripts





Given that we are able to identify which button was pressed based on the value returned by wm.state['buttons'], it is possible to repurpose the controller for other tasks. To the right is a portion of the code where we call upon the previously made function to actuate the servo.>

We additionally set the remote's on board LEDs to light as specific buttons were pressed in order to test whether the unit was able to also receive data. Pressing left or right on the directional pad flashes the LED. Pressing 1 or 2 puts the servo in its left most or right most state respectively, and the remote is programmed to rumble.

The game controller was successfully repurposed to actuate a servo. Any output device can be placed on the receiving end.


Video

Back to top of page


© Team459 2018