SensoDuino: Log and Transmit Android Sensors to Arduino & PC via Bluetooth
Think of SensoDuino as a dozen or more free virtual shields for your Arduino each supporting a different sensor and function. All you need is your Android phone, Arduino, and a $10 HC-05 Bluetooth module. SensoDuino captures data from sensors built into your Android mobile device such as GPS, audio, gyro, date/time then transmits this data over an HC-05 Bluetooth module to Arduino or any device equipped with Bluetooth capabilities be it Windows PC, Mac, or microcontroller.
This app has been tested and designed for the HC-05 Serial Bluetooth module. Other Bluetooth modules may or may not work.
SensoDuino is a free Android application that captures data from sensors and functions built into your Android mobile device then transmits the data over the HC-05 Bluetooth modul to Arduino or any device with serial Bluetooth capabilities such as a Windows PC, Mac, or Bluetooth equipped microcontroller. SensoDuino also saves the captured data to a comma-delimited text file. SensoDuino can be downloaded from Google Play only.
You can also set the frequency of sensor data reading, transmitting, and logging (subject to the specifications of the sensor vendor.)
SensoDuino eliminates the need for USB Host hardware for your phone or Arduino. For Arduino or microcontroller, you only need a $10 HC-05 Bluetooth module.
Save over $200 in sensors and parts for your Arduino or microcontroller project, if you already have a mid-range Android device such as my Samsung Galaxy II Plus. See section titled: Android: A Capable Electronics DIY Platform.
NOTE: Because SensoDuino is updated and improved on a regular basis, screen captures and videos may look different from those of the latest version, but the concept is the same.
PROJECTS BASED ON SENSODUINO
Bluetooth-controlled Pan/Tilt Servo Platform Using Android (SensoDuino) & Arduino
IR Remote Control Station for SensoDuino
SensoDuino recognizes the following Android sensors: GPS, Orientation, Gravity, Rotation Vector, Gyroscope, Accelerometer, Linear Accelerometer, Magnetometer, Light Level, Audio Level, Proximity, Pressure, Temperature, Relative Humidity, and Time & Date.
Some software (virtual) sensors relay on the presence of hardware sensors to function. For example, the gravity sensor, linear acceleration sensor, and rotation vector sensor all of these software sensors relay on the presence of hardware gyro sensor on your Android device to function.
SensoDuino also features an Android sensor scanner that lists hardware and software sensors supported by your Android device as well as key sensor specifications such as max power consumption, resolution, vendor, etc.
WHAT CAN YOU DO WITH SENSODUINO
With the help of Arduino or other microcontrollers, SensoDuino can be used in robotics and UAV guidance. Its support for 12 motion and environment sensors covers a wide range of sensory feedback. Also, SensoDuino can be used for logging. The ability to set the speed of logging from 10Hz to once every 10 minutes allows for high-speed as well as time-lapse logging of sensor readings.
Special thanks to colleagues from PIN13 Protospace who helped with testing, usability, guide review and proofreading. Mainly, I wish to thank Jafar Quttaineh for his detailed product testing and for his invaluable insights and feature suggestions. Also thanks to Mujahed Al-Tahle for his detailed analysis and testing of the product and guide.
How to Use SensoDuino
SensoDuino is very simple to use. Basically you have rows of sensor names (number of sensors may change in the future). Each sensor has three checkboxes next to it labeled On, Tx, and Log.
You can control the speed of sensor reading from the Preferences menu. You have a choice between 100 millisecond (10 Hz) to 10 minutes. The speed of the sensor is subject to the limits of the vendor specifications. Most GPS sensors today generate location data once per second (1 Hz). Some GPS modules generate location data 10 times per second (10 Hz). On the other side of the speed spectrum, some sensors generate readings over microseconds.
Motion sensors (gyro, accelerometer, magnetometer) are sensitive to environmental conditions such as presence of magnetic field or slight physical vibrations. So even when your phone is placed on a flat stationary surface, you will still see changes in sensor reading affecting mostly the least significant digits. The least significant digits of motion sensor readings may produce more data than you need for your application. Your application requirements should determine how many digits will be truncated or kept.
SensoDuino is a power-hungry app. Between active sensors, Bluetooth transmission, logging to device storage, and keeping your device awake so as not to interrupt sensor readings, you are bound to drain your battery.
For prolonged use of SensoDuino, an additional power source should be considered either in the form of power brick, solar/wind energy, or power outlet if one is available.
There are many tips on the web on how to conserve your mobile device's battery power that could extend your SensoDuino logging time significantly.
For example, enabling Airplane Mode on you device can save battery power. Different vendors use different names for Airplane Mode such as In-Flight Mode.
Wiring the Arduino to the HC-05 Bleutooth
To take advantage of SensoDuino out of the box, you don't need anything. You can start logging sensor readings to a text file then process the logged data with myriad graphing and data analysis tools. But if you see the added value in wirelessly transmitting sensor readings over Bluetooth to a microcontroller or PC, you should get the HC-05 Bluetooth serial module.
The HC-05 package comes in two flavors, SMD and breakout board versions. Both can be purchased for less than $10 from ebay. I strongly recommend buying the HC-05 with the breakout board to avoid unnecessary soldering and debugging headaches and to take advantage of useful features included with the breakout board such a status LED that blinks in patterns to show if the HC-05 is paired, connected, in command mode, or not even powered.
The breakout board has a 3.3V regulator which can convert Arduino's incoming 5V power but you still have to drop the Arduino's 5V pins down to 3.3V. The simplest way is a voltage divider from two resistors but you can use a level shifter such as the CD4050 level shifter IC.
I use 2K & 1K resistors as voltage divider to drop the Arduino's 5V TX pin to 3.3V, which is the operating voltage of the HC-05 pins. You have to do this to protect the HC-05 3.3V RX pin. On the other hand, the Arduino 5V RX pin can handle the 3.3V sent from the HC-05 TX pin. Even if the HC-05 worked without the voltage divider, there's no telling for how long.
TO UPLOAD A SKETCH TO ARDUINO YOU MAY HAVE TO REMOVE THE POWER FROM THE HC-05 MODULE TO AVOID ANY CONFLICT OVER SERIAL. Alternatively, you can wire the HC-05's TX/RX to different Arduino pins supported by Arduino's SoftwareSerial library.
Transmitting from SensoDuino to Arduino
SensoDuino can transmit sensor readings to an Arduino with the HC-05 Bluetooth module. Other comparable Bluetooth modules may work as-is or require changes to their default settings.
The attached Arduino sketch "sensoduino.ino" reads data transmitted by SensoDuino over Bluetooth then parses and converts this data from strings to numeric values ready for utilization in your Arduino application be it robotics control or UAV navigation or sensor logging.
The process of connecting SensoDuino to Arduino is simple.As with all Bluetooth communication you must pair your Android device with the HC-05 Bluetooth module attached to your Arduino. You only need to do the pairing once.
I have published a project that illustrates how use SensoDuino and Arduino to control a pan/tile servo platform using your Android phone's Accelerometer sensor.
Pairing and Establishing a Serial Connection between Windows 7 and SensoDuino
Pairing Bluetooth devices is a very basic task. On Windows 7 (or similar OS) opening serial over Bluetooth involves one additional step and that is assigning a virtual COM port to the Bluetooth connection between Windows and SensoDuino. More often than not, this is done behind the scenes and the user does not have to worry about it. But if you like to debug your Bluetooth connection to SensoDuino, you may need some basic details of what takes place when connecting serial over Bluetooth.
NOTE: To debug the Bluetooth connection, make sure SensoDuino is running with one sensor enabled and transmitting (check Tx checkbox for that sensor) at slow speed.
For testing the Bluetooth connection between SensoDuino and Windows PC, I use Tera Term. You don't have to but it's a robust terminal emulation software that helps me test serial connections either Bluetooth or wired. You can download the latest Tera Term from here: http://ttssh2.sourceforge.jp/index.html.en If you see garbage on the screen after you established a connection, match the baud rate for both Bluetooth devices.
The data you will see on the terminal emulator console may not be neat looking but it's properly formatted for the C++ and C# utilities as well as for the Arduino sketch to consume.
Let's start by establish a pairing between the Bluetooth on your Android device and your computer's Bluetooth. Once you do this step successfully, we can move to the next stage.
Capturing SensoDuino Data on Windows PC using C++ and C# over Bluetooth
I am attaching two skeletal programs in C++ "main.cpp" and C# "Program.cs" that will serially send and receive data to and from Arduino and SensoDuino either over wired serial or Bluetooth serial.
These two programs were extracted and modified from sample code published by the Microsoft Developer Network. The programs are simple, robust, and can handle reasonably high data transmission speeds.
For one test, I enabled all SensoDuino sensors at the highest speed and could not detect significant loss in data transmission. I used a Samsung Galaxy S2 Plus and re-configured my HC-05 Bluetooth baud rate to 115200. Results may vary depending on your Android phone and Bluetooth module.
To modify your HC-05's default baud rate and other settings, refer to the section titled Boost Your Bluetooth Transmission Speed.
I have tested both utilities on my Windows 7 workstation using the free Microsoft Developer Express 2012 which you can download for fee from Microsoft. You can easily modify this code to add functionality such as graphing, logging to hard disk, and sharing sensor data with other applications and users.
ESTABLISH THE CONNECTION
I have included an instructional video to explain the steps below. Make sure you have paired your Windows PC Bluetooth with your Android Bluetooth first. Let's install and run the C++ sample program:
If the connection does not work the first time, stop the C++ application. Exit SensoDuino. Launch SensoDuino again then run the C++ program. Sometimes when SensoDuino sends too much serial data to the serial buffer, the C++ program chokes on it. So make sure you sync running SensoDuino and the C++ program. If you see garbage on the C++ console, adjust the baud rate.
Additional programming will be needed for the C++ and C# programs to parse the incoming SensoDuino strings into floats and integers per your requirements.
Log SensoDuino Data to File Then Import into Excel
SensoDuino logs data to a comma-delimited text file with a format that's consistent across all sensor data which means ease of importation into application such as Excel or other analytical and charting tools.
The logged sensor readings follows this format:
SENSOR TYPE (string)
SERIAL COUNT (integer)
FIRST VALUE OR X (float)
SECOND VALUE OR Y (float)
THIRD VALUE OR Z (float)
Units of Sensor Readings
In the list of official Android sensors below I have retained the sensor name and number as listed by the Android SDK SensorManager. For Audio (mic) and GPS, which are not part of the Android SDK SensorManager family, I have assigned my own numbering and naming scheme starting from 99 downwards.
OFFICIAL ANDROID SENSORS
1- ACCELEROMETER (m/s^2 - X,Y,Z)
2- MAGNETIC_FIELD (uT - X,Y,Z)
3- ORIENTATION (yaw, pitch, roll)
4- GYROSCOPE (rad/s - X,Y,Z)
5- LIGHT (SI lux)
6- PRESSURE (hPa millibar)
7- DEVICE TEMPERATURE (C)
8- PROXIMITY (Centimeters or 1,0)
9- GRAVITY (m/s^2 - X,Y,Z)
10- LINEAR_ACCELERATION (m/s^2 - X,Y,Z)
11- ROTATION_VECTOR ( X,Y,Z)
12- RELATIVE_HUMIDITY (%)
13- AMBIENT_TEMPERATURE (c)
14- MAGNETIC_FIELD_UNCALIBRATED (uT - X,Y,Z)
15- GAME_ROTATION_VECTOR ( X,Y,Z)
16- GYROSCOPE_UNCALIBRATED (rad/s - X,Y,Z)
17- SIGNIFICANT_MOTION (1,0)
UNOFFICIAL ANDROID SENSORS
97- AUDIO (Volume in generic units)
98- GPS1 (Lat., Long., Alt.)
99- GPS2 (Bearing, Speed, Date/Time)
ANDROID SENSORS CATEGORIES
The Android platform supports three broad categories of sensors:
These sensors measure acceleration forces and rotational forces along three axes. This category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.
These sensors measure various environmental parameters, such as ambient air temperature and pressure, illumination, and humidity. This category includes barometers, photometers, and thermometers.
These sensors measure the physical position of a device. This category includes orientation sensors and magnetometers.
For a detailed reference to Android sensors start here:
Boost Your Bluetooth Transmission Speed
SensoDuino reads and transmits data for 12 sensors at speeds ranging from 1 Hz to 10Hz (sensor reading speed will increase in future releases.) Most of the supported sensors send X,Y,Z data in floats converted to characters for serial communications. That's lots of data being processed, saved, and transmitted.
I doubt many application will require all SensoDuino sensors transmitting full throttle concurrently but it may be advantageous to configure the HC-05 Bluetooth module (or your Bluetooth module) for the highest practical baud rate.
You have to experiment until you decide which speed is acceptable to you. I have published a guide on how to change the settings of the HC-05 in preparation for SensoDuino increased bandwidth requirements. Follow any of the two links below for detailed how-to instructions to change the HC-05 configuration.
Modify The HC-05 Bluetooth Module Defaults Using AT Commands:
Android: A Capable Electronics DIY Platform
If you buy all the sensors supported by SensoDuino separately to go with your Arduino project from some of the well-known stores, you could pay over $200. If you have an Android phone why not use its built-in sensors. And since Android is the most popular phone in the world today, it's a ready and capable DIY platform.
Even the newer SoC ARM boards being introduced today by top DIY vendors can't match the overall price, performance, and built-in features and integration of a mid-range Android phone.
Here's a breakdown of the costs when you buy sensors and parts supported by SensoDuino and included in most Android phones:
ITEM / COST
Light Sensor $5
Audio Sensor $5
Display & Input $20
SD card $10
Open Source Dev Tools $0
CUSTOMS TARRIF: Varies
Feedback & Bug Reorts
There are two ways to contact me regarding bugs and feature requests via SensoDuino.
SensoDuino is equipped with a Crash Reporter from ACRA. When the app crashes it will open up a dialog box and prompt you for permission to send me the crash report, next time you connect to the internet and run SensoDuino.
The ACRA crash reporter will send me technical info about your device such as Android version, app version, phone model, technical specs, stack info, etc to help me identify the source of the crash so I can fix the bug. You can also enter a comment to send to me from the crash report dialog box.
From the action menu of SensoDuino, select Preferences. At the bottom of the list of sensors, there's a Feedback form that you can use to send me your comments and suggestions. You need to be connected to the internet.
For general inquiries, please use my contact form on this website.
Android SDK | Sensors Overview
Android SDK | Position Sensors
Android SDK | Motion Sensors
Android SDK | Environment Sensors
Android SDK | Location Sensor
Sensor Fusion on Android Devices
- ArduDroid: Simple Bluetooth control for Arduino and Android
- TV Volume Loudness Guard
- Geo Data Logger
- Face Tracking with Arduino and OpenCV
- Kinect Controls Servos Using Human Motion
- Fast Line-following Robot
- Universal IR Remote Control Station for Android
- Bluetooth-controlled Pan-Tilt Servo
- Modify The HC-05 Bluetooth Module Defaults Using AT Commands
- Bluetooth Comm for Arduino and PC
- GOduino: The Breadboard-friendly Robot Controller
- How to Network Many Arduinos with Sensors using I2C
- Your Android Phone Is A Sensors & Comm Nervana