September 19, 2019, 12:55:23 pm


Have you visited the Allwinner Chipset wiki? -

Python and GPIO on Cubietruck

Started by Vyachez, May 31, 2014, 03:57:05 am

Previous topic - Next topic


Hello, everyone!

I spent much time researching this issue but seems that it fits only for Cubbieboard2.
I am trying to make WiringCB-python working for Cubietruck/Cubieboard3.

The purpose of that is programming for GPIO using python language. So I need addressing GPIO with Python (not! shell or C).
The gobal goal of my project is to create intelligent robot able to recognize faces and voice and perform relevant dependant commands.

Here we have repository:
I dug it all aroung but did not find the way how to rebuilt it for Cubietruck.

What I've done to make GPIO working on Cubietruck from startup:

Added GPIO ports to script.bin

WARNING: do not change default pin PH20 PH10:

-created group gpio
-added user to group
sudo groupadd gpio
sudo usermod -aG gpio <username>

Then modified (added lines of code without exit 0) rc.local file by setting up /sys/class/gpio group to gpio recursively and permissions to 775 on gpio recursively; exported pin 3 gpio folder; and changed permissions to 775 on gpio3_pi14 (I used GPIO pin no PI14:

chgrp gpio -HR /sys/class/gpio
chmod -R 775 /sys/class/gpio
echo 3 > /sys/class/gpio/export
chgrp gpio -HR /sys/class/gpio/gpio3_pi14
chmod -R 775 /sys/class/gpio/gpio3_pi14

Tested GPIO pi14 with led running following sh. script right after reboot:

cd /sys/class/gpio/gpio3_pi_14
echo out > direction
echo 1 > value
sleep 1
echo 0 > value
sleep 1
echo 1 > value
sleep 1
echo 0 > value
sleep 1

led blinked.

But when I am running the code on Python, nothing happens (after all repositories and python installation obviously):

import wiringpi2
pin = 3
HIGH = 1
LOW = 0


while 1:

I've reinstalled python and used 2.7.x and/or 3.x.x. It does not change the matter.
Everythin was done under instructions but no luck.

Maybe someone have any ideas how to use Python to work with Cubietruck GPIO?
Or maybe smeone have any ideas how to interact with GPIO for my global purpose. I guess I need to connect openCV libraries for that purpose. I am frustrated what right way to go.


I highly recommend you open-cv since it would be very hard to build your own library. Also, you may want to add a microphone attached to the LINEIN-L and LINEIN-R (24 and 26) GPIOs. But if you want to get your microphone to work, you'll have to build a pre-amplifier.


Thank you, Eduardo!
You helped me much to get solution with GPIO and giving this advice. I will definitely use mic. But it will be a bit later. After playing around GPIO in/out I will go to PWM to operate 4 wheels smoothly. Then I will connect webcam and learn CT to recognize subjects with openCV. Adding unltrasonic or infared sensors I will make it scan premises and find path.

Thus second step is PWM and Video capturing/processing. BTW for video I found some interresting materials here: