Introduction: Remote Control Any Device Via SMS Using Arduino, RELAY Boards and C-uGSM or D-u3G Shields

About: electronics, software, ....

Some times ago, I felt the need to have remote control for switch on and off some outdoor lighting. Looking in my backyard, I choose some components and I build this SMS CONTROLLED RELAY(S) bundle.

Here, I share this project with you, maybe will be useful for you at certain time. You can control any electronic device that has ON/OFF switches, the same setup will apply.

Step 1: Gathering the Parts Together

For this project you'll need very few parts:

* Those shields are pin 2 pin compatible, first one it is quad band GSM only(world wide compatible) and has support for 2SIMs and the second one it is SINGLE SIM 3G only (North American version) / 3G+GSM (European and rest of the world version). Those shields are compact as 1.25"x1.57"(31.75x39.88mm) / 1.35"x1.57"(34.29x39.88mm), weight around 10g, have USB support (communication and powering), auto level 3V-5V digital interfaces and Lithium Polymer charger integrated. Can be directly interfaced with all Arduino boards (and clones), Raspberry PI (all versions), Beagle Bone or other ARM Linux boards and with any 3-5V microcontroller.

Step 2: ...and, Do Not Forget the Core Logic... One Mega328p Based Arduino Like Board

Choose one from Arduino Pro Mini or Arduino UNO, shown up-here. Or, you may port the configuration to any Mega328p board or to other Arduino platform, if you like to.

Step 3: Putting the Hardware Together - Logic Wiring

All the logic wiring it is represented in the picture up-here. Just chose your Arduino board before! :D Connect the wires between boards accordingly to the color code.

HINT: Observe the GREY wires (connections between Arduino and the RELAY board(s)).

  • if you want to use one RELAY board (2 relay commands via SMS), it is not needed to wire GREY2 and GREY3
  • in some cases, depending on RELAY board(s) used and your application replace those wires with resistors I've told before (1-10kb).

You can chose any from c-uGSM and d-u3G micro shields. The very same wiring may apply, just observe and start from the right-down corner to the left (as represented in the schema picture).

Powering wiring it is not represented here, but:

  • Arduino Pro Mini or Arduino UNO needs 5V power supply.

  • RELAY board(s) needs 5V or 12V, depending on model chosen.

  • for the modem - "WITHOUT Lithium Polymer configuration" configuration >> connect +4V power supply (g-SPS 4V [DDRV] recommended) to the 3G/GSM shield "Vcc 4V" pin OR, "WITH Lithium Polymer" configuration >> connect +5V power supply (g-SPS 5V [LiPOL] recommended) to the 3G/GSM shield "Vin 5V" pin, depending on the configuration chosen. Read more about >> c-uGSM and d-u3G how to start

Step 4: Software or Let's Do the Magic

a. Start making a folder named "SMS_RELAY_controller_light".

b. Download the "c-uGSM kickstart for Arduino" from c-uGSM CODE SAMPLES and UTILITIES, or "d-u3G kickstart for Arduino" from d-u3G CODE SAMPLES and UTILITIES if you use the d-u3G shield. Product IEME and your email address it is required in order to perform the download.

c. Unzip the archive and copy "cuGSM_basic_lbr.h", "cuGSM_basic_lbr.ino", "cuGSM_SMS_lbr.h" or "cuGSM_SMS_lbr.ino" ("du3_basic_lbr.h", "du3G_basic_lbr.ino", "du3G_SMS_lbr.h" or "du3G_SMS_lbr.ino" - 4 d-u3G users) files to the folder previously created.

d. Download (right click and save as... in the previous created folder) the Arduino code from the link bellow:

SMS_RELAY_controller_light.ino (via SMS CONTROLLED RELAY using GSM/3G SHIELD) - main code

Set the code parameters

First, it is recommended to check the supported SMS number format by your NMO (network mobile operator), manually or using our kickstart application (the downloaded package that contains the needed libraries).

Edit the "SMS_RELAY_controller_light.ino" (double click on the file; this one will be open by the ARDUINO environment). Write in your AUTHORIZED mobile number on line 19 (modify phoneNumber variable).

You may edit, also:

  • the SMS commands and the SMS REPLY messages on line 31, 32 and 33.Check modified messages length and adjust the size of those variables.
  • if you use the c-uGSM shield comment line 17. Don't need to this if you use the d-u3G shield.
  • if you use one board with 2 RELAYS, comment line 21. Don't need to this if you use 2 boards with 2 RELAYS each.


Step 5: What This Little Baby Does? Behavior and Where to Go From Here.

On BOOT, send awake message to the master recipient ( set by phoneNumber variable).

Receive SMS, check AUTH (check for authorized sender number, same phoneNumber variable), parse message and switch ON/OFF the RELAY outputs.

Execution message format:

  • 4RELAY version: rel0,rel1,rel2,rel3 where relX can be 1 for activate relay, or 0 for release relay
  • 2RELAY version: rel0,rel1 where relX can be 1 for activate relay, or 0 for release relay

For other received SMS, makes the ALARM to reply with a sort of "help message".

Ready to roll >> save, compile and upload the code. Enjoy!

Where you may go from here!

If you enjoyed this project, you may add it to your favorites, or you may follow me. Also, you may like to check my other projects.

Soon (next week, maybe), I will publish the DTMF and TCPIP versions for this hardware. Just check later.

Thank you for you time and for your interest!