Gpio android bpi-m2


(ricky long) #1

How do you access gpio under android?


(BPI_Justin) #2

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


(Dmitriy) #3

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;”


(BPI_Justin) #4

HI:

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

(wael abo elhija) #5

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


Android 4.4 gpio help
(Adam Fikri Maulana) #6

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

Thanks…


(BPI_Justin) #7

HI: Maybe you can see this for reference.


Downlaod address: ftp://dev.banana-pi.org.cn/

Account/Password: pub/ bananapi

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


(Adam Fikri Maulana) #8

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

thanks… :smiley:


(ricky long) #9

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??


(ricky long) #10

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_Justin) #11

HI FYI.

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
        e.printStackTrace();
    }

(ricky long) #12

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


(John Huang) #13

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


Sensors with Android 5.1
(ricky long) #14

Nothing that I’ve seen


#15

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).


(John Huang) #16

I found the gpio spec:

http://www.bananapi.com/index.php/component/content/article?layout=edit&id=73


#17

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:

http://www.bananapi.com/index.php/forum/general-discussion-for-bpi-m2/411-m2-gpio-defininiton?start=6 (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.


(Chris) #18

check this out: https://github.com/BPI-SINOVOIP/BPI-WiringPi/blob/BPI_M3/pins/pins.pdf The gpio seems accurate, I used 7 and 8 for my kernel module and it works as i expect.