The nRF8002 breakout board is a simple to use module to develop Bluetooth 4.0 based applications. The nRF8002 has 3 digital outputs, 1 pulse width modulated(PWM) output, and 2 digital inputs. This module supports the proximity profile, and can create immediate alerts and link loss alerts. The module also supports the battery profile, and the host can query the device for the battery state of charge. In this tutorial, we will be developing a simple proximity application.
The components needed for this application are:
- The TX and RX pin of the nRF8002 breakout board is connected to the RX and TX pin of the FTDI USB
(Change to 3.3V operation) to serial converter respectively.
- The IN1 and IN2 pins are connected to the pushbuttons.
- The OUT1, OUT2, and OUT3 pins are connected to the LEDs via 330Ω resistors
- The buzzer is controlled via transistor 2N3904 whose base is connected to the PWM output of the Bluetooth module via a 330Ω resistor.
The final assembled setup is shown below:
A photograph of the assembled board is shown below:
To program the various parameters in the Bluetooth module to control the inputs and outputs, we will be using the nRFStudio tool available from Nordic Semiconductor at (http://www.nordicsemi.com/eng/nordic/download_resource/14964/43/10909484).
Once the program is installed, it communicates to the Bluetooth module using the FTDI Basic board. When the program is launched for the first time, the screen below is seen. Click on nRF8002 in the “Features” menu on the left to begin configuring the device.
In this tab, we will set the “Local Name” parameter to “myFirstBLE”. This value will be displayed on the host device during the initial pairing process. The remaining parameters in the “Identification” section of this tab can be used to uniquely identify the device. The parameter values can be queried by the host system. In this application, the remaining parameters are left unchanged.
An input pin connected to a button can generate three events determined by the amount of time the button is pressed.
- A press shorter than t1 is interpreted as a Short press.
- A press longer than t1, but shorter than t2, is interpreted as a Medium press.
- A press longer than t2 is interpreted as a Long press.
The polarity section is used to determine if active low or active high should be used for signaling. The default setting is active low. This screen is also used to provide immediate feedback for the various button press events. In the default settings, a simple beep is heard after a short press and a double beep is heard after a long press. Custom blinking and beeping patterns can be developed using the “Outputs tab”
The output tab is used to develop custom blinking and beep patterns that can be assigned to the various output pins.
State Machine Tab
This tab is used to configure the state machine of the module. The device has 4 states namely sleep, bonding, connecting, and connected. For each state, the three digital outputs and PWM output of the module can be configured. Similarly, the inputs that will trigger the entry into the various states can also be controlled.
Profile – On Slave Tab
This tab is used to control the proximity and battery related functions. For proximity, there are two main types of responses namely Immediate and Link Loss. Each of these responses can be further configured at run time by the host as mild or high. For example with the default setup, when the master device sets the Immediate alert to Off, the output pin is disabled. This happens because the output pin is set to use the pattern Fixed output to the PWM, but inverts it.
For example, the default setup uses the PWM to trigger 3 short beeps when the master device has
activated Immediate alert with level set to Mild.
Profile – On Master Tab
This tab is used to select the output you want when the peer device sends an Alert notification. For example, in the setup shown in the figure Pin 3 will be set to 5 blinks, 300ms on, 200ms off when an Alert notification is received and the SMS/MMS. When the Call flag is set, Pin 3 will use the 3 blink, 200ms on 500ms off setting.
Upload Configuration Tab
This tab is used to upload the final configuration into the device for testing. During debugging, the radio box for “Upload to RAM” must be selected. If the device is powered off or reset for any reason, the settings must be reloaded. Once the system has been debugged, the settings can be permanently stored on the device by using the “Upload to OTP” option. This will permanently store the configuration in the one time programmable (OTP) memory and will be available even after power off or reset conditions.
We have put together our own Android app to test this setup. You can check out the code and full explanation of the app here! This project can also be tested using an iPhone running iOS 6.0 or greater using the nRFReady app provided by Nordic Semiconductors. It can also be tested on an Android phone running Android version 4.3 or greater using the nRF Utillity app also provided by Nordic Semiconductors.