Shares

ESP8266 Controlled with Android App (MIT App Inventor)

Shares

In this project, you’re going to build an Android app using the MIT App Inventor software that allows you to control the ESP8266 GPIOs.

First, watch the video demonstration


To learn more about the ESP8266 use the following tutorials as a reference:

If you like the ESP and you want to do more projects you can download my eBook Home Automation using ESP8266 here.

Let’s get started!

Parts List

Here’s the hardware that you need to complete this project:

Click the image above, to see on ebay.

Click the image above, to see on eBay.

Flashing Your ESP with NodeMCU

In this tutorial we are going to use the NodeMCU firmware. You have to flash your ESP with NodeMCU firmare.

Downloading ESPlorer IDE

I recommend using the ESPlorer IDE which is a program created by 4refr0nt to send commands to your ESP8266.

Follow these instructions to download and install ESPlorer IDE:

  1. Click here to download ESPlorer
  2. Unzip that folder
  3. Go to the main folder
  4. Run “ESPlorer.jar” file
  5. Open the ESPlorer IDE

esplorer start

Schematics (3.3V FTDI Programmer)

The schematics for this project are very straight forward. You only need to establish a serial communication between your FTDI programmer and your ESP8266. You can buy one FTDI programmer on eBay.

esp8266_pinout_h-569x236Wiring:

  • RX -> TX
  • TX -> RX
  • CH_PD -> 3.3V
  • VCC -> 3.3V
  • GND -> GND

ESP-Bitcoin-price_bb

Uploading Code

You should see a window similar to the preceding Figure, follow these instructions to upload a Lua file:

  1. Connect your FTDI programmer to your computer
  2. Select your FTDI programmer port
  3. Press Open/Close
  4. Select NodeMCU+MicroPtyhon tab
  5. Create a new file called init.lua
  6. Press Save to ESP

Everything that you need to worry about or change is highlighted in red box.

esplorer_tab

Code

Upload the following code into your ESP8266 using the preceding software. Your file should be named “init.lua“.

Don’t forget to add your network name (SSID) and password to the script below.

Schematics

Now follow these schematics to create the circuit that controls two LEDs.

ESP-web-server_bb

Your ESP IP Address

When your ESP8266 restarts, it prints in your serial monitor the ESP IP address. Save that IP address, because you’ll need it later.

In my case, the ESP IP address is 192.168.1.95. If you experience problems seeing your IP read this troubleshooting guide.

Creating the Android App with MIT App Inventor

MIT App Inventor is a drag-and-drop software that allows you to create a basic, but fully functional Android app within an hour or less.

Here’s how to edit the ESP8266 Controller app:

  1. Click here to download .zip folder that contains .aia file
  2. Unzip the folder
  3. Go to MIT App Inventor
  4. Click the “Create Apps” button on the top right corner
  5. Go to the “Projects” tab and select “Import project (.aia)”

aia file import

After importing the .aia file, you’ll be able to edit the app and see how the app was built.

Designer

The designer tab is where you can edit how the app looks. Feel free to change the text, change the colors, add buttons or add more features.

app designed

Blocks

The blocks section is where you can add what each button does and add logic to your app.

app inventor blocks

Click the image above to enlarge the figure

After finishing editing the app you can click the “Build” app tab and install the .apk file in your Android.  I personally recommend that you first upload the app provided below to ensure that everything works as expected (later you can edit the app).

Installing the Android App

Follow these instructions to install the default app that I’ve created:

  1. Click here to download .zip folder that contains the .apk file
  2. Unzip the folder
  3. Move the .apk file to your Android phone
  4. Run the .apk file to install the app

Here’s how the ESP8266 Controller app looks when you to open it.

App

ESP8266 Controller

It’s very easy to configure. Click the button “Set IP Address” on the bottom of the screen and type your IP address (in my case 192.168.1.95).

You’re all set!

Now you can turn the GPIOs high and low with your smartphone. Go to the top of this page to see a video demonstration of this project.

Taking It Further

This is a basic example that shows you how easy it is to integrate an Android app with the ESP8266. You can take this example and modify it.

You could add multiple screens to the app, so you can other ESPs or add buttons to control more GPIOs.

Do you have any questions? Leave a comment down below!

Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.

Leave a Comment:

Add Your Reply

Download Home Automation Using ESP8266 (2nd Edition) and Save 30%
Sale Ends January 21

x