5

I want to install Android on my Raspberry Pi for implementing a GUI app, which is easy to create using Android Studio.

But now I am confused about how to control the GPIO pins on the Pi 3 to turn on the relay and get data from other sensors.

How can I interface my main GUI app to another script running in the background waiting for commands from the user selection?

3
  • Did you ever figure this out? I'm running Android on my Pi and I'm trying to control the GPIOs from an app I'm building that will run on that Pi.
    – Lucas P.
    Nov 18, 2018 at 0:45
  • I hope my answer is not too late. Please refer to the URL following. github.com/yang-neu/rpi3gpio
    – Alex Yang
    Oct 27, 2019 at 12:06
  • You could try installing gpiozero. It comes with Raspbian by default, but you should be able to install it on other operating systems. gpiozero.readthedocs.io/en/stable/installing.html
    – Paul
    Apr 8, 2020 at 2:10

1 Answer 1

2

I do this all of the time with MQTT. Here's how:

For your android app, use an MQTT client library like PAHO https://github.com/eclipse/paho.mqtt.android

Simple examples on how to do basic pub/sub on that site.

On the Pi - I actually run an MQTT "Server" or broker on the pi but you can also run one on something like an AWS EC2 server and control your pi over the internet. Just have both the android and pi subscribe and post to the topics you create to talk to eachother.

There are many MQTT clients that work on a pi depending on the programing language. POHO clients you can code against for python, Java, Kotlin etc.

Hope that helps someone.

Not the answer you're looking for? Browse other questions tagged or ask your own question.