AI2-MIOIO Twitter Alarm

In this project the intention is to show how to use the Twitter block in a practical way.
Consists of receiving a signal from the ultrasound connected to the MIOIO-AppInventor Card and in case of exceeding a distance marked will send a Twitter alert to a specific user.

This practice consists of two parts, the implementation of an application on Twitter, and the implementation of the application in  MIOIO-AppInventor 2.


To get started the first thing to do is to get the user codes and secret code that Twitter provides for the use of external applications.
To do this we created an application on Twitter following the instructions below.

  1. We go to and click on Create New App.aplicacion-twitter_01
  2. Fill in the data of the application without forgetting to fill in the two boxes of the url of the web.aplicacion-twitter_02
  3. Click on Create twitter appaplicacion-twitter_031
  4. Once created it shows the details, now touches on the tab superior Keys and access Tokensaplicacion-twitter_04
  5. This tab shows the Key API and Secret API, which will be the data we need when creating the application in MIOIO-AppInventor 2.

If you have achieved this you are on the right track.



Now let's see how the blocks are mounted with the MIOIO-App Inventor 2 so that the application warns us by Twitter when a distance is exceeded with the ultrasound.

The blocks in the part of the designer that we are going to need are:

  1. Ultrasound block MIOIOBOT. (Remember that if you use this block is because you have the ultrasound physically connected to the MIOIOBOT card).
  2. Clock block.
  3. Twitter block.
  4. 5 blocks labels.
  5. 3 blocks text fields.
  6. 3 button blocks to authenticate the user and start the application.
  7. Block notifications to notify us if you are not connected to Twitter.

Drag all those blocks into the designer with the following structure:

twitter diseño


In the properties of the FieldText3. Let's check the box for just numbers.
In the properties of the Clock1 we deactivate the timer, and we will manually activate it from the blocks when we are interested.


Now we go to the part of blocks and put the blocks according to the following figure:

We create the variables that we are going to use, including the ones that include the codes that we obtained from the application we created on Twitter.


We implemented the functions that we want the buttons to have.
Buttons 1 and 2 will serve to authenticate us on Twitter, and it will be that user who sends the message.
The button 3 will serve to activate the clock timer and thus start the application.



Once the user has been authenticated by Twitter, it will show us in (Label1).


As we are going to use a sensor of the MIOIOBOT card we need a sample time, with which the data of the sensor will collect them in the timer of the Clock1. Now we will use this timer to perform the periodic operations we want, such as sending the message (FieldText2) to the user (FieldText1), to represent the state of our authorization in Twiiter (Label1) and to show the distance the sensor is picking up Ultrasound at each time interval (Label1). In addition, we compare the distance we have entered in (FieldText3) with the current distance of the sensor (global variable).


You can download the project from here.


Leave a Reply

Your email address will not be published.