Contents
  1. 1. Parts
  2. 2. Assembly
  3. 3. Programming
  4. 4. Communication API
  5. 5. Connect

It would be really cool to expose physical sensor data to mobile phones for further consumption. For instance imagine a sensor, which can measure pressure, temperature and humidity information. If this sensor can be connected wirelessly to an app running on a mobile device, a portable weather station can be created.

The sensor bundle has to be self sustained. It has to run on battery. This means that the battery charge level has to be exposed to the connected mobile device in order to be able to track, if recharge is necessary.

Regarding wireless connection there are many possibilities:

  1. Bluetooth Low Energy
  2. WiFi
  3. Infrared
  4. XBee

From this list Bluetooth LE and WiFi seems to be the two viable alternatives. From now on I will focus only on Bluetooth LE, just to keep things simple in the reference implementation example covered in this blog post.

Parts

The wireless sensor bundle is built up from the following parts:

  1. Adafruit Feather 32u4 Bluefruit LE
  2. SparkFun Pressure Sensor Breakout - MS5803-14BA
  3. SPDT Slide Switch
  4. Half size breadboard
  5. Breadboard wires
  6. Lithium Ion Polymer Battery - 3.7v 1200mAh

The key part is the Adafruit Feather 32u4 Bluefruit LE microcontroller board. It provides a nice Arduino compatible programming interface and Bluetooth LE connectivity. A LiPo battery can be connected to it. The board can measure its current voltage level. From this information and the battery characteristic, the charge level can be calculated.

Assembly

Based on the following Fritzing diagram the sensor bundle components can be easily wired togerher.

It will look similarly in real life:

Programming

The Arduino sketch, which makes the board work, can be found in the BleSensorRemote GitHub repository.

Besides the initial setup and sensor data retrieval capabilities, it provides a Communication API. This API can be used to retrieve the sensor data from the connected mobile device.

Communication API

The following keywords can be sent from the connected device to the sensor bundle over Bluetooth:

  • @TEMP# - Ask for the current temperature
  • @PRES# - Ask for the current ambient pressure
  • @BAT# - Ask for the current battery charge
  • @ALL# - Ask for all information

A sample communication flow is described below:

1
2
3
4
5
6
7
8
9
10
11
IN  <-: @TEMP# - Ask for the current temperature
OUT ->: @23.4# - The temperature in celsius

IN <-: @PRES# - Ask for the current ambient pressure
OUT ->: @1010.3# - The pressure in millibar

IN <-: @BAT# - Ask for the current battery charge
OUT ->: @4.14# - The current battery charge in volts

IN <-: @ALL# - Ask for all information
OUT ->: @1009.80,26.07,4.32# - The pressure in millibar, the temperature in celsius and the battery charge in volts

Connect

The communication with the sensor bundle can also be tested with the Adafruit Bluefruit LE Connect app:

Contents
  1. 1. Parts
  2. 2. Assembly
  3. 3. Programming
  4. 4. Communication API
  5. 5. Connect