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:
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.
The wireless sensor bundle is built up from the following parts:
- Adafruit Feather 32u4 Bluefruit LE
- SparkFun Pressure Sensor Breakout - MS5803-14BA
- SPDT Slide Switch
- Half size breadboard
- Breadboard wires
- 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.
Based on the following Fritzing diagram the sensor bundle components can be easily wired togerher.
It will look similarly in real life:
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.
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:
IN <-: @TEMP# - Ask for the current temperature
The communication with the sensor bundle can also be tested with the Adafruit Bluefruit LE Connect app: