The GSM shield allows the Arduino to connect to cellular networks. This opens the door for many interesting outdoor solutions.
There are all kinds of shields available. Make sure that the shield you are using is configured to work with pins other than 0 and 1 (which are used for programming the Arduino). We will use SoftwareSerial with AsyncStreams to communicate with the GSM module.
The GSM shield is controlled with AT commands. There are many online resources about the supported commands. Here is a one: http://www.codeproject.com/Articles/85636/Introduction-to-AT-commands-and-its-uses
The GSM code module, included in the attached example, implements the most common commands.
- Sending and receiving SMS messages.
- Making phone calls (the speaker part is not implemented).
- Incoming phone calls.
- Checking the registration status.
Only one task can be done at a time. So there is a "busy" flag that is set and cleared to make sure that commands do not mix.
In this specific example the led is controlled with SMS messages. The button sends a "click!!!" message:
Sub btn_StateChanged (State As Boolean) If State = False Then GSM.SendSMS(phoneNumber, "Click!!!") End If End Sub Sub MessageArrived(msg() As Byte) If msg = "On" Then led.DigitalWrite(True) Else if msg = "Off" Then led.DigitalWrite(False) Else Log("error: ", msg) End If End Sub
2.3 KB Views: 948