Getting Started with MIT App Inventor 2 and Arduino

In this post I’m going to introduce you to the MIT App Inventor 2 software and I’m going to show you what you need to quickly getting started building Android apps that interact and control your Arduino.

Here’s the contents that are going to be covered in this post:

  • Introducing MIT App Inventor 2
  • Why MIT App Inventor 2 is a good choice?
  • Accessing MIT App Inventor 2
  • How to control Arduino with MIT App Inventor (Bluetooth)
  • MIT App Inventor Overview
  • Projects with MIT App Inventor
  • Android Apps for Arduino with MIT App Inventor 2

Introducing MIT App Inventor 2

MIT App Inventor 2 is a simple and intuitive free service for creating Android applications. If you want to start with MIT App Inventor, you don’t need to download or install any program in your computer as the software is cloud-based, so you build the apps directly in your browser (Chrome, Mozilla, Safari, Internet Explorer, etc).

For instance, you only need an internet connection for building the apps.

Why MIT App Inventor is a good choice?

  • MIT App Inventor 2 is intuitive and simple to use.
  • You don’t have to be an expert in programming or design to build awesome apps that can do useful stuff.
  • Creating the design is as easy as selecting and placing widgets in the smartphone screen.
  • The code is done with drag and drop puzzle blocks.

Anyone can learn how to build their own apps with MIT App Inventor 2 with a few hours of practice.

Accessing MIT App Inventor 2

To access MIT App Inventor 2 go to http://appinventor.mit.edu/explore/ and press the orange Create Apps button.

To access the app builder, you need a Google account. Follow the on-screen steps to login into MIT App Inventor 2. After that, you’ll be presented with the following dashboard (we’ll cover how to use the dashboard in the MIT App Inventor 2 Overview section):

 How to Control Arduino with MIT APP Inventor (Bluetooth)

To establish a connection between the Arduino and your Android app, you need a Bluetooth communication protocol. For that, you need a Bluetooth module.

The most common Bluetooth modules used with the Arduino are the HC‑05 bluetooth, HC-04 and HC-06.

For more information about the bluetooth module, you can check this blog post:  Reviews – HC-05 Bluetooth Module

The Bluetooth module works with serial data. This means that the Arduino sends information and the Bluetooth module receives it via serial (and vice-versa).

The following figure explains how the information flows from the Android app to the Arduino.

Your smartphone sends information to the Bluetooth module via Bluetooth. Then, the Bluetooth module sends the information via serial communication to the Arduino. This flow also works the other way around: the Arduino sends information to the Bluetooth module that sends it to the smartphone via Bluetooth.

MIT App Inventor Overview

Go to http://appinventor.mit.edu/explore/ and press Create Apps button.

Next, click on Start new project as shown in figure below. 

You’ll be asked to give your project a name. As we’re just exploring the MIT App Inventor 2 features, you can name it test.

Click OK. Your project is automatically saved.

If you go to Projects > My Projects you can see all your saved projects.

Click on the project name to open the app builder.

Designer

You’ll be presented with the Designer tab as shown in the following figure.

At 1) you select whether you are on the Designer or in the Blocks Editor tab. With MIT App Inventor you have 2 main sections: Designer and Blocks. The designer gives you the ability to add buttons, add text, add screens and edit the overall app look.

The Blocks section allows you to create custom functionality for your app, so when you press the buttons it actually does something with that event.

2) The Palette contains the components to build the app design like buttons, sliders, images, labels, etc…

3) It’s the Viewer. This is where you drag the components to build the app look.

4) Components. You can see all the components added to your app and how they are organized hierarchically.

5) Properties. This is where you select your components’ properties like color, size and orientation.

Blocks Editor

Open the Blocks editor tab.

In the Blocks editor tab, you have several sections:

1) contains the built-in blocks for creating the app’s logic. This is what makes the app define the buttons functionalities, send commands to Arduino, connect to the Bluetooth module, etc. You have several blocks grouped by categories:

  • Control: if/else statements, while loops, etc…

  • Logic: True, False, equal, not equal, etc…
  • Math: math operators.
  • Text: blocks that deal with text.
  • Lists: blocks for handling lists.
  • Colors: blocks to handle colors, like choosing a color, make color and split colors.
  • Variables: initialize variables, setting variables values, get variables values, etc…
  • Procedures: procedures are like functions. A procedure is a sequence of code blocks with a given name. Later, you can call that sequence of blocks instead of creating the same long sequence.

Inside each group, you have blocks that you can drag to the Viewer 2). In the Viewer, you drag the blocks and join them in a specific way to make something happen.

We recommend that you navigate inside the blocks section and explore what’s inside. The blocks look like puzzle pieces that fit into each other or not. If you can’t do something with certain blocks, they won’t fit.

In the backpack 3) you save code blocks to use later. You move blocks to the dustbin 4) to delete them.

Projects with MIT App Inventor

This was just a quick introduction to the MIT App Inventor. Now, its time to start building apps!

Here’s a list of  our popular Arduino and MIT App Inventor projects:

Android Apps for Arduino with MIT App Inventor 2

If you like Android Apps and Arduino take a look at our course: Android Apps for Arduino with MIT App Inventor

This is a step-by-step course to get you building cool Android applications for Arduino, even with no prior experience! A collection of 8 + 1 Projects.

Download Android Apps for Arduino with MIT App Inventor 2

I hope you’ve found this post useful.

Thanks for reading,

Sara



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

12 thoughts on “Getting Started with MIT App Inventor 2 and Arduino”

  1. Hi Sara,
    Thank you for this interesting tutorial.

    I have 2 questions :

    1) what are the differences between the 3 bluetooth modules HC-04, HC-05, HC-06 ?

    2) I don’t have an Android smartphone. Is there a similar application to MIT, but for iPhone ?

    Thank you, and best regards,
    Roger

    Reply
    • Hi Roger.
      Thanks for your comment.

      1)Regarding the differences between the different bluetooth modules, I think this link at stack exchange does a good job explaining that: arduino.stackexchange.com/questions/6541/what-are-the-fundemental-differences-of-different-bluetooth-modules-for-beginner

      2) As far as I know, there isn’t a drag and drop software to create apps for iPhone. You would need to use Xcode software and write code with Objective-C or Swift programming languages.

      Reply
      • Do you have a book showing how to create an app for cell phones using MIT App inventor followed by being able to upload to the ESP8266 dev bd or Wemos Mini D1?
        Need help on how you either export code from MIT App Invertor to some other format that Arduino IDE can import if that is even possible?
        Need help getting code created in MIT App Inventor with buttons and gauges and uploaded to the ESP8266 dev bd. If any book you have walks you through the step I have outlined I would be interested in purchasing.
        I am not a programmer so speaking to me in programming syntax will not work it need to be in plain easy to understand english.
        BTW I have purchased books from Rui before I am a returning customer.

        Reply
        • Hi Rudy.
          We have a book about building applications using MIT App Inventor to control Arduino.
          The apps interact with the Arduino using Bluetooth.
          We don’t have any information about how to do it with the ESP8266.
          Regards,
          Sara

          Reply
  2. My understanding is that recently MIT App Inventor is available for iOS (currently in beta phase).

    I’m interested in controlling ESP32 via MIT App Inventor 2 with iOS devices.

    Are you aware of any developments on this topic.

    Reply
  3. Hi,
    I just want to know how to establish the connection not by bluetooth but by the web, between my Appinventor app and arduino

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.