ArdUI

A video explanation

If you are more a fun of video explanation go to this youtube video

Project aim

This project aims to simplify creation of basic Arduino programs by just editing a UI on Android. Instead of the usual Arduino development cycle:

arduino-usual-flow

You have just to create your program via the Android UI and send it Arduino via Serial.

In order to make the setup work you have to do two things

Build and deploy the generic program to your Arduino board

in order to do that

  • Include the ArdUI.zip (./arduino-library/generated/c/ArdUI.zip) library

    (You can include the Library zip can in Arduino IDE via: Sketch -> Include Library -> Add .ZIP Library.)

  • Upload GenericProgram.ino to your Arduino board.

That’s it!

All subsequent changes to the Arduino Program can be done with Android UI now.

Technical details

Below is a technical description for whats happening under the hood

The workflow go as described here

  • a Protobuf file is used to describe the serialization/deserialization of data between Kotlin objects, byte streams and C structures. the Protbuf file used here to describe the data format is located at ./proto/common.proto

  • The Android application allows to create a program in UI which is translated to data classes generated by the Protobuf generator.

  • This data is serialized and sent to Arduino via the Serial.

  • The C program in Arduino deserializes the received bytes and construct the set of instructions to run.

The fact that Protobuf is supported for an array of languages allowed us to write programs in Kotlin (for Android), C (for Arduino) and JS (for a NodeJS app)

Web interface

A NodeJS application is provided too in case you don’t have access to an Android phone. The interface is pretty simple and basic; you have 2 text fields:

  1. For setup instructions
  2. For loop instructions

This is the syntax to use for writing instructions:

pinmode [input|output|input_pullup]
digitalwrite pin [low|high]
analogwrite pin value
sleep duration

Press upload button and it should work.
More details can be found Here

How bindings are generated?

Java bindings

This is generated using the wire library, the gradle plugin seemed like the easiest way, all you need is for this case is to include

wire {
    sourcePath {
        srcDir '../../proto'
    }
    kotlin{}
}

in your build.gradle file, and it will keep your generated stub up to date with the protobuf spec.

C bindings

The C binding is generated with nanopb library; it is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.

C bindings are generated for our project with the following steps:

  1. clone the repository locally

git clone https://github.com/nanopb/nanopb.git
  1. generate the bindings from .proto files:

NANOPB=path/to/nanopb
${NANOPB}/generator/nanopb_generator.py \
  -D ./arduino-library/generated \
  -I ./proto \
  common.proto
  1. create the library as a ZIP file:

zip -j arduino-library/ArdUI.zip \
   ${NANOPB}/pb_common.h \
   ${NANOPB}/pb_common.c \
   ${NANOPB}/pb_decode.h \
   ${NANOPB}/pb_decode.c \
   ${NANOPB}/pb.h \
   arduino-library/generated/common.pb.h \
   arduino-library/generated/common.pb.c \
   arduino-library/ArdUI.h \
   arduino-library/ArdUI.cpp

You can include the Library zip can in Arduino IDE via:
Sketch -> Include Library -> Add .ZIP Library..

N.B: probably you will need the nanopb dependencies for Python.

You can install them with:

pip3 install scons protobuf grpcio-tools

JS bindings

to create the needed JS binding you can run the following command:

protoc --proto_path=./proto \
       --js_out=import_style=commonjs,binary:html-serial-ui/js \
       common.proto

More details can be found Here

Limitations

  • Currently, only 8 instructions are supported for setup and 16 for loop.

  • 4 types of instructions are supported now:

    • setPinMode
    • digitalWrite
    • analogWrite
    • sleep

Contributions

Contributions are welcome!
Just create your pull request and it will be reviewed and merged ASAP.

Found a bug?

Describe your bug and the steps to reproduce it in an issue and it will be addressed by us.

GitHub

https://github.com/targist/ardui