Objective: to develop a cell phone app that could control a piece of hardware over bluetooth.

MIT AppInventor

appScreen.jpg

Overview

The objective of this exercise was to control a drone that we programmed on an ESP32 using a cell phone app connected over bluetooth. You can see a demonstration in the video below:

How it worked

As you can see in the video, we were controlling the four motors of a drone. We wrote an auto levelling program that would read the roll, pitch, and yaw from a gyroscope and determine the drone’s orientation. Depending on its orientation different motors would be sent power. There are more details specific to the auto-levelling program on the drone project page (LINK COMING).

When the user of the app pushes on a button a command would be sent over bluetooth serial (U for up, D for down, L for Left, R for right, etc.) to the ESP32. When the ESP32 would receive the input it would increase the power to a certain combination of motors. In the video above, you can see an example of sending the UP command. We will dive further into the details of the app itself below.

App details

The app was programmed using MIT App inventor. An open source program for building simple phone apps using code blocks. There were two control pads. One for level flight control (left pad) and one for pitch and roll flight control (right pad). You can see the controller details in the image below.

appScreen.jpg

Flight commands

Below is a description of the commands

Left pad:

Right pad:

Those are the main flight controls. Now lets dive in to how the app itself was programmed.

Code blocks

There three main sections to the code blocks written in the app:

We will discuss each block in detail below.

Initialization code blocks

Details for these code blocks are provided in the image below.

block1.jpg

Description of the code blocks seen on the left:

Description of the code blocks seen on the right:

Next we will discuss the control blocks.

Control code blocks

Details for the control blocks are shown in the image below.

block2.jpg

As can be seen each block is the same and deals with two cases for each button:

Next we will discuss the ON/OFF control blocks.

ON/OFF code blocks

The ON/OFF (I/O) code block is shown at the bottom of the following image.

block3.jpg

As can be seen, this code block deals with the case when the ON/OFF button is clicked. When its clicked the bluetooth serial is initialized, the command “I” or “O” are sent (depending on the state of the image that is being displayed with record_off.jpg is default). Lastly, the image is updated to show the ON/OFF button as either red or the default off.