How to Connect MIT App Inventor to Ubidots and Make a Basic Smart Home Automation App?
Today we are going to learn how we can connect a App made in MIT App Inventor to Ubidots(Cloud) and make a basic Smart Home Automation App which also gives us an idea of how IOT based devices work in real life.
Basic terminologies used:
1. MIT App Inventor: MIT App Inventor is an intuitive, visual programming environment that allows everyone even children to build fully functional apps for smartphones and tablets.
2. Ubidots: Ubidots is a cloud based Internet of Things(IoT) data analytics and visualization platform.
So, after knowing about these basic terminologies firstly we will see how to create a device on ubidots.
Creating a device and dashboard on Ubidots:
Step 1: Open the portal https://ubidots.com/ .
Step 2: Create your account and log in on the website. After logging in you will see such kind of interface:
Step 3: Now click on devices and again select devices among all the options. Such interface will appear:
Step 4: Create a new device and variable using the following:
Create Device -> Click on blank device -> Name your device as “Smart_home” ->Click on add variable -> Select Raw -> Name your variable as “Bulb”.
Step 5: Click on data and go to dashboards and create a widget using the following procedure:
Click on Add new widget -> Select Switch -> Name your widget as “Bulb” -> Click on add variables -> Select Smart_home -> Select “Bulb” -> Click on green tick.
So, now after creating a new device and dashboard now we have to create and design our application in MIT App Inventor.
Working on MIT App Inventor:
Step 1: Open the portal http://ai2.appinventor.mit.edu/ and create a new project named Smart_home.
Step 2: Design your application as shown below and use all the essential components.
Step 3: Go to the part of the block where we have to write blocks of code to implement our application. Write or drag the blocks as shown as below:
Connecting Ubidots With MIT App Inventor :
Step 1: Go to Devices on Ubidots and copy API Label shown there and then paste it on the position shown below:
Note: This “https://things.ubidots.com/api/v1.6/devices/” will be same for all the other applications you will make in future also. So, to connect this application api label smart_home should be pasted at last of the same url provided above.
Step 2: Go to devices on ubidots and copy the token from there and paste it at the position shown below:
Step 3: Click on the variable(Bulb) and copy its API label this time and paste it at the position shown below:
Congratulations! You have completed your application. Now click on build and generate apk file for your application so that you can install it on your mobile phone.
It functions like this:
1. Open the Smart Home application on your mobile phone and by turning on the MIC speak “Turn on”.
2. You will see that switch on your dashboard automatically turns on(now say “Turn off” to turn off the bulb).
Hence, we saw how basic IoT devices work and how we can use ubidots and MIT App Inventor to build such applications.