Monitor Your nRF52 Battery with Jumper in 15 Minutes
The nRF52 is a popular Bluetooth Low Energy solution designed for IoT devices. Coupled with a battery and the right design it could go on for years without a charge. The problem is predicting how the device behaves in the field. Finding problems ahead of time is critical for maintaining high quality of service.
Jumper insights is a monitoring platform for embedded IoT devices. One of the things you can do with the platform is battery analysis. In this post I will walk you through the process of adding battery monitoring to an nRF52 project using Jumper Insights.
Most examples will not include a real use case. They’ll typically omit the gateway. In this example we’ll be walking through a full example that includes an end device and gateway. And it’ll only take 5 simple steps.
STEP 1 — make sure you have the following prerequisites
For compiling the sample project:
Linux computer/gateway with:
- Bluez drivers
- Python 2.7
- We tested it on Ubuntu 14.04 and 16.04
STEP 2 — nRF52 Sample Project
This sample project is based on the ble_app_template taken from Nordic’s nRF5-SDK.
1. Download the project and unzip: https://s3.eu-central-1.amazonaws.com/jumper-public/ulogger/nrf52-ble-sample-project-v0.1.1.zip
2. export NRF52_SDK=/PATH/TO/NRF5-SDK
3. Compile the app and run it on the device
cd nrf52-ble-sample-project
make flash_softdevice
make flash
Step 3 — Install Jumper’s BLE-Logger to the gateway
This is probably the coolest part of the system. Typically, you would need to integrate an SDK to your gateway application, recognize monitoring notifications vs. application notifications and handle them accordingly. The BLE logger, which is a type of an HCI proxy, does that so you wouldn’t have to. It collects and handles the monitoring notifications, while forwarding the regular (application) notifications to your gateway application. The gateway application is kept virtually unchanged.
Installation:
1. Install both prerequisites libffi
and libssl
.
Ubuntu: sudo apt-get install libffi-dev libssl-dev
2. Install the BLE Logger by executing: sudo -H pip install jumper-ble-logger
Have a look at the newly created “/etc/jumper_ble_logger/config.json”, this is where you will need to store your credentials at the next step.
Step 4 — Register on Jumper Insights’ Website and Create a Project
1. Go to https://app-events.jumper.io and register as a new user:
2. Create a new project:
3. On the “Manage Projects” page, click the “wrench” icon near your project’s name and copy your project’s id and key to the “/etc/jumper_ble_logger/config.json” file.
Step 5 — See it In Action!
1. On your gateway, start the BLE Logger service: sudo service jumper-ble start
2. Verify that the service is running: sudo service jumper-ble status
3. You should see a new virtual HCI device on your system by executing hciconfig
:
4. Use hcitool to find the MAC address of the nRF52 device: sudo hcitool -i hci1 lescan
In our example, the MAC address is C6:45:82:23:11:44
.
5. Use gatttool to connect to the device and discover its characteristics:
sudo gatttool -i hci1 -t random -b AA:BB:CC:DD:EE:FF -I
6. You should now see the battery events on the “Battery Analysis” page:
Note that you can use the device as usual as monitoring communications are not being delivered to hci1
.
Conclusions
We saw how easily Jumper Insights can be integrated to an existing project.
Check out the sample project and see how adding more data to the system can help you get more insights and information regarding the real behavior of your system in production.
The more data you upload the more insights you get. Here are more examples of useful data you can log with Jumper :
- Battery level
- Version release
- Number of boot events
- Power modes (coming soon) — sleep, radio state, connection state
- Crash reports (coming soon)
Call for Input
If you find this interesting — signup to get updates from Jumper and join our closed beta.