Trying to get my MIT app to send SMS when it doesn't receive a signal from Arduino

Hi Folks,

I had my app set up that when it receives bytes from my Arduino it sends an SMS with GPS..

I am now trying to get it to send a SMS when it doesn't receive a signal.

End result is for the app to receive an initial signal and then to check for another signal every minute, if it doesn't receive another signal it will send the SMS. Not to sure if this can be done in MIT App Inventor.

I tried the below blocks but it seems it reads the signal then it doesn't send the SMS due to the timer set to 60000 .. if I take out the timer it continually sends the SMS..

Again any help would be greatly appreciated.

Thanks ....

You are missing a global variable LastSignalReceivedMS, initially 0.

Using this variable simplifies your code, eliminating one of your Clocks.

Whenever a signal arrives, set LastSignalReceivedMS to Clock1.SystemTime and send an SMS.

Every Clock Timer, if no signal has arrived yet, subtract LastSignalReceivedMS from Clock1.SystemTime to get the interval (ms) from the last time you sent an SMS. If the interval is high enough, set LastSignalReceivedMS to Clock1.SystemTime and send an SMS.

1 Like


If the App is only for your own use, you can build an APK and install on your device (phone). The SMS can use the 'legacy' setting SendMessageDirect() to send the message directly to the recipient automatically, which I am sure is your requirement.

Unfortunately, the default SMS action, SendMessage(), is to pop-up the phone's built-in SMS App, waiting for the device User to approve sending it - this is a Google security measure, so it is the same for any platform used to develop Apps for Android. If you want to distribute your App via Google Play Store, you cannot use SendMessageDirect().

Think of 'BytesAvailableToReceive' as a flag - it does not necessarily record the total bytes available. To ensure the App receives all Bytes, use the Math Block '-1'.

Dear @atierne1, everything said by @ABG and @ChrisWard applies, but where is clock3 ?

Normally I use the location sensor with a much shorter period and with the highest resolution, like this:

It works, and with these values I can use the GPS to control the position and the speed of a car.

As far as the detection of a missing Arduino "live" signal is concerned, what I suggest is: on Arduino side you shall send every 30 seconds a live message to the app, then the app, on its side has to check every 60 s if the message has been received. In a nuthshell: the sender shall send twice for each period: this avoids that, due to time shift (remember that the clock of Arduino is completely asynchronous with respect to that of your app) the app declares a missing message from Arduino. Then every time that the app receives the message it sets to "true" a boolean variable. To perform the control that Arduino is still alive, the app has a clock that fires every 60 s and checks for this variable, if it is set to true, everything is ok, otherwise sends the SMS. Before exiting it sets always the boolean to false. This variable will be turned to true only if the Arduino "live" message is received within the next 60 seconds. Something like::

In the above example the Screen initialize block sets periods, and enables the clocks. This implies that you "untick" the checkboxes TimerEnabled and TimerAlwaysFires at design level.
Best wishes.

1 Like