Recieving text messages without notifiying user

Hi all!

I’m working on a project using an arduino that monitors a few sensors in a remote location. The arduino is connected to a cell module and I currently communicate with it via text messages. I currently text the arduino the message “Stat” and the arduino replies with a text message stating the current status of it’s sensors. I want to replace the text message system with an app.

I am new to app inventor and creating apps in general. I studied the ‘no text while driving’ tutorial app and worked on creating an app based off that example. In both apps, when a text message is recieved, not only does the app get the message, but the android text message app also gets the message. Ideally, I’d like to stop the android text message app from getting the text message if it’s from my arduino.

Basically, I’d like my app to get the text message, and if the caller number of the text message is my arduino, then handle the text message. Otherwise, pass it on to the android app. Is that possible?

I’m seeking advice and guidance on this…


Hello Randy

It’s not possible because of the Google Security Measures that are now part of Android. The Android device (phone) has a built-in messenger and that is the “King” of SMS.

So the device always receives text messages before any App can be used to additionally process them.

However, if you want to communicate with your Arduino, you can use Bluetooth to directly exchange text with your App and App Inventor already has the Code Blocks needed to do that - at least thousands of Users have done it. Bluetooth modules such as the HC06 work well with Arduino, using Bluetooth “Classic” in App Inventor, for example.

See my website:

Maybe Randy. Wheter this could work depends on several factors:

  • does the arduino have its own telephone number?
  • can the arduino include a key word? So that if the text includes the key word (like Hello in the example) your app can decide how to handle it.
  • are you using Companion 2.58u (not 2.58)?

This small app is a 'modern' simplification of No Texting While Driving sms

There are two versions of the sms handling routine. One searches and handles a telephone number (the one in color), the other (grayed out) handles an incoming sms depending on whether the text contains Hello or Goodbye.

This might be what you want to do @revolt_randy It requires setting ReceivingEnabled appropriately. Remember, when your app is sleeping, it is NOT in the foreground. This should work if the app is keep awake (AI2 apps cannot run in the background).


@ChrisWard - Thanks for you reply, and the links to your site. Appears to be lots of info there and I will take a closer look. My first use of AI2 was an app that used bluetooth (HC-05) connected to the arduino. I will use bluetooth when I am local to the arduino, but I want to use SMS when I’m not local to the arduino. Also, internet service isn’t available at this location, and cell service is poor, but useable. This is why I am using the SMS route.

@SteveJG - Yes, the arduino has it’s own phone number. And yes, the arduino can send a keyword, or anything else I want, I’m writing the code. As to your third question, I’m not using the companion app at all… I do like what your example suggests, would you be open to sharing the AI2 files with me?

I’m not using companion because I couldn’t get it to work, I’m blaming that on outdated computer and OS. I download the .apk to my computer and e-mail to the phone, not pretty and really slow, but it works…

Additonally, while learning about the ‘NoTextWhileDriving’ app, I noticed some differences in between the tutorial and the actual app. The app you create following this tutorial : Isn’t the same as the one you download as AI2 source. The one I built following the tutorial only asked for permission to send messages. The one I built from the downloaded source asked for more permissions and appeared to have some other parts I couldn’t find in the source…

Thanks for the help, please keep it coming!

Did you try to re-create the Blocks? It is an example showing how you can send a text message to yourself. In addition to the Blocks you only need to place thre buttons on the Designer. Actually, for your Project you do not want that.

The code posted has 45 blocks Randy. You need the colored ones in the MessageReceived block and that Block to capture the fact the Arduino is texting you. Create the initialize global phoneNumber , place a single Button on your Designer (it is only used as an indicator … Button3 … that changes color). Enter the phone number your Arduino uses in the blue puzzle piece connecting to initialize global phoneNumber. In the Screen1.Initialize block, place the set Texting1.ReceivingEnabled to 2.
Compile the app and run it. Now force the Arduino to send a Message. When it sends a message, the Button should turn red (if the phone does not go to sleep). Does turn the Button red? Alternatively, you can use the grayed out block with the keyword you Arduino can send.

Differences in the NTWD app probably due to changes Google required since late 2018 to prevent abuse using some Android tools. Don’t worry about them. The NTWD tutorials are mostly obsolete.

– Steve

Initially, no I didn't, because I didn't see any difference in the blocks. So I did build it and adapted it to work in my case.


And here's the blocks

And it works, but the text messages sent from the arduino are still going to the default android text app. Since this app is currently open, when the arduino replies, it gets the message first, then it appears to be sent to the default text app, because that app then notifies me it got the text. How do I stop the text from going to the default text app?

Do I need to look "further under the hood" to do what I want than AI2 can give me? Should I be looking at the official android development environment to accomplish this?

Thanks for the help and advice,

  • And it works, but the text messages sent from the arduino are still going to the default android text app. – yes, that is the way it works now and the way it worked when the NoTestingWhileDriving tutorial was created. The default android tet app also receives the messages. Glad that the example works. :smile:

  • How do I stop the text from going to the default text app? I don’t know. You probably can but remember, sms is a ‘dangerous’ permission issue w.r.t. Google. You will have to code an app that will become the default sms app on your phone.

  • Do I need to look “further under the hood” to do what I want than AI2 can give me? I suspect you are doing what can be done using the technology you are using. See the sms archive in the old AI2 Forum; it explains what can and cannot be done using AI2 (though you will have to dig).

  • Should I be looking at the official android development environment to accomplish this? Maybe. Even that path might be impossible. Google Android Studio sms You will have to write an sms Client that would by pass the Android system texting features.

Sorry this is not a panacea. It is what is possible with App Inventor.
Good luck.