It has been a while since the post where we explained how to Turn your Linux computer into a huge Android USB Accessory. In the former post, the process of creating a C-application to communicate with your Android device has been discussed. Today, we would like to pick up on the same topic, this time however showing how communication can be established with the “pyusb” library using Python.
Since devices like the Arduino Yún or the Raspberry Pi offer a fully implemented USB stack (based on the Linux Kernel and libusb) it becomes increasingly interesting to use Python for this task.
The Arduino Yún is a WLAN capable development board featuring an ATMega microcontroller, as well as a separate chip running a small Linux distribution, making it a perfect candidate for home automation projects like in the picture below! This basic tutorial will show you how to communicate wirelessly between your Arduino Yún and an Android device. Schematics and components for dimming a high power led are also available at the end of this post.
Dimming a high power led wirelessly from an Android device
Following up on the last post “How to get started with Embedded Android on the Wandboard”, this article shows how to use the GPIO Pins of the Wandboard. It is based on the Android setup, however the generic part should run under other Linux based systems as well.
Finding the right GPIO Pin Number
In the userspace you are able to access GPIO functionality through the sysclass interface.
root@android:/ # ll /sys/class/gpio/
--w------- root root 4096 2013-06-20 10:57 export
lrwxrwxrwx root root 2013-06-20 10:57 gpio101 -> ../../devices/virtual/gpio/gpio101
lrwxrwxrwx root root 2013-06-20 10:57 gpio200 -> ../../devices/virtual/gpio/gpio200
lrwxrwxrwx root root 2013-06-20 10:57 gpio24 -> ../../devices/virtual/gpio/gpio24
lrwxrwxrwx root root 2013-06-20 10:57 gpio72 -> ../../devices/virtual/gpio/gpio72
lrwxrwxrwx root root 2013-06-20 10:57 gpio75 -> ../../devices/virtual/gpio/gpio75
lrwxrwxrwx root root 2013-06-20 10:57 gpio90 -> ../../devices/virtual/gpio/gpio90
lrwxrwxrwx root root 2013-06-20 10:57 gpio91 -> ../../devices/virtual/gpio/gpio91
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip128 -> ../../devices/virtual/gpio/gpiochip128
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip160 -> ../../devices/virtual/gpio/gpiochip160
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip192 -> ../../devices/virtual/gpio/gpiochip192
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip32 -> ../../devices/virtual/gpio/gpiochip32
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip64 -> ../../devices/virtual/gpio/gpiochip64
lrwxrwxrwx root root 2013-06-20 10:57 gpiochip96 -> ../../devices/virtual/gpio/gpiochip96
--w------- root root 4096 2013-06-20 10:57 unexport
The community based Wandboard project (http://www.wandboard.org) is a very interesting open Freescale iMx6 hardware platform. The most recent release of the Android 4.2.2 Source Code for the board makes it an ideal candidate to prototype an Embedded Android System.
For this Blog Post we are using:
Android 4.2.2 wandboard repo sources
IMX Kernel 3.0.35+ (supplied by the Android sources)
U-Boot IMX Fork (supplied by the Android sources)
Host: Ubuntu 12.10 64 Bit (username: user)
Understanding how Android Boots
In this blog post we are looking a bit closer in how to get started with booting the platform using the patched Linux Kernel and u-boot. Both come with the Android Source code which is available for downloading with Android’s repo tool.
In this post we are going to set up the Arduino Uno to measure light intensity. Furthermore, we configure and recompile the Pandaboard’s kernel to communicate with the Arduino Uno through USB-serial.
For measuring light, we will require some kind of photoresistor. If you do not have any spare ones around, you can easily get them on ebay. A photoresistor is a resistor that changes its resistance depending on the current light intensity. In the end, we will simply measure an analogue voltage that changes depending on the attached photoresistor.
For this tutorial you will need:
- Pandaboard with Linaro’s Android build from Part I
- Arduino Uno
- 1 Photoresistor
- 1 Resistor with a value around 3 kilo-ohm (we are using 3.9kOhm)
- 3 jumper wire cables (male-male)