- Nov 23, 2013: SensoDuino 0.160 gets a face left.
- Nov 19. 2031: OPINION: The Amazing Synergy Between Arduino & Android.
- Nov 19, 2013: SensoDuino 0.159 is out. Android phone date (y,m,d) and time (h,m,s) are supported as sensors. Support for Android KitKat (4.4/API 19).
Think of SensoDuino as having over a dozen virtual shields for your Arduino each providing a function or feature such as GSM, GPS, Gyro, etc but without having to stack or wire these components. SensoDuino is a free Android application that captures data from sensors built into your Android mobile device then transmits the data over the HC-05 Bluetooth module to Arduino Uno 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. This app has been tested and designed for the HC-05 Serial Bluetooth module. Other Bluetooth modules may or may not work. Please refer to comments by users who tried other Bluetooth modules with this app.
You can install SensoDuino from Google Play only.
You can control the frequency of sensor data reading, transmitting, and logging (subject to the specifications of the sensor vendor.) This is my second Android app for Arduino Uno. You might also be interested in my first app Andruino which is a simple 2-way Bluetooth-based Android controller for Arduino Uno.
SensoDuino eliminates the need for USB Host hardware for your phone or Arduino Uno. For Arduino Uno or microcontroller, you only need a $10 HC-05 Bluetooth module (or equivalent).
Save over $200 in sensors and parts for your Arduino Uno 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.
SensoDuino recognizes the following Android sensors: GPS, Orientation, Gravity, Rotation Vector, Gyroscope, Accelerometer, Linear Accelerometer, Magnetometer, Light Level, Audio Level, Proximity, Pressure, Temperature, and Relative Humidity.
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 will list hardware and software sensors supported by your Android device as well as key sensor specifications such as max power consumption, resolution, vendor, etc. Some Android devices have duplicate sensors from different vendors. The Android SDK will return the default sensor.
- Reads Android sensors.
- Saves sensor readings to comma-delimited text file.
- Transmits readings in ASCII comma-delimited format via Bluetooth.
- Lists your Android device's built-in sensors both hardware and software (virtual sensors).
- Set speed of sensor data capturing, logging, and transmission from 100 milliseconds to 10 minutes (subject to sensor limits).
- Keeps track of accuracy for logged sensor readings and provide visual clues for inaccurate sensor data.
- Geo-tags sensor readings using your Android device GPS.
- Optimized for speed of operation and transmission.
- Keeps device awake to prevent loss of sensor data logging.
- Scan and list available sensors in your device and their specifications.
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.
PROJECTS BASED ON SENSODUINO
Bluetooth-controlled Pan/Tilt Servo Platform Using Android (SensoDuino) & Arduino
IR Remote Control Station for SensoDuino
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.
PLEASE RATE ON GOOGLE PLAY
This is a free app and only through your ratings can I determine if it's worth supporting or discontinuing.
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: How to Use SensoDuino
- ON: The first checkbox turns the sensor On or Off which means SensoDuino is either reading this sensor or not.
- TX: The second checkbox when enabled, SensoDuino will transmit the associated sensor readings via Bluetooth to any paired and connected Bluetooth serial device.
- LOG: When the third checkbox is checked, the associated sensor readings are logged to a comma-delimited text file named "sensoduino.txt" in the root of your Android's SD card.
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.
Step 2: Wiring the Arduino to the HC-05 Bluetooth
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.
CONVERTING 5V TO 3.3V
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. This is 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 works without the voltage divider, there's no telling for how long.
UPLOADING ARDUINO SKETCHES
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.
Step 3: Transmitting From SensoDuino to Arduino
SensoDuino can transmit sensor readings to an Arduino via 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.
Please refer to previous step regarding how to resolve errors when uploading a sketch while your Arduino pins 0 and 1 are connected to the HC-05 Bluetooth module.
Step 4: Pairing and Establishing a Serial Connection Between Windows 7 and SensoDuino
To simplify debugging the HC-05 Bluetooth connection, make sure SensoDuino is running with only one sensor enabled and transmitting (check Tx checkbox for that sensor) at slow speed preferably once per second.
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 attached C++ , C# and the Arduino skeletal programs 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.
- Check to make sure Bluetooth is set to Discoverable on your Android device.
- Check to make sure Bluetooth is enabled on your Android device.
- Run SensoDuino.
- To test the setup, enable the Orientation sensor and enable its Tx (transmit) checkbox and bring down the transmission rate to 1 per second, from the preferences menu.
Step 5: Capturing SensoDuino Data on Windows PC Using C++ and C# Over Bluetooth
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:
- Download the attached "main.cpp" and save it to your computer.
- Download and run Visual Studio Express 2012.
- Select New Project.
- From Templates, Select Visual C++ CLR Empty Project (call it SensoDuino).
- From Solution Explorer, right-click on project name, not solution name.
- Select Add Existing Item then pick the file main.cpp from Step 1.
- Run SensoDuino and make sure you select only one sensor to transmit at 1 reading second. You can increase speed and add sensors later.
- Run the C++ program.
- A console for the C++ program will open up and it will prompt you to enter the COM port you wish to communicate with.
- Enter the COM port assigned to your Bluetooth SensoDuino.
- You should see a stream of numeric data showing up on your C++ application console each made up of comma-delimited numbers representing sensor information such as type, count, and raw sensor readings, reading accuracy.
Additional programming will be needed for the C++ and C# programs to parse the incoming SensoDuino strings into floats and integers per your requirements.
Step 6: Log SensoDuino Data to File Then Import Into Excel
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)
Step 7: About Android Sensors
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:
Step 8: Boost Your HC-05 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:
Step 9: 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.
Step 10: 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 with many Android phones:
ITEM / COST
Light Sensor $5
Audio Sensor $5
Display & Touch Input $20
SD card $10
Open Source Dev Tools $0
CUSTOMS TARRIF: Varies
Step 11: Resources
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
Participated in the
flefevre made it!