Home > Arduino > WiFi SMS Gateway

WiFi SMS Gateway

September 5th, 2009 Leave a comment Go to comments

After a long search on the internet, trying to find a cheap SMS Gateway, I got the idea to create one myself.
As I already had a GM862 module laying around, and I’ve got the WiShield WiFi module for the Arduino too, I thought it would be easy – but it wasn’t!

The hardware setup is pretty easy, except the powering for the GM862, as it requires about 3.8V. That was made with a Linear LT1528 3A low dropout voltage regulator.
After alot of testing and measuring, I finally made a working circuit, and afterwards an Eagle Schematic.

WiFi SMS Gateway - Schematic

WiFi SMS Gateway - Schematic


In the following picture you will see the hardware setup, which consists of the Arduino with the WiShield on the top, the GM862 on two breadboards, and alot of wires!

WiFi SMS Gateway - Hardware

WiFi SMS Gateway - Hardware


But the real problems appeared when I started programming! I had alot of troubles with the serial connection between the Arduino and the GM862 module, which apparently wasn’t caused by the hardware setup!

After alot of debugging I figured it out, and a simple SMS sending code was working 🙂
Then after a couple of hours I’ve added the WiFi parsing code which sends an SMS to the requested number, with the requested message, read from the GET parameters!

You can grab the code here, and try it out:

 * WiFi SMS Gateway sketch by Thomas Jespersen - http://elec.tkjweb.dk/blog
 * --- Remeber to change the PIN, if any, in the setup() routine! ---

#include <WiServer.h>


// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,111};	// IP address of WiShield
unsigned char gateway_ip[] = {192,168,2,254};	// router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};	// subnet mask for the local network
const prog_char ssid[] PROGMEM = {"SSID"};		// max 32 bytes

unsigned char security_type = 0;	// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"Passphrase"};	// max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,	// Key 0
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 1
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 2
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	// Key 3

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------

//unsigned byte TimeBeforeConnection;

unsigned int lastSMStime = 0;

   char number[7];
   char* message;

void sendSMS() {
  if (millis()/1000 > lastSMStime) {
    for (int i=0; i < 8; i++) {
    // Replace with a valid phone number

    // End the SMS with a control-z
    lastSMStime = (millis()/1000) + 2;

// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {

    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<head><title>TKJ's SMS Gateway</title>");
        WiServer.print("<h1>This is TKJ's SMS Gateway</h1><br>");

        // URL was recognized
        return true;

    // Check if the requested URL starts with "/?"
    if (URL[0] == '/' && URL[1] == '?') {
        for (int i=0; i<8; i++) {
          number[i] = '0';
        message = "";

        for (int i=0; i < 8; i++) {
          number[i] = URL[i+2];
        for (int i=0; i < strlen(URL); i++) {
          message[i] = URL[i+10];

        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<head><title>TKJ's SMS Gateway</title>");
        WiServer.print("<h1>The SMS is now sent!</h1><br><p>");


        // URL was recognized
        return true;

    // URL not found
    return false;

void setup() {
  // Turn GSM Module ON
  pinMode(3, OUTPUT);
  digitalWrite(3, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(3, HIGH);

  // Type Mobile SIM Pin Code
  // Remember to change the PIN, if any

  // Initialize WiServer and have it use the sendMyPage function to serve pages

  // Enable Serial output and ask WiServer to generate log messages (optional)


void loop(){

  // Run WiServer

Categories: Arduino Tags: , , , , ,
  1. July 22nd, 2011 at 14:17 | #1

    Hi, i’m interested on this project of yours (wifi sms gateway). I’m developing similar device but without the wifi shield. I;m trying to power arduino & Gm862 telit module like yours with just one power source. I see from your schematic, there are 7 resistors. But from the photo, you have more than that. Can you have the list of components used ? or updated schematic ?

    Thank you

  2. July 30th, 2011 at 20:51 | #2

    Dear Amri.
    Haha, great spotted 🙂
    Though the reason why I have more resistors on the board is because I didn’t have the exact values as needed (shown in the schematic). So instead I’ve connected 2 or 3 resistors in series to make the value needed.
    The schematic is confirmed to be working, so no need to change or update that.


  3. Amri
    August 4th, 2011 at 03:57 | #3

    Hi Thomas, what if i want to power the arduino with battery ? let say 7.4v poly battery. Do i need two voltage regulator ? one from the battery to arduino and the second from arduino to gm862 modul ?


  4. August 4th, 2011 at 11:20 | #4

    Dear Amri.
    No, it is not neccesary to use a second voltage regulator. You should just connect the 7.4V battery to the VIN pin of the Arduino.
    Then the Arduino will take care of regulating this to 5V, which it requires. Then you should also connect the VIN (7.4V) to the Vin of the voltage regulator for the GM862 module.

    Best Regards
    Thomas Jespersen

  5. Amri
    August 5th, 2011 at 08:05 | #5

    Hi Thomas, thanks for your guidance. Really appreciate your help 🙂

  6. Amri
    November 27th, 2011 at 14:25 | #6

    Hi Thomas,

    I’m new to electronic. Can you explain why do you put R3, R4, Ground for TX connection ? and what should i use for RX connection (if I want to have this connected) ?

    Basically, i want to know why can’t i just connect these two straight away ?

    Thank you so much 🙂

  7. November 28th, 2011 at 12:27 | #7

    Dear Amri.
    I use these two resistors to form a voltage divider to make a proper voltage for the GSM module.
    The voltage coming out of the Arduino is 5V, though the GSM module only supports around 3V. By using this voltage divider I make the 5V signal into a 3V signal!

    If you want to use the RX (output from GSM module) you should be able to connect it directly, as the Arduino supports 3V as input treshold.

    Best Regards
    Thomas Jespersen

  8. Amri
    November 28th, 2011 at 12:52 | #8

    Ahhh I c, if i’m planning to use Arduino Fio (which uses 3.3 v input from a battery). I won’t need thoses transistor for RX and TX right ? note: I’m planning to power both arduino fio and the gm862 from a poly battery 3.7v

  9. November 28th, 2011 at 17:32 | #9

    Powering the GM862 directly from the battery would be OK, as the power supply should be between 3.40V and 4.20V.
    The Fio will regulate the 3.7V power supply input to 3.3V so yes, you would actually be able to connect it directly to the GM862 module, without having to use any voltage dividers.

  10. Turbay
    March 10th, 2012 at 19:28 | #10

    Thanks, Thanks!! nice men!

  1. No trackbacks yet.