Introduction: Configuring a BLE Device (RN4871) As a Wireless Actuator for DragonBoard 410C
BLUEPY is a convenient Python library for accessing the Bluetooth Low Energy features of the DragonBoard 410c.
RN4871 is a tiny and easy to use Bluetooth Low Energy 4.2 module. Its embedded scripting language allows for a swift integration of sensors and/or actuators with the DragonBoard 410c.
This tutorial teaches how to easily integrate a RN4871 BLE module with the DragonBoard 410c.
In an IoT application, using BLE for substituting (eliminating) wires seems to be a good idea (due to cost saving in wires, less hassle with mess of wires, better electrical isolation, straightforward installation of sensors, etc).
The beauty of the the module RN4871 resides in its small size, simplicity of use and low cost. If all you need is controlling an output (relay), or read an input (digital or analog), this module is perfect. If your project requires more input or output pins, his big brother comes into play : the RN4870 (with more pins, more features). No MCU is needed for simpler applications, due to the scripting capabilities of these modules.
If you're in search for an easy to integrate BLE module with embedded antenna for your MCU project, either of them are serious candidates. It's easy to integrating them using UART communication and "AT" like commands.
The perfect match : a DragonBoard 410c as a concentrator for an army of tiny RN4871 as wireless node sensors or actuators.
Step 1: Required Components for This Tutorial
The following components are required for this Tutorial:
[1] 1 DragonBoard 410c Kit (the DragonBoard 410c itself, Power Supply, HDMI monitor, Keyboard and Mouse):
https://www.arrow.com/en/products/dragonboard410c/...
[2] 1 RN4871 Evaluation Kit (RN-4871-PICTAIL):
Step 2: Prepare the RN4871 PICTAIL Evaluation Board
Using a solder iron and 2 short pieces of thin wire, make the following signal connections:
[PIN P12] connects to [HEADER J5 / LED 5] (green wire in the picture)
[PIN P13] connects to [HEADER J5 / LED 4] (yellow wire in the picture)
This will connect two I/O pins of the RN4871 Module to a pair o LEDs available in the evaluation board (prototyping LEDs).
Note: the RN4871 PICTAIL board has a total os 4 LEDS a 4 Buttons for prototyping purposes.
Step 3: RN4871 Software Configuration
[1] Connect the RN4871 PICTAIL board to a PC using the provided USB cable.
[2] Using a terminal emulator (screen), open a serial connection to the RN4871 PICTAIL board :
$ screen /dev/tty.usbmodem1411 115200
[3] Follow the instructions of the section [1] of the Tutorial and complete the 24 programming steps.
By the end, the RN4871 Module will be ready to go (ready to connect to the DragonBoard 410c).
Note : For detailed instructions, read the PDF tutorial
Step 4: Prepare the DragonBoard 410c
Install the BLUEPY Library in the DragonBoard 410c
To install the current released version, on most Debian-based systems:
$ sudo apt-get install python-pip libglib2.0-dev
$ sudo pip install bluepy
Step 5: Run the Python Script
PYTHON SCRIPT DESCRIPTION
This example script (“bluepy_dw_write.py”) scans all nearby BLE devices, looking for its addresses and complete local names.
Once the “target name" (ble_module_name) is found, the scripts traverses all its services and characteristics, looking for the “target UUID" (ble_target_uuid).
If a match occurs, the “target value” (ble_target_value) is written to the characteristic.
Any Python script accessing the BLUEPY library must run as “superuser”:
$ chmod +x bluepy_dw_write.py
$ sudo ./bluepy_dw_write.py 0x00 (turn LEDs ON)
Possible Values : 0x00 (all LEDs ON) , 0x18 (all LEDs OFF) , 0x08 (LED1 on) , 0x10 (LED0 on)
In this example, the DragonBoard 410c will control two I/O pins (digital outputs) of the RN4871 BLE Module.
Note 1 : the I/O pins of the RN4871BLE Module could be easily reprogrammed as digital inputs or analog inputs as well.
Note 2 : For detailed instructions, read the PDF tutorial
Attachments
Step 6: Additional References
[1] BLUEPY
https://github.com/IanHarvey/bluepy
[2] DragonBoard 410c
https://developer.qualcomm.com/hardware/dragonboa...
[3] RN4871 Bluetooth Low Energy PICtail / PICtail Plus Daughter Board
http://www.microchip.com/DevelopmentTools/Product...
[4] RN4871 Bluetooth Low Energy Module






