GPIO Java API

edited September 2018 in Projects

Hi,
is there a Java API for using RPI3 GPIO ?

Comments

  • https://help.emteria.com/kb/devices-rpi-3

    `# GPIO

    Accessing GPIO is possible just the same way you would do it in Linux (via sysfs). We are also planning on adding proper Java API for that, but it will take a while.`

    Hope we could use such API near in the future. Waiting for it!

  • How is the GPIO access possible from within an Android (Java) app? How do we need to set permissions to access sysfs?

    The Java method

    public boolean activationPin(){
    String command = String.format("echo %d > /sys/class/gpio/export", this.pin);
    try {
    Runtime.getRuntime().exec(new String[] {"su", "-c", command});
    return true;
    } catch (IOException e) {
    return false;
    }
    }

    leads to the exception "java.io.IOException: Cannot run program "su": error=13, Permission denied"

Sign In or Register to comment.