Whenever it comes to setting up new applications, I usually come back to the Arduino Due, while the Mega 2560 is a close second choice. This next new project was an SAE J1939 (a CAN Bus based higher layer protocol) to Bluetooth interface. The idea was to connect an ARM-Processor-based hardware to a vehicle network and relay a pre-defined data set to an Android tablet for further processing. The Arduino platform is not necessarily the perfect solution for automotive applications (think limited temperature range, limited power supply range, no protection against environmental factors such as vibration, etc.), but it is the best choice when it comes to quick prototyping.
I had run into some issues with the Bluetooth connection on our SAE J1939 / OBD-II Electronic Logging Device With Bluetooth, which forced me to re-think the approach. Using the Arduino platform for prototyping and tests enforces a simple approach to any project (think KISS = Keep It Simple Stupid!).
One part of the KISS approach was using the Microchip RN41XV Bluetooth module. The module can be accessed per UART connection, which enables the developer using standard serial communication without having to deal with complex protocol stacks. In case of the Arduino Due, I used the RX1/TX1 (Serial1) connection.
The RN41XV and RN42XV are small form factor, low-power Bluetooth radio modules offering plug-in compatibility for the widely used 2 x 10 (2-mm) socket typically used by 802.15.4 radio modules.
Based on the popular 2 x 10 (2-mm) socket footprint often found in embedded applications, the Roving Networks’ RN41XV and RN42XV modules provide Bluetooth connectivity in legacy and existing designs that may have been based upon the 802.15.4 standard.
The RN41XV Class 1 Bluetooth module is based on the RN41, and the RN42XV Class 2 Bluetooth module is based on the RN42. These modules are simple to design in and are fully certified, making them a complete embedded Bluetooth solution. The RN42 is functionally compatible with the RN41.
The Class 1 RN41 module has a range up to 100 meters (~300 feet). The Class 2 RN42 module has a range up to 20 meters (~60 feet).
The connection between the Arduino Due or Mega 2560 to the RN41VX Bluetooth module requires 4 wires (see above photo; the pin dimensions of the RN41XV did not match my standard bread board, so I soldered directly to the pins).
The image to the left shows the RN41XV module. The important pins are:
1 VDD_3V3 - Connect to 3.3V on the Arduino
2 TXD - Connect to RX1 on the Arduino
3 RXD - Connect to TX1 on the Arduino
10 GND - Connect to GND on the Arduino
Two additional signals (RTS - Request to Send, CTS - Clear to Send) are available but are not supported by the Arduino, so leave them open.
The next step, after powering up the Arduino, is to pairing the Bluetooth device with your PC or Mac. For more information, see:
In my case, I used a Windows 10 machine. Please be aware that a Bluetooth device requires two COM ports, one for receiving and one for transmitting data. The Windows Device Manager will show you a list of COM ports and even which are Bluetooth, but there is no further information which port is for reception or transmission. It is also important to know that you will need to access only one of the two COM ports for bi-directional data exchange, and, to make things worse, Windows will not tell you which one.
In a next step, use a terminal program such as CoolTerm (highly recommended!), RealTerm, or TeraTerm to connect to either one of the Bluetooth COM ports and find out which one is the one you need. The LED on the RN41VX module will stop blinking as soon as a connection is established.
Also use the terminal program to send and receive data to the Arduino. I have included a screen shot of the test program below. The code is so simple that it wasn't even worth proving a download link.
The sketch displays the data it receives from the PC and echoes it back to the terminal program.
Last, but not least, for more information on Bluetooth see Bluetooth Basics.
Getting Started with Bluetooth Low Energy: Tools and Techniques for Low-Power Networking
With Bluetooth Low Energy (BLE), smart devices are about to become even smarter.
This practical guide demonstrates how this exciting wireless technology helps developers build mobile apps that share data with external hardware, and how hardware engineers can gain easy and reliable access to mobile operating systems.
This book provides a solid, high-level overview of how devices use BLE to communicate with each other.
You will learn useful low-cost tools for developing and testing BLE-enabled mobile apps and embedded firmware and get examples using various development platforms, including iOs and Android for app developers and embedded platforms for product designers and hardware engineers.
- Understand how data is organized and transferred by BLE devices
- Explore BLE concepts, key limitations, and network topology
- Dig into the protocol stack to grasp how and why BLE operates
- Learn how BLE devices discover each other and establish secure connections
- Set up the tools and infrastructure for BLE application development
- Get examples for connecting BLE to iPhones, iPads, Android devices, and sensors
- Develop code for a simple device that transmits heart rate data to a mobile device