In recent years, portable sensor devices have gained a lot of popularity due to their ability to give you instant, accurate information about your local environment. Some of these devices include the Sensordrone, Smart Citizen, and the Storm Tag. These devices combine portability and accessibility in such a way that they're easy to use and convenient to carry around. However, they can be expensive, as they're required to pack quite a bit of advanced technology into a very small package.
This Instructable is for my Bluetooth Low Energy Go-Anywhere Sensor Pack (BLEGASP, if you will). It's a device that I built from an Arduino and various environment sensors. Since environmental concerns differ from person to person, I wanted to create a device that maximizes sensor modularity. And so were born the objectives for this project:
In order to accomplish these objectives, I decided that the communication should take place via Bluetooth Low Energy (Bluetooth LE, or BLE). Bluetooth LE, also known as Bluetooth Smart, is a wireless technology that's designed to allow effective communication between compatible devices while providing a significant reduction in the power consumption of those devices as compared to Classic Bluetooth.
The sensor pack that I built can report seven different quantities about the environment. These are temperature, relative humidity, heat index, barometric pressure, visible light intensity, infrared (IR) light intensity, and ultraviolet (UV) index. In this Instructable, I'll show you how to build the sensor pack that I built, program the Arduino with the sketch that I wrote to control it, and use the Android app that I wrote to communicate with it.
Thanks to master of digital image creation and modification burstolava
Step 1: Get Materials
Step 2: Connect the Bluetooth Low Energy Module
Connect the BLE Module Breakout Board
Using your breadboard, connect the nRF8001 breakout board to the Arduino as shown in the schematic. This board is made by Adafruit Industries, and I used Adafruit's Arduino library for controlling it. The library is in the lib/ directory of my GitHub repository. Copy this library into your Arduino sketchbook/libraries/ directory so that the Arduino software can find it.
At this point, you can already test out your Bluetooth LE connection! Here's how:
If you're interested in learning more about Bluetooth Low Energy, Adafruit has a useful introduction to the technology. You can also check out the official Bluetooth Developer Portal and Android's BLE guide.
The breakout board for this Bluetooth LE module simulates a UART device to make it easy to send and receive data. There's plenty of information about UART and how it works on the UART Wikipedia page.
The nRF8001 breakout board uses a SPI bus to communicate with the Arduino. If you're not familiar with this bus, the Wikipedia page is a useful resource.
Step 3: Connect the Temperature and Pressure Sensor
Connect the BMP180 Breakout Board
Connect the BMP180 breakout board as shown in the schematic. The board is made by SparkFun Electronics. I used their Arduino library to make measurements. Copy this library from the lib/ directory of my GitHub repository to your sketchbook/libraries/ directory.
The BMP180 sensor can function as either a barometric pressure sensor or as an altimeter, to measure altitude. I used it as a pressure sensor. When measuring pressure, though, you need to first measure temperature, and the sensor returns the absolute pressure. Absolute pressure varies with elevation, so we need to compensate for its effects. SparkFun's library includes a way to do this, but it requires that the Arduino knows our elevation. You'll need to change the ALTITUDE constant defined in the code you're using.
Test the Temperature and Pressure Readings
Testing this sensor is straightforward enough. Here are the steps:
This board uses an I2C bus to communicate with the Arduino. If you're not familiar with this bus and want to learn about it, check out learn.sparkfun.com/tutorials/i2c/all and www.i2c-bus.org. There is also a good introduction to both I2C and SPI interfaces here.
Step 4: Connect the Relative Humidity Sensor
Connect the DHT22 Humidity Sensor
Connect the DHT22 humidity sensor as shown in the schematic. This sensor can also function as a temperature sensor. It can take both temperature and humidity readings every 2 seconds. Since I already had a temperature sensor on the BMP180 from Step 3, I didn't use the temperature sensor functionality here.
The Adafruit library for the DHT22 is in the lib/ directory of my repository. Just like the previous step, copy it from there to your Arduino sketchbook/libraries/ directory.
Test the Humidity Readings and Heat Index Calculations
The Adafruit library for the DHT22 sensor provides an easy way to read both temperature and relative humidity. The library can also perform a calculation of heat index. Heat index is a measure of how hot it feels due to the effects of both temperature and humidity. You can test these three values with the example sketch provided in the library directory. Here's how:
Step 5: Connect the Light Sensor
Connect the Si1145 Light Sensor
Connect the Si1145 breakout board as shown in the schematic. The board is made by Adafruit, and I used their Arduino library for controlling it. The library is located with the other Arduino libraries in the lib/ directory of my GitHub repository. This board uses the I2C bus to communicate with the Arduino, just like the BMP180 barometric pressure sensor from Step 3.
Testing the Readings
The test sketch included with the Adafruit Si1145 library provides an easy way to test the sensor. Here's how:
When measuring visible light intensity and infrared light intensity, the library is written to provide relative values. You'll get an idea of how much light there is hitting each photodiode, but you won't get measurements in lux.
UV index is a measurement of the strength of UV radiation. It provides an easy way to tell how much exposure you are getting to UV radiation at a specific place and time.
Step 6: [Optional] Bypass Arduino's On-Board Regulator
Arduino Uno 5V Regulator
The Arduino Uno uses a linear voltage regulator to provide its 5V power from an external input. In general, though, linear regulators are very inefficient. The efficiency of a linear regulator is usually well below 50%.
Since one of the goals of this project was to make the sensor pack as portable as possible, I decided to bypass the on-board linear regulator for a more efficient option. This provides better battery life for the sensor pack. I used an LM2825N 5 volt buck switching regulator as the 5V regulator. I ordered this part as a free sample from Texas Instruments. According to its datasheet, which is included in the doc/ref/ directory of my GitHub repository, its efficiency is typically about 80%. Much better!
Connect the LM2825 Buck Converter
If you want to bypass the on-board regulator like I did, connect the buck converter as shown in the schematic. Each of the outputs on pins 4-8 will provide 5 volts as long as the input is a high enough voltage. I used a 9V battery as the input.
Arduino specifically advises against bypassing the on-board regulator. Please be careful when connecting this part of the circuit. If you connect a wire to the Arduino's 5V input, and the wire voltage is not 5V, there is a chance that you will irreparably damage your Arduino board. I strongly recommend using a voltmeter to test the voltage at the output of your regulator and make sure it's 5V before connecting it to the Arduino.
If you decide that you don't want to use the buck converter, using the on-board regulator is very easy. To use it, connect your battery to the Vin pin-not the 5V pin-on the Arduino board. As long as your voltage source is between 7V and 12V, you'll be perfectly fine.
For portable devices such as this one, battery life is an important factor. Using the external LM2825 buck converter, I've estimated the battery life of my completed project. To do this, I measured the current draw from the battery while the sensor pack was advertising its existence over Bluetooth LE. I measured 43.5mA. According to this Wikipedia page, a standard alkaline 9V battery has a capacity of about 565mAh. Drawing 43.5mA, this gives us a battery life of
565mAh / 43.5mA = 12.99 hours
So, advertising continuously, we'd get about 13 hours of battery life. Not too bad for a single 9V battery!
I didn't measure current consumption for other Bluetooth LE states. The current draw would probably be different, so any communication with other BLE capable devices would affect battery life in some way.
Step 7: Verify Connections
Check Your Connections
If you've successfully done the tests for all of the sensors and the Bluetooth LE module, you can safely skip this step.
Otherwise, you should check the connections to protect against damaging something. You should make sure that:
Step 8: Download Arduino Code
All of the Arduino libraries are available in the lib/ directory of my GitHub repository. Once you've downloaded them, put them all in your Arduino's sketchbook/libraries/ directory so that the compiler can find them.
All of the Arduino code required for this project is available at my GitHub repository. The main Arduino project file is BLE_sensor_pack.ino. Inside this file, update the constant REF_ALTITUDE_FT with your elevation in feet. Again, you can find your elevation at veloroutes.org/elevation/. Upload this sketch to your Arduino once you have the libraries in place.
Step 9: Download Android App and/or Code
I wrote a BLE Sensor Pack app for Android devices. Bluetooth LE is only supported on Android 4.3 or later, so your device must adhere to that requirement in order to install it. The first screen is a screen with a connect button on it. When you hit 'Connect', the app attempts to find the sensor pack. If it finds it, it brings you to the next screen. In addition to the buttons at the bottom, pressing the sensor row will toggle that sensor's state.
This app works specifically with the sensor pack that I'm describing in this Instructable. Since it's so specific to the device, I've decided not to put it on the Google Play Store. The Android application package file (.apk extension) is in the app/ directory of my GitHub repo. There are several ways to install it. I emailed it to myself as an attachment, and opened the email with my Android device. It then asked me if I wanted to install the app.
Note: you may have to enable installation of apps from unknown sources on your device by going to Settings - Security and checking Unknown source.
Step 10: Test BLE Sensor Data Communication
Now that you have the circuit put together on a breadboard, the Arduino programmed, and the Android app installed, it's time to see the whole system in action!
You can use a battery here, but I recommend using a USB cable to power the Arduino at this step. That way, you can monitor the Arduino's state on the serial monitor.
Step 11: Solder the Stackable Headers
Now that we have a working system on a breadboard, it's time to make it smaller and much more portable!
Solder the Stackable Arduino Headers
Step 12: Assemble the Shield
Solder the Pin Headers and 24-pin Socket
I always try to avoid soldering parts like breakout boards and ICs directly into my circuit. Applying heat with a soldering iron directly to the pins can damage the board or chip. Instead, I suggest using female pin headers and IC sockets. This way, you can avoid damaging your components and make it possible to reuse them in the future without desoldering them first.
Solder the Connections
Using the full schematic as a reference, solder everything together with wire. Don't forget to include the pull-up resistor and the capacitor.
Plug in the Components
Connect the components to the correct pin headers and IC socket. Be careful to connect them in the correct direction for your soldering. A quick test is to match up the voltage supply and ground pins. If they're okay and you're soldering is good, all the other connections should be correct.
Step 13: Put it all Together
Now that you've assembled the shield, it's time to test the finished product! The testing process is very similar to the testing in Step 10. Again, I recommend that you not connect a battery just yet. Instead, use a USB cable connected to your computer. Watch the serial monitor as you play around a bit with the Android app, turning various sensors on and off.
If everything works, great! If not, you'll have to debug the circuit. The Arduino serial monitor is your best friend here. Look at what is being printed, and possibly add your own Serial.print statements to see what's working and what isn't. Look at the solder joints that you made on the board, and try to find something that's wrong. Look for short circuits and loose wires. If you can't find the problem, use a multimeter to check connections and voltages at various points in the circuit.
Once everything has been tested, you have a working portable Bluetooth LE sensor pack and Android app! Congratulations!
Step 14: Customize!
Make it Your Own
I really like this project because it has so much potential for customization. It's as modular as I could make it, so you can add your own capabilities. What do you want it to do? Add that on!
Here are just a few ideas for how you could build on this project and make improvements:
The buck switching regulator that you added in Step 6 will allow you to drastically reduce power consumption of the Arduino while it's in sleep mode. Put it in sleep mode for some amount of time every loop and watch your power consumption drop! Obviously it can't always stay asleep, since it has to communicate with Bluetooth LE devices.
The Android development website provides great tutorials and documentation for Android app development. Get into it and turn the BLE Sensor Pack app into your own vision!
There are so many different sensors out there that you can add to this project! The Arduino has plenty of analog and digital I/O pins, and has hardware and libraries for handling buses like I2C and SPI. This makes it easy to add on nearly whatever you want.
Maybe you want your Android device to be able to control your window blinds through the Arduino and stepper motors. Maybe you want to be able to set a cooking timer and have the Arduino send you a notification through your Android device when your meal is finished cooking. Build off of this project and add whatever components you want to realize your idea.
Whatever you decide to build, make it awesome. Good luck!