Gpio android bpi-m2

How do you access gpio under android?

HI Rlong: you can try it .

import com.softwinner.Gpio;

Gpio.writeGpio(portType, portNum, status);

Sample Code Framework API: Control GPIO-PG10

char portType = ‘G’; int portNum = 10; Gpio.writeGpio(portType, portNum,1); //Trun on Gpio.writeGpio(portType, portNum,0); //Trun off


Hi! Are there any ways to get the access to GPIO port if there is android 4.4 on the Bannana Pi M1+? I develop using java. And where get this “import com.softwinner.Gpio;”


  1. You can download Android source code for M1+
  2. See frameworks/base/swextend/gpio/java for your reference.

hii 1-i want to know if i have to download the gpio library for my (banana pi + android os) or if it’s exist 2- if it’s not exist ,from where can i download it 3-can u explain to me how to develop an application(and which environment ) to control the pins and how to put it on the banana pi. if u can help me with this subject because theres only negative answers on the net

Hi… Where i can download Android source code for M1?


HI: Maybe you can see this for reference.

Downlaod address:

Account/Password: pub/ bananapi

Path: Source_Code / bpi2 / BPI-M2-Android4.4.tar.gz

1 Like

Hi… I can access that link…but that file too big… any opinion for connect GPIO in Android?

thanks… :smiley:

1 Like

im confused is this all for the m2? or the m1? or both? just android in general? I really would like to gain access via android to the gpio has anyone done this yet on the m2??

Can someone give me a sample code to control 2 gpio pins on the m2 with voice commands on android 4.4 plz I think I’m starting to learn some of this pretty good now lol but I’m too much of a noob to do this on my own lol


BPI-M2: Onboard Led

 try {
        Runtime command = Runtime.getRuntime();
        Process proc;
        DataOutputStream opt;
        proc = command.exec("su");
        opt = new DataOutputStream(proc.getOutputStream());
        Log.d(TAG, "LED Testing start.");
        opt.writeBytes("echo 1 > /sys/class/gpio_sw/PG10/data\n");
        opt.writeBytes("echo 1 > /sys/class/gpio_sw/PG11/data\n");

    } catch (IOException e) {
        // TODO Auto-generated catch block

Justin I love that your willing and trying to help me in the right direction but I need some explanation with your sample codes man like where do I put the code? What platform, directly on the bpi-m2 in android with a terminal app? What is supposed to happen with this code example? If I don’t know the expected results how do I know if I’m doing it right or not, you clearly have more experience than I and I appreciate your help and hope to hear more from you on the subject, also what about the 40 pin gpio header how is that accessed

Is there a document that defines the mapping of the GPIO port type / portNum <–> GPIO pin?

Nothing that I’ve seen

I’ve been searching for documentation as well but had to find out that it’s all scattered through different places and if you look into the ‘documents’ they lack even the most basic rules of accurateness (incomplete or wrong).

I found the gpio spec:

Sorry, but the ‘documents’ you found can not be called a ‘spec’. This is more or less random bullshit according to people who really tried to get a clue what’s going on: (this seems to be the ‘official’ forum from a few months ago)

I’m very disappointed by the amount of wrong and missing informations. It seems the vendor doesn’t care at all about accurateness. Even product specs used to advertise/sell their products are wrong.


check this out: The gpio seems accurate, I used 7 and 8 for my kernel module and it works as i expect.