Introduction: MIT App Inventor Particle Photon Test

About: We are retired engineers/software developers who enjoy developing projects that are useful and practical. All of our projects are well documented and are published under an open source, non-commercial license.

We (Team Practical Projects) have been developing Internet-connected projects using Particle Photon and Electron IoT devices for some years now, see:

We have used a number of services to communicate with our Particle devices, such as IFTTT and Blynk. These services work fine and do not require any programming. However, they are necessarily limited; specifically, in respect to the very limited logic that you can place in the app. This has required us put all of the logic and computation required of the project into the Particle device firmware. This is frequently undesirable; specifically when we wish to develop hardware and firmware that can be used for more than one purpose.

MIT App Inventor 2 is a very easy-to-use programming system for developing real apps. It is currently limited to developing Android apps, but the MIT team has promised iOS support in 2018. Furthermore, there are Android emulators available that will run apps created with MIT App Inventor 2 on Windows and Mac/OSX platforms.

This project is about teaching you how to develop apps in MIT App Inventor 2 that can interact with your Particle-based project. Specifically, you can develop your own app that can read Particle Cloud-exposed variables (Particle.variable() ) from your Particle device and can call Cloud exposed functions (Particle.function() ) on your Particle device. This project includes Particle firmware and a corresponding app, as well as documentation about how this code works.

This project also shows you how to include our Particle App Template into your MIT App Inventor 2 app:

This Particle App Template is also written in MIT App Inventor 2 and provides your app with the capability for a user to login to their Particle account and select a Particle device for use with the app. Including the Particle App Template inside of your app means that you can publish your app pre-built (.apk file); the user of your app does not have to manually place their Particle user access_token and deviceID inside of source code and compile it themselves.

Happy app developing!

Team Practical Projects

Step 1: Hardware

You do not need any hardware if you simply want to study our example app. However, you can benefit from building the example, including hardware, Particle firmware, and MIT App Inventor 2 software.

The hardware that you will needs uses our Water Leak Sensor printed circuit board with components, and an external LED/pushbutton switch and hobby servo. Complete information can be found at:

However, you do not have to build the Water Leak Sensor project to run this example. You can make it on a solderless breadboard using the following components:

1. Particle Photon (or Electron)

2. LED with current limiting resistor

3. Hobby servo (3.3 volt compatible)

4. (Optional) micro pushbutton switch

Instructions for building this breadboard version for the hardware are included in the Installation and User Manual:

Step 2: Particle Firmware

In order to run this example project using the hardware that you built in the previous step, you will need to load, compile and flash Particle firmware ("Test_MIT.ino") onto your Particle device (Photon). The firmware (source code) is posted at:

Instructions for compiling, flashing this firmware to your Photon or Electron, and testing that it works using the Particle Console, are in the Installation and User Manual:

Step 3: MIT App Inventor 2 Example Software

We have included a pre-built and ready-to-install version of the app at:

You can upload this file directly to your Android mobile device and install it simply by tapping on this file on your mobile device. More detailed instructions are included in the Installation and User Manual, at:

Step 4: Learn How to Write Your Own Apps for Your Particle-based Projects

This project is a turorial. As such, its primary purpose is to educate you about how to write MIT App Inventor software and corresponding Particle firmware. In order to achieve this purpose, we have included source code for both the Particle firmware and for the MIT App Inventor 2 software for this example project. Particle firmware source code is located at:

MIT App Inventor 2 source code is located at:

Note that you will need the MIT App Inventor 2 IDE in order to view and edit this source code. The IDE is a free web service that only requires you to have a free Google account in order to use it. Go to the following URL to get started with MIT App Inventor 2:

We wouldn't leave you to figure all of this out for yourself! We have included a detailed description of how this all works; see:

If you do nothing else with this project, please read through this latter document. We guarantee that you will learn a lot by doing so.

Step 5: Going Further

This demo project uses our Particle App Template. The Particle App Template provides users of your app with the ability to log in to their particle account and select the device to use with the app. In so doing, it is not necessary for a user of your project to manually enter their Particle user and device credentials into the app source code and then compile the app for their use. You can write the app for your project, build it into an .apk file (ready to install), and your users can simply install it without ever having to consult the source code (of course, we do encourage open source publication of the all source code so that users can understand the project and even make their own modifications and improvements to it).

You don't need to understand how the Particle App Template works for you to use it in your MIT App Inventor 2 apps. However, you can learn a lot more about communicating with the Particle Cloud if you review the extensive documentation that we have provided, at:

Do you still have questions? Suggestions? Want to share back? Please feel free to contact us at: