Mit App Inventor Upload Read Phone State

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, picket the video demonstration

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

  • Getting started with the ESP8266
  • ESP8266 spider web server with NodeMCU
  • Flashing NodeMCU firmware
  • ESP8266 troubleshooting guide

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

Let's get started!

Parts Listing

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

  • 1x ESP8266 -read All-time ESP8266 Wi-Fi Developmento Boards
  • 1x FTDI programmer
  • 2x LEDs
  • 2x 220Ω Resistors
  • 1x Breadboard
  • 1x Android Telephone – example OnePlus 5 (read review)

Y'all can use the preceding links or go straight to MakerAdvisor.com/tools to find all the parts for your projects at the all-time price!

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 past 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. Become to the primary 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 series communication between your FTDI programmer and your ESP8266. You lot can buy i FTDI developer on eBay.

Wiring:

  • RX -> TX
  • TX -> RX
  • CH_PD -> three.3V
  • VCC -> three.3V
  • GND -> GND

Uploading Lawmaking

Y'all 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. PressOpen/Shut
  4. Select NodeMCU+MicroPtyhon tab
  5. Create a new file called init.lua
  6. Press Save to ESP

Everything that you need to worry virtually or alter is highlighted in red box.

Code

Upload the post-obit lawmaking into your ESP8266 using the preceding software. Your file should be named "init.lua".

Don't forget to add your network proper noun (SSID) and password to the script below.

          -- Rui Santos -- Complete projection details at https://randomnerdtutorials.com  wifi.setmode(wifi.STATION) wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") print(wifi.sta.getip()) led1 = 3 led2 = 4 gpio.mode(led1, gpio.OUTPUT) gpio.mode(led2, gpio.OUTPUT) srv=net.createServer(internet.TCP) srv:listen(80,function(conn)     conn:on("receive", function(customer,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)and so             _, _, method, path = string.discover(asking, "([A-Z]+) (.+) HTTP");         end         local _GET = {}         if (vars ~= aught)then             for one thousand, 5 in string.gmatch(vars, "(%w+)=(%w+)&*") practice                 _GET[k] = v             end         terminate                  if(_GET.pin == "ON1")and then               gpio.write(led1, gpio.HIGH);         elseif(_GET.pin == "OFF1")so               gpio.write(led1, gpio.LOW);         elseif(_GET.pin == "ON2")then               gpio.write(led2, gpio.Loftier);         elseif(_GET.pin == "OFF2")then               gpio.write(led2, gpio.LOW);         cease         customer:send(buf);         client:close();         collectgarbage();     end) end)                  

View raw code

Schematics

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 accost. Save that IP address, because you'll need it later.

In my example, 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-driblet software that allows you to create a bones, but fully functional Android app within an hour or less.

Here'due south how to edit the ESP8266 Controller app:

  1. Click hither to download the .aia file
  2. Unzip the binder
  3. Go to MIT App Inventor
  4. Click the "Create Apps" push on the top correct corner
  5. Go to the "Projects" tab and select "Import projection (.aia)"

aia file import

Afterwards importing the .aia file, you'll exist 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 gratis to change the text, modify the colors, add buttons or add more features.

app designed

Blocks

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

app inventor blocks
Click the image above to enlarge the effigy

After finishing editing the app yous 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 on y'all 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 the .apk file
  2. Unzip the binder
  3. Movement 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 information technology.

App
ESP8266 Controller

It'due south very easy to configure. Click the button "Set IP Accost" on the bottom of the screen and type your IP accost (in my case 192.168.1.95).

You're all fix!

At present you tin turn the GPIOs high and low with your smartphone. Go to the top of this page to run across a video demonstration of this project.

Taking It Further

This is a basic example that shows y'all how piece of cake it is to integrate an Android app with the ESP8266. You tin take this case and modify it.

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

Do you have whatever questions? Exit a annotate down below!

Thanks for reading. If you similar this postal service probably y'all might similar my next ones, so please support me by subscribing my blog.

grandberrysity1985.blogspot.com

Source: https://randomnerdtutorials.com/esp8266-controlled-with-android-app-mit-app-inventor/

0 Response to "Mit App Inventor Upload Read Phone State"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel