Contents
  1. 1. Additional hardware
  2. 2. Software changes
  3. 3. Test Bluetooth connection

I believe the recently introduced json file support and the Serial API were really nice additions to the DiveIno feature list. These features mostly support third party integration and the development of the dive computer. How this can be further improved? What is the biggest pain point right now in DiveIno usage?

I think the answer is the required wired connection. Up until now DiveIno has to be connected to a desktop PC through an USB cable to be able to manage and download the data from it. Wireless connection possibility obviously offers much more flexibility and broader connection capabilities. Based on these I decided this will be the next improvement area, where new features will be introduced in the future. The first step on this road is to make the Serial API connection wireless. It means to add Bluetooth Low Energy (BLE) access capability to the Serial API.

Additional hardware

By default DiveIno doesn’t support Bluetooth connection on the hardware level. It means that a new module has to be connected to the microcontroller board in order to provide BLE connection capability. I decided to use the Adafruit Bluefruit LE UART Friend - Bluetooth Low Energy (BLE) module because of the following reasons:

  1. It is affordable
  2. It is supported by Adafruit
  3. It works with Android, Windows and iOS operating systems
  4. I had some experience with it - see this blog post
  5. The Adafruit Bluefruit LE Connect app provides a nice way to monitor the Bluetooth connection

This module can be easily attached to the Arduino microcontroller board. The power pins and the UART RX-TX lines have to be connected. Such a setup can be seen below:

Software changes

On the software side first of all the Adafruit BluefruitLE nRF51 library has to be imported into the DiveIno project. The Bluetooth module configuration can be found in the BluefruitConfig.h header file.

Since the Bluetooth capability is an optional feature, it can be turned on and off on the DiveIno sketch level:

1
2
3
4
5
6
7
8
9
10
11
12
// Manage Bluetooth support based on the Adafruit Bluefruit LE UART Friend module
// 0 = Module is not present - Bluetooth was turned off
// 1 = Module is connected - Bluetooth is supported
#define BLUETOOTH_SUPPORTED 1

#if BLUETOOTH_SUPPORTED
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"

Adafruit_BluefruitLE_UART ble(Serial1, BLUEFRUIT_UART_MODE_PIN);
#endif

If the Bluetooth support is turned on, DiveIno is able to listen for incoming Serial API request on the Bluetooth channel and of course can respond to it.

Test Bluetooth connection

In order to test the Bluetooth Serial API support, the Adafruit Bluefruit LE Connect app will be used. After the installation the first step is to open it:

The nearby Bluetooth Low Energy capable devices will be listed - including DiveIno! The next step is to click onto the Connect button:

When DiveIno is attached to a PC with an USB cable, the standard UART serial communication channel gets used by the Serial API. Fortunately the Adafruit Bluefruit LE UART Friend module can provide such an UART channel through the wireless Bluetooth connection. This means that the UART mode has to be selected in the list below:

Congratulations, now you are connected to your DiveIno wirelessly over a Bluetooth UART connection! All you have to do is to type in some Serial API commands and send it to DiveIno for further processing. Let’s try to obtain first the current DiveIno version number:

Bluetooth support was added to DiveIno from version 1.4.0, so hopefully you can see a similar response on the screen:

Obviously all Serial API features are available through Bluetooth. For instance the current temperature, pressure and date information can be retrieved:

As a bonus you can retrieve the current settings in json format!

Contents
  1. 1. Additional hardware
  2. 2. Software changes
  3. 3. Test Bluetooth connection