31 Bluetooth Module Bluetooth radios provide short-range (up to 20 m)
144 31 BLUETOOTH MODULE
goes dark, and you should also expect to see the STATUS front-panel indicator active; these two indications show that the RN42 has established a data connection with another Bluetooth device. Type characters into the PuTTY terminal emulator window and expect to see those same characters appear on the VI front panel. Type “t” and “d” and confirm that you see the NI myRIO system time and date. Click enable echo and type some more characters; you should now see the characters as you type them in the PuTTY terminal emulator window.
Click the CTS (“Clear To Send”) button and type several characters. When CTS is active the RN42 suspends transmitting from its UART and you should observe that no characters are received by the NI myRIO. Click the CTS button again and you should see the buffered characters appear in quick succession on the incoming character indicator.
Close the PuTTY window; you will see the PmodBT2 green status LED blinking again and the STATUSfront-panel indicator inactive to show that the RN42 is waiting for a new data connection.
Open a PuTTY window again and type $$$ to enter command mode. By now the default 60- second configuration time window has expired and nothing special will happen. Observe the PmodBT2 green status LED as you click the RESET button two times; do you notice how the blink rate is faster now? This medium-speed rate indicates that the RN42 can accept a request to enter command mode. Type $$$ again and you will see the CMD prompt ap- pear; also observe that the status LED blinks at high speed while in command mode. Type “h” to display help on all of the available commands. In particular, try “d” to display basic settings, “e” to display extended settings, and “v” to show the firmware version. Type -- to exit command mode.
Click the Stop button or press the escape key to stop the VI and to reset NI myRIO.
Troubleshooting tips: Not seeing the expected results? Confirm the following points:
• Glowing power indicator LED on NI myRIO, • Black Run button on the toolbar signifying that
the VI is in run mode,
• Correct MXP connector terminals — ensure that you are using Connector B and that you have the correct pin connections,
• Correct PmodBT2 terminals — double-check your connections, and ensure that you have connected the NI myRIO UART “receive” input to the RN42 “transmit” output; also check that you have not accidently crossed the power supply connections.
31.2
Interface Theory
Interface circuit: The Roving Networks RN42 is a self-contained full-qualified Bluetooth Class 2 module with integrated antenna. By default the RN42 operates in “slave” mode, may be paired with the code “1234,” and offers the Serial Port Profile (SPP) service. By connecting the NI myRIO UART directly to the RN42 UART, the RN42 appears as a virtual COM port on a Bluetooth-capable laptop or desktop computer.
Study the video Bluetooth Interfacing Theory (youtu.be/WidjSMNU1QM, 15:34) to learn more about the RN42 as the basis of a wireless serial cable replacement application, including essential RN42 features and PmodBT2 pinout, pairing the RN42 with a computer, accessing the virtual COM port with a terminal emulator and with a LabVIEW desktop application, and accessing the RN42 UART with the NI myRIO low-level UART VIs.
31.3
Basic Modifications
Study the video Bluetooth Demo Walk-Through (youtu.be/LFCThGa681A, 15:08) to learn the design principles of Bluetooth demo, and then
31. BLUETOOTH MODULE 145
try making these modifications to the block diagram of Main.vi:
1. Create a desktop LabVIEW VI to interact with the COM port; review Bluetooth Interfacing Theory (youtu.be/WidjSMNU1QM, 15:34) for ideas. 2. Add additional cases to return other internal
states of the NI myRIO. For example, return the value of the onboard accelerometer X-axis when the “x” character is received.
3. Add a data streaming feature: when the “a” character is received begin transmitting the three onboard accelerometer values once every 100 ms (three space-delimited values followed by a carriage-return and linefeed combination); continue streaming out data until the “a” character is received again.
31.4
Integrated Project Ideas
Now that you know how to use the Bluetooth module consider integrating it with other devices to create a complete system, for example:
• Wireless Sensor (40)
31.5
For More Information
• PmodBT2 Reference Manual by Digilent ∼ Reference manual for the Bluetooth module:
http://digilentinc.com/Data/Products/PMOD-BT2/ PmodBT2_rm.pdf
• PmodBT2 Schematics by Digilent ∼ Schematic diagram of the Bluetooth module:
http://digilentinc.com/Data/Products/PMOD-BT2/ PmodBT2_sch.pdf
• RN42 Datasheet by Microchip ∼ Datasheet for RN42 Bluetooth module; select the “RN42” PDF document at the bottom of the page:
http://microchip.com/RN42
• Bluetooth Data Module Command Reference and Advanced Information User’s Guide by
Microchip ∼ Complete information on config- uring the RN42 while in command mode; select the “Bluetooth Advanced User Manual” PDF document at the bottom of the page:
http://microchip.com/RN42
• Bluetooth Basics by SparkFun ∼ Excellent tutorial on Bluetooth and wireless mobile devices:
http://learn.sparkfun.com/tutorials/ bluetooth-basics/all
• Bluetooth Resources by Bluetooth Developer Por- tal ∼ Comprehensive site devoted to designing with Bluetooth: