Saturday, December 20, 2014

DroidX displays sensor data from Arduino Yun 

Arduino Yun + ATTINY85 + RFM12B
Recently I built some sensor nodes using RFM12B transceivers and attiny85's. The receiver is an Arduino Yun and RFM12B saving the sensor node data to the Yun's sdcard. The Sensor nodes are working better than expected running off 3.7v batteries and taking advantage of the attiny85 power management features. I've been running these sensor nodes for several months using LED's as alarms that turn on/off LED's or send an email based on constraints coded in the Arduino Yun receiver sketch. It works great, but a decent display would be a nice touch for this project.


Using an Android Display
I have a few older cell phones lying around, and one of them is a Motorola DroidX. The purpose of the app will be to simply display data regarding the various node sensors I have around the house. I also want to keep the project as compact as possible and not add anymore expense.  I can power the DroidX off of the Arduino Yun's USB port with a power supply capable of supplying enough current for both devices. I'm sure this has been done before and probably using graphs and other nice Android graphics features to display Arduino projects.  I'm just going to display the sensor data as text on the Android screen.

Android Programming
First thing that needs to be done is to enable USB debug mode on the DroidX.On the DroidX, go into Settings/Applications/Development/USB Debugging. You will be asked to confirm allowing USB debugging. Here's a link that explains how to do this in detail.

Then install the Android SDK bundle here. This will install the Eclipse Developer IDE for writing your own apps. You can install the SDK updates for all of the Android API's you want to write apps for.  I installed all the SDK build tools for API's 17 on up to 21 and everything for Android versions 4.4.2 on up to 5.0.1.

This link will help get you started coding your first app. This is the same site that I used to learn using the Eclipse IDE, but I didn't use a simulator, I ran my Android Application directly on the DroidX.

The app I created is called Sensor Display. I have the source files on github that can be loaded into the Eclipse IDE as a project. You can modify the java code to your needs.

I manually created the SensorData directory on the sdcard, and created empty files of the glog.txt, plog.txt and wlog.txt files inside the SensorData directory.