ESP8266 controlled with Android app (MIT App Inventor)

ESP8266 controlled with Android app (MIT App Inventor)

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.

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


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.


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


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.



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.

-- Rui Santos
-- Complete project details at

led1 = 3
led2 = 4
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
    conn:on("receive", function(client,request)
        local buf = "";
        buf = buf.."HTTP/1.1 200 OK\n\n"
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
        if( == "ON1")then
              gpio.write(led1, gpio.HIGH);
        elseif( == "OFF1")then
              gpio.write(led1, gpio.LOW);
        elseif( == "ON2")then
              gpio.write(led2, gpio.HIGH);
        elseif( == "OFF2")then
              gpio.write(led2, gpio.LOW);


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


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 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)”


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


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.



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

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.

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

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.


For More Details: ESP8266 controlled with Android app (MIT App Inventor)

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top