How To Use Firebase With MIT App Inventor 2

How To Use Firebase With MIT App Inventor 2

No doubt, MIT app inventor is one of the easiest ways to develop apps for project or hobby. If you want to develop a simple IOT based project, you certainly need a real-time database. Though there are many players in the game but google firebase is best among all. So here is a tutorial on How to use firebase with MIT app inventor or How to integrate firebase with MIT app inventor 2.

What Is Google Firebase And What Is Google Firebase Used For?

Firebase is primarily used for app development, cloud messaging, real-time database, storage, hosting, social authorization, and analytics.

Firebase is a platform offered by Google which can be used as backend storage. In simple words, we can say that firebase is a cloud-based database. It provides one of the most stable and fastest real-time databases.

Here, in this post, we are going to use Google firebase as a real-time database. First of all, we will see how to integrate firebase with MIT app inventor 2. After that, we will get deep into how to use the app inventor to read data from firebase. We will also see, MIT app inventor logic to update the database using an app.

How to use firebase with MIT app inventor 2.

Integrating firebase with app inventor is straightforward and it can be done in 3 simple steps.

1. Create real-time database

  • Navigate to Google Firebase and login using your google account. It will redirect you to Google firebase console.
welcome firebase iot
  • Click on new project, enter a project name and cloud firestore location, then hit create project button.
Google firebase console new project
  • Search for Develop option in the left panel, then expand Develop and select Database. It will open the firebase database catalog. Scroll down to select real-time database and click on create database button.
  • Keep Security rules for Real-time Database in locked mode and enable it.
Security rules for Realtime Database

Now your database is enabled and online. Its time to find out secret database details (URL + KEY) so that you can access it remotely.

2. Find real-time database authorization details

Open your database and copy Real-time database URL. Paste the link to firebase database on the notepad.

Realtime database URL

Click on Project Overview option on the left panel and select project settings. Navigate to Service accounts >> Database secrets >> Secret. Copy the database authentication key and save in a safe location.

realtime databse secret key

3. Integrate firebase with MIT app inventor

  • Find the “Experimental” option (located in the left palette window) and expand it. Drag and drop “FirebaseDB” in the workspace (viewer window).
  • After that, create a new project and give it any desired name.
FirebaseDB app inventor properties
  • Left click on FirebaseDB1 (at bottom of viewer window) to see properties of the database. In the properties window, paste database URL and database secret key (copied in step 2).
  • That’ it, now you are ready to use google firebase with MIT app inventor. Now, let’s dig a little bit deeper in how to read/write data from/to firebase using app inventor.

How To Write Data To Firebase Using MIT App Inventor?

As we say, the best way to learn something is to do it (Do it Lean it), let’s create a simple app which can write data to firebase. At this point, I am assuming that you had already integrated firebase with app inventor. Now we need to add some other components.

  • Drag and drop a TextBox and a Button to the workspace. Click on the button and give it a name (let it be “Write Data”).
Write data to firebase
  • After that, click on BLOCKS option located at the top right corner of Windows. This is workspace where we will write our logic. Create logic as shown below.
Write data to firebase logic
  • Then click on build and save apk file to your PC, transfer file to smartphone and install on it.
dowwnload firebase apk

Run the app, enter something in the text field and click the button. Your data would be saved to firebase. You can view saved data by visiting Google firebase console.

How To Read Data From Firebase Using MIT App Inventor?

  • Drag a label and second button (let it be Read Data).
Read data from firebase
  • Add code blocks as shown below. Save it and run on any android device or android emulator.
use firebase with mit app inventor

After that, go to console and edit value manually or write any value using app. Then press “read data” button and it will fetch and show new data in label.

In this way you can update or fetch data from firebase. You can use it for developing app or any IOT based project. So what are you waiting for? Go and expand your wings of creativity!

Still have any doubt? Check out this awesome video by Tech Mania. And Tech Mania, if you are reading this, A BIG THANKS for making the helpful video 😉

For further reading, you can also check out a demonstration for app using firebase.

Wrapping UP!

Hope you find this tutorial useful. Please feel free for queries. And Best Of Luck for upcoming IOT adventures.

8 thoughts on “How To Use Firebase With MIT App Inventor 2”

  1. Richy….THANK YOU very much for this post or blog.

    ALL information on Youtube, Google, shown a parts with Firebase with RULES on “TRUE”, Read an Write, BUT the REAL WORK is with these two rules protected, and the Database Protected.

    All tests and hours of reading and see videos with the simple solution of unblock the database is for create the app only, but not to work.

    You explain very well this BIT or BIG information to continues the app.

    Thank you newly

  2. Hi, I got a question, when we read data form Firebase Databased, is it stored in phone? Or as soon as we close it i gets deleted, or it is never downloaded?

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.