6 Replies Latest reply on Apr 22, 2015 5:01 AM by vlad.bura

    Create Android app that utilizes GPIO




      I have been trying to find more info on how to access the gpio from inside a android app. Something simple like blinking and/ or fading an led. I want to eventually use the gpio and a few mosfets to be able to control my extra lighting in my vehicle. I found some info for other boards that have android and a form of gpio but could only find info on linux for the riotboard. I would prefer to use android as a car computer that happens to be able to control lighting. I didn't want to get too complicated with it (use zigbee or bluetooth to send commands to arduino in order to trigger mosfets).


      I promise that I attempted to google this already. If anyone has or knows of where i can find more information i would greatly appreciate it. Even if it doesn't have much to do with the exact mission i have. There seems to be a lack of tutorials on the riotboard and android.

        • Re: Create Android app that utilizes GPIO

          If you only want to Turn GPIO ports on and off it should be as simple as writing a file.


          In the shell the command "echo 1 > /sys/class/leds/user_led/brightness" would turn the GPIO port for the user led on.

          And "echo 0 > /sys/class/leds/user_led/brightness" turns it off.


          So you just need to find a method to write to that file.

          (I´m no Android developer so I can´t tell you how to this in java.)


          What I don´t know is if you have permissions to write to the GPIO ports out of the box.

          • Re: Create Android app that utilizes GPIO

            check this link ; http://android.serverbox.ch/?p=972

            they got android app using GPIO on imx6

            • Re: Create Android app that utilizes GPIO

              If you want to reduce the complexity of your project, since you are already planning on using the arduino as the actual controller (triggering the mosfets), you could probably bypass the riotboard altogether, and use the arduino with a wifi or bluetooth shield, etc.  You could either write a cell-phone/ipod app to send the commands wirelessly to the arduino, or have the arduino serve a small web page that allows you to turn things on/off using a web form with buttons.  There are plenty of projects and tutorials you could find using that method.  Are you planning on using the riotboard for any particular reason?

                • Re: Create Android app that utilizes GPIO

                  I liked the idea of using the riot board as a in-car computer that could also interface directly with a few items. I wanted to avoid the need of a arduino. I only mentioned it because the arduino comes with 5v logic and is so commonly used that there are plenty of tutorials. if i could do everything with the riotboard that would have been the way for me to go. I am learning how to develop apps for android right now and trying to work my way up controlling on-board devices. With the riotboard being a dev board with gpio i just wanted to know how to acctually control the gpio. Being that android was designed for phones and tablets i didn't know how to go about accomplishing that.


                  So far i the riotboard is a great product and there was enough info to get me started with learning. For instance how to root the device and also add google services (even though i can't get either to work as described). I am new to the android scene so i have a ways to go.


                  Thanks for all the links. I am going to play with those and if i get it working i will report back here.

                    • Re: Create Android app that utilizes GPIO

                      Hello all!

                      We want to setup the external gpio on RIOTBOARD and we get stuck with mux procedure. We want to use all GPIO from J13 connector.



                      This is the only GPIO  that works:

                      root@RIoTboard_6solo:/ # devmem2 0x20E009C w 0x5

                      /dev/mem opened.

                      Memory mapped at address 0x400fc000.

                      Value at address 0x20E009C (0x400fc09c): 0x5

                      Written 0x5; readback 0x5

                      root@RIoTboard_6solo:/ # echo 112 > /sys/class/gpio/export

                      1|root@RIoTboard_6solo:/ # echo out > /sys/class/gpio/gpio112/direction

                      root@RIoTboard_6solo:/ # echo 1 > /sys/class/gpio/gpio112/value

                      And the rest of them doesn't work


                      We try to set GPIO5_08 to output (that means SW_PAD_CTL_PAD_DISP0_DATA14)

                      root@RIoTboard_6solo:/ # devmem2 0x20E03DC w 0x5

                      /dev/mem opened.

                      Memory mapped at address 0x40180000.

                      Value at address 0x20E03DC (0x401803dc): 0x1

                      Written 0x5; readback 0x1

                      --->All time  we get 0x1 even we write 0x5 (ALT5 -MUX mode)


                      The problem:

                      We can't set the GPIO as output or input. Maybe we need to set somehow the SION first?

                      Any idea?


                      Thx in advance!