Python GPIOs module for A20-OLinuXino-MICRO


pyA20 GPIO module is uploaded yesterday to Pypi

The use is same as the Python modules for imx233, A10S, A13 OLinuXino:

#!/usr/bin/env python
import A20_GPIO as GPIO
#init module
#configure module
#read the current GPIO configuration
config = GPIO.getcfg(GPIO.PIN#)
#set GPIO high
#set GPIO low
#read input
state = GPIO.input(GPIO.PIN#)

this is initial release so if you find some bugs please report back to us 🙂

A10S-OLinuXino ANDROID GPIO control LED toggle app


We got lot of requests on our forum how to control GPIOs from Android.

With the new A10S Android image we decided to play a bit and it appear to be not hard to implement.

We found two ways to do GPIO control running Android.

GPIO using ADB

1. Boot android (from nand or sdcard)

2. Connect USB-to-Serial cable on UART1

3. Open terminal at speed 115200

4. When loading is ready in the terminal type “sh” and enter

5. “ls /sys/class/gpio_sw” will give you a list of all accessable GPIOs.

The GPIOs name is according to the chip ports. For example PE3 is LED1.

6. To set PE3 as output:

#echo 1 > /sys/class/gpio_sw/PE3/mul_sel

or as input

#echo 0 > /sys/class/gpio_sw/PE3/mul_sel

7. To turn on LED:

#echo 1 > /sys/class/gpio_sw/PE3/data

and to turn off:

#echo 0 > /sys/class/gpio_sw/PE3/data

8. If GPIO is as input to read state:

#cat /sys/class/gpio_sw/PE3/data

GPIO using Android SDK

Basicly you should read and write to the filesys. Make sure that your app is running as root, or else nothing will happen.

The demo program toggle LED1 on every button press.  The sources are at GitHub:

All read/write methods are realized in file.

The application is with single button and each time you press it it toggles the green LED on the board.


You can see ToggleLED.apk running at this video:

A10S-OLinuXino-MICRO Python GPIO module


pyA10S GPIO ports module is available at:

iMX233-OLinuXino GPIO Python Libraries


Soon after we released A13-GPIO for Python we got requests to do same for iMX233.

iMX233_GPIO is released on PyPi now
it works identical to pyA13 you can use same commands:

import iMX233_GPIO as GPIO
#init module
#configure module
#set GPIO high
GPIO.output(GPIO.PIN#, 1)
#set GPIO low
GPIO.output(GPIO.PIN#, 0)
#read input
state = GPIO.input(GPIO.PIN#)

due to the GPIO multiplexing we add only these GPIOs in the base package:

PIN9, PIN10, PIN11, PIN12, PIN13, PIN14, PIN15, PIN16, PIN17, PIN18, PIN23, PIN24, PIN25, PIN26, PIN27, PIN28, PIN29, PIN31

you can use this as template, and if you for instance disable LCD in your linux image you can have access to all LCD pins too.

After you download the package from PyPi do as follows to install it:

#tar -zxvf iMX233_GPIO-0.1.0.tar.gz
#cd iMX233_GPIO-0.1.0.tar.gz
#sudo python install

after the installation you can use it this way:

#sudo python
>>> import iMX233_GPIO as GPIO
>>> GPIO.init() #init GPIOs
>>> GPIO.getcfg(GPIO.PIN31) #config PIN31 as GPIO
>>> GPIO.setcfg(GPIO.PIN31, GPIO.OUTPUT) #config PIN31 as output
>>> GPIO.output(GPIO.PIN31, GPIO.HIGH) #set PIN31 high
>>> GPIO.output(GPIO.PIN31, GPIO.LOW) #set PIN31 low
>>> GPIO.setcfg(GPIO.PIN31, GPIO.INPUT) #config PIN31 as input
>>> GPIO.input(GPIO.PIN31) #read PIN31

PINxx assignments is exactly as per imx233-OLinuXino-MAXI schematic

Maximum iMX233 GPIO toggle speed via Python is 15,6 kHz, which is kind of dissapointing, as /dev/mem C approach achieve about 5.7 6 Mhz, but Python is running slow on imx233 so this probably cause the slow GPIOs access.

On A13 is opposite /dev/mem is running slower at 1Mhz but pyA13 GPIO achieve up to 100 kHz as Python is running faster on A13.

Scratch + A13-OLinuXino-WIFI Physical Computing


Scratch is great visual environment very easy to understand by children.

I already blogged that Scratch is running fine on OLinuXino here

What bothered us though was that we can’t use all GPIOs and hardware resource which OLinuXino offers and Scratch basic installation can only play music and make cool animations.

So we start searching info how to implement this.

Soon we found SNAP which is based BYOB (Build your own Blocks) which is based on Scratch but adds ability to make your own blocks, recursion etc new features.

SNAP is implemented with JavaScript so even better it runs on your Browser without need of installation. Based on SNAP there are few cool projects made by Technoboy10 ( interfacing Wii Nunchuk , Arduino and NXT-Lego robots.

I asked Technoboy10 is there documentation how to connect Hardware to SNAP and soon he published this info in the Wiki:!-Extension which is very detailed.

So How cool is this? Kids are able to program robots with visual IDE!

Looking at Technoboy10 GitHub repository we figured out how to do this, but SNAP basic installation have no such great choice of sprites and animation examples, so I decided for the beginning to try to implement OLinuXino hardware features to SCratch.

So I posted question on Scratch forum and start to wait for reply . After few days waiting, 30+ views and none reply I did what I had to do at the beginning: searched github for “scratch c” then for “scratch python” and found what we needed:

This is cool python client for Scratch. When you enable remote sensors in Scratch it creates server, then with scratchpy you can pool for given variables and take their values or change them, this way you can connect sensors or actuators.

As opposite to SNAP (where SNAP i client and snap-server is made with pyton, so SNAP connects to the server) here Scratch makes server and the scratchpy client connects to it and interact through variables.

So here is our first “Hello World” blinking LED with Scratch:

Instruction how to install the OLinuXino GPIO interface to Scratch is on GitHub:

Our second project animate GPIO connector with Scratch based on real buttons inputs and LED outputs:


Here is video on the GPIO interaction with SCRATCH

Now when we have this powerful tool: scratchpy to interface Scratch to anything via python, just imagine what would happend if we connect Scratch to … OpenCV 🙂

From my previous blog I show you some videos which demonstrate the power of OpenCV: face recognition, face expression recognition, color objects tracking.  You can make SCRATCH script for instance which recognize the face of the person in the fron of the web cam and run some animation to welcome it by name.

Or you can program your robot to chase this yellow pong ball which is in the front of it.

Or you can make different animations depend on the face expression of the person in the front of the camera… the applications and the fun will be endless!

A13-OLinuXino GPIO Python libraries


Python is one of the most popular languages in the last years, it’s used by Google for their search engine and many other apps like game designs, databases etc.

Python combines the easy of use of the interpretive languages with powerful datastructures, so it replaces the old days BASIC but opens up lot of new possibilities.

If you want to learn more about Python you can read or the official Python language web site

The best of all are the Python libraries you can see thousands of these at

A13-OLinuXino as any Linux platform can run Python language, what we were missing was GPIO library which to allow Python users to have access to A13-OLinuXino GPIOs.

Now this library is done! You can download is from or from GitHub:

then install it:

#tar -zxvf pyA13-0.1.7.tar.gz
#cd pyA13-0.1.7.tar.gz
#sudo python install

after the installation you can use it this way:

#sudo python

>>> import A13_GPIO as GPIO
>>> GPIO.init()                           #init GPIOs
>>> GPIO.getcfg(GPIO.PIN37)               #config PIN37 as GPIO
>>> GPIO.setcfg(GPIO.PIN37, GPIO.OUTPUT)  #config PIN37 as output
>>> GPIO.output(GPIO.PIN37, GPIO.HIGH)    #set PIN37 high
>>> GPIO.output(GPIO.PIN37, GPIO.LOW)     #set PIN37 low
>>> GPIO.setcfg(GPIO.PIN37, GPIO.INPUT)   #config PIN37 as input
>>> GPIO.input(GPIO.PIN37)                #read PIN37

PINxx assignments is exactly as per A13-OLinuXino schematic

EDIT: Maximum GPIO toggle speed via Python is 101 kHz

Friday Free Board Quiz issue #25 is RPI-UEXT + MOD-IO2



RPI-UEXT allow Raspberry Pi to have access to different modules see original blog post we made about it:

MOD-IO2 allow RaspberryPi to control 2 relays and to read/write 7 additional GPIOs, including Analog inputs. On top of this MOD-IO2 is stackable and addressable so you can stack and connect to Raspberry Pi as many relays as you need for your project.

You have chance to win RPI-UEXT + CABLE26-pin + MOD-IO2 today if you answer correctly our quiz question!

Today at 17.00 o’clock our local Bulgarian time (GMT+2) we will post on Twitter our questions.

You have one hour to reply to our tweet with the correct answer.

At 18.00 o’clock we will count the correct answers and ask to generate random number in range then announce the winner and ship the board by airmail in Monday.

Good Luck!

Previous Older Entries Next Newer Entries