Having a fun with GPIO on Android!

You must install the C2 Android Marshmallow Ver2.8 image or higher to access the GPIO port properly.
You must install the C1/C1+ Android Kitkat Ver3.2 image or higher to access the GPIO port properly.
You must install the XU4 Android Kitkat Ver6.0 image or higher to access the GPIO port properly.
You must install the XU4 Android Nougat Ver1.3 20171214 image or higher to access the GPIO port properly.

This WiKi explains how to make an Android app which can access GPIO ports.

You need to install Google Android Studio on your host PC.
Add NDK and tools first before starting below steps.
We tested following steps on Android Studio 2.3 and NDK R14.

Configure NDK path for Android Studio

You can find the Android SDK location on this menu (File → Settings → Appearance & Behavior → System Settings → Android SDK)

After editing the bashrc file, you have to login again or type “source ~/.bashrc” on the command line.

Download example code

Download WiringPi NDK library and App source code Project from github.

ODROID-C1+/C2

$ sudo apt install git
$ git clone https://github.com/codewalkerster/example-wiringPi -b odroid-c

ODROID-XU4

$ sudo apt install git
$ git clone https://github.com/codewalkerster/example-wiringPi -b odroid-xu

Run Android Studio and open the downloaded project.

Build the project to make an apk package

Select Build → Make Project menu.
You will see a couple of error messages and click following texts to complete the build process.
Install missing platform(s) and sync project
Install Build Tools 25.0.2 and sync project

And you will have an apk file to run it on your ODROID.

Set environment PATH to point NDK folder path

Reboot Windows.

Install git client program

Clone project

https://github.com/codewalkerster/example-wiringPi

Select origin/odroid-c or origin/odroid-xu.

Install NDK

Toos → Android → SDK Manager

ADC and GPIO output

Read ADC value and show the voltage level with 19 LEDs on GPIO output.

ODROID-C1+/C2

ODROID-XU4

PWM

Basic PWM control example. You can choose the number of PWM outputs 1 or 2.
And control the frequency and duty ratio.

Gmail Notifier example

This is a fun and useful project using the PWM port.
When you are watching videos or playing games, you might miss notification of an important email or message.
The flag is moved by servo motor which is connected to a PWM pin on 40pin GPIO port.
https://github.com/codewalkerster/GMailNotifier

I2C

An example code to access our Weather Board to measure the temperature, humidity, atmospheric pressure, altitude and visible/invisible light intensities via I2C interface.

img_20170526_153143.jpg

UART

A demo software for Sending and Receiving characters via UART interface.

1 Wire

A demo software to access 1-wire protocol interfaced to two DS18S20 temperature sensors.

Open File Manager app.

Edit /storage/internal/boot.ini like this. (near end of file).

Before edit.

movi read dtb 0 ${dtbaddr}
# load kernel from vfat or boot partition.
movi read boot 0 ${loadaddr}
#fatload mmc 0:1 ${loadaddr} Image
booti ${loadaddr} - ${dtbaddr}

After edit.

movi read dtb 0 ${dtbaddr}
# load kernel from vfat or boot partition.
#movi read boot 0 ${loadaddr}
fatload mmc 0:1 ${loadaddr} Image
booti ${loadaddr} - ${dtbaddr}

Load kernel image from vfat partition built i2c.

If you could not find 'fatload' command, remove /storage/internal/boot.ini file and reboot system.