SMS Text messages

Help Index

If the user's Android device has phone functions ie: not a tablet, then they may be able to use the SMS features of BTInterface.

This is dependent on them actually being able to send and receive SMS text messages on their device and they will need to get this working first.

Outgoing SMS:  To send an SMS Text message from BTInterface the micro controller device need only send the command sms then the phone number and then the text message so:

sms 0123456789 my message

Will cause BTInterface to send the text message  ‘my message’  to that phone number! How easy is that?

The phone number must be sent without any punctuation marks or spaces, everything after the phone number is the message.

The message limit is 160 characters. If you attempt to send a message longer than this then only the first 160 characters will be sent.

Disclaimer! It is possible to send lots of messages with a micro controller, be careful of your programming as I will not be held responsible for large phone bills!

Incoming SMS:  BTInterface can act on incoming SMS messages! How cool is that! Remotely control your remote controlled device!  

This works because BTInterface monitors all incoming SMS messages, if a message starts with the SMS password which by default is bti then BTInterface will treat the rest of the message as a command or a series of commands!

Also, BTInterface will ‘silence’ this message so that users don’t end up with hundreds of bti text messages in their messaging application.

What can this be used for?

Well, as an example say you have a system where you have a micro controller connected via Bluetooth to an Android phone using BTInterface and this setup controls functions around the house, so that Android phone stays at the house within range of the bluetooth module connected to the micro controller. Well now you can control your house from any mobile phone, anywhere in the world just by sending text messages to it!

The normal SMS text message caveats apply like, they are not instant, sometimes they might take ages but usually they’re pretty quick, sometimes SMS messages get lost in the post. Programmers should bear all this in mind when developing apps and inform users of these possibilities.

SMS Settings:  Pressing the menu button on your android device allows access to the settings screen.

From here the user can decide if they want to allow BTInterface to send SMS messages, it is turned on by default but if they turn it off then SMS commands to send outgoing SMS text messages will be ignored.

The user can also turn on or off the feature for acting on incoming SMS messages. To act on incoming SMS text messages the user must set a password, this should be an unusual word that an SMS message would NOT normally begin with.

If no password is set or the smsPassword setting is set to 'disabled' then acting on incoming SMS text messages is disabled so to disable this feature you need merely clear the sms password box.

There is an sms password set by default and this is bti (because no words begin with that so there is no danger of BTInterface accidentally consuming a normal message).

The password is case insensitive so it can be BTI bTi Bti bti etc. It doesn’t matter.

Any SMS message that begins with this word will be treated as a command or a series of commands.

So from another phone you might send a text message to the android phone running BTInterface like this:

BTI cmd1

The android phone running BTInterface is looking at all the incoming SMS messages and when it sees that this one begins with the password it intercepts it, doesn’t let it go any further and sends everything after the password over the bluetooth link to the micro controller.

It will also act on any normal commands like: screen1, hide, sfx2, say, even sms! So your sms message can cause BTInterface to send an sms message! (Beware of causing infinite loops!).

In the above example this will cause BTInterface to send the word cmd1 over the bluetooth serial link to the micro controller device.

Your micro controller device program will normally be running a main loop where it is constantly checking for incoming text from the bluetooth serial module, when it sees the string ‘cmd1’ it will then activate the subroutine that you have set to carry out the commands that you have programmed for the action cmd1  

Here is some pseudo code to illustrate:



If SerialIn = “abcd” then abcd

If SerialIn = “cmd1” then  command1

GoTo MainLoop

Function command1

 servo = 20


 delay(1000) ‘wait a second

 SerialSend(“toast Ok done cmd1”)

  delay(1000) ‘wait a second

 SerialSend(“sms 0123456789 Message from Micro Controller, the action cmd1 has been successfully carried out.”)

 delay(1000) ‘wait a second

 SerialSend(“say Ok I have completed the function command 1”)

End Function

It would be a shame to waste all those other characters in an SMS message (up to 160 characters per message) so you can send a series of commands in the same text message by using the ; (semi-colon) character to separate them like this:

BTI cmd1; cmd2; cmd3; cmd4

(You don’t need a semi-colon after the last command)

When BTInterface intercepts this SMS Text message (because it starts with the sms password) it will split up all the commands and put them in a row and then start to send them over the bluetooth serial link to the micro controller device and act on any commands that it recognizes such as sfx or say commands.

Each command will be sent one after the other and this might be too quick for your micro controller to keep up with so remember that you can use the pause command which is sent as just the letter p to save space:

BTI cmd1; p; cmd2; p; cmd3; p; cmd4

Each pause is for one second and you can use more than one at a time like:  p; p; p; etc.   

You can also use p with a number (in milliseconds) so p1000 is the same as just p or you can do other numbers such as p5000 or even p25000 etc.

You can omit the spaces after the semicolons if you wish to cram even more into your text messages:

Bti cmd1;p;cmd2;p;cmd3;p;cmd4

But note that there must be a space after the sms password and after some command words that require extra text after the command (like ‘say’) depending on how you have programmed them.

The sms password must be the first word in the text for BTInterface to pick it up and act on the text. It can be upper or lower or mixed case. There must be a space after it.

You can change the sms password in the settings to a word of your choice to keep it secret.

For anyone to be able to get your android device to act on sms texts they would need to know the phone number of the android device and the sms password.

Just remember that if you leave the password as the standard of BTI then anyone who knows your mobile phone number could potentially send texts to your device to control it!

Everything in sms commands is passed on over the bluetooth interface so for example if you send the command

BTI b1

Then b1 will be sent over the interface and can be used the same as if the user had pressed the b1 button on screen1

Just about any command can be relayed to the micro controller using SMS Text messaging.

I know, it is really easy isn’t it :) and a lot of Fun!

I have a lot of fun developing BTInterface too!

SMS commands are represented in the terminal screen log by being doubled up where you see the same command twice, one being received and one being sent and this is a good indication that it was an sms command.

I am always working to make BTInterface more flexible and add new features etc. Please have a look at the supporting website at

and please feel free to join the forum to let me know your ideas and wishes for the next versions of BTInterface.

Help Index