Main Site Documentation

SM5100B Cellular Shield


#1

I have searched throught the forum and seen this topic http://www.tinyclr.com/forum/2/2867/.
As far as I could read Stefano managed to get it to work on the Domino.
I have a question in regards to the wiring… When Stefano said connect D2 to D0 and D3 to D1. Reading into it does that mean connect:
D2(Cell Shield) to D0(COM1 IN on the domino) ?
D3(Cell Shield) to D1(COM1 OUT on the domino) ?
When I purchased this module I thought it was plug and go but the realised there are jumper settings for soft serial mode or Uart; its that part that seems to be eluding me!
As a dev my leccie skills need somewhat improving so apologies in advance!


#2

There are little solder jumpers. You need to use the COM pins D0 and D1


#3

Ahh… Cool… Clears that up… I was thinking the framing errors I was getting was down to the serial connect setting… Back to the drawing board!!
I have it stacked on the domino and am powering the shield with the dc 7-12 socket with the usb connected for debugging. Do you think this could be causing the framing errors? A lack of power?
Any help would be very much appreciated! :wink:


#4

Hello,

[quote]D2(Cell Shield) to D0(COM1 IN on the domino) ?
D3(Cell Shield) to D1(COM1 OUT on the domino) ?[/quote]

This is right! Or if you want you can solder the jump on the SM5100B. This is due to the fact that other developing boards (e.g. netduino by Secret Labs) have a COM2 on D2 and D3, but you need to use the COM1 on domino board.

I did not get what your problem is. What is your target? I used the module to send and receive SMS. I’m now trying to use the TCP/IP stack, but I don’t have many time to dedicate to this project.

Please post the code you are developing and the error you get!

I powered the board with an external power supply (5V).

Bye!

Ste.


#5

Thanks for the replies chaps… I appreciate you taking the time to reply! 8) As it turns out I really should have just done some further research! :-[

After Gus replied I went back and studied the schematic and got to grips the the jumpers. I have soldered them so that the shield tx rx routes through COM1 on the domino.

Then i checked out the data sheet and done some research on the board itself. The power it requires was more than the DC socket on the domino could provide. I was adding 7.5 volts through the DC socket on the domino. I have now purchased a 12VDC 2A supply to power the shield externally. To make sure this was ok to run through the shield I looked up the voltage regulator data sheet and Vin max is 16V @ 3A so I should be ok to connect through the Vin socket. Hopefully that should sort out my power issues.

My initial goal is to send/receive messages and respond to basic commands. Then move on to testing more of the features it provides.

With regards to my code I have just opened up the port and hooked up the two event handlers. I was expecting to see some SIND messages as the module initialises? I was getting random FrameErrors but then again I wasn’t using the correct power supply so I can’t rely on any testing so far! Here is the code I am using:


using System;
using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

namespace GSMDevice
{
    public class Program
    {
        static SerialPort gsmSerialPort;
        public static void Main()
        {
            gsmSerialPort = new SerialPort(Serial.COM1, 9600, Parity.None, 8, StopBits.One);
            gsmSerialPort.DataReceived += new SerialDataReceivedEventHandler(gsmSerialPort_DataReceived);
            gsmSerialPort.ErrorReceived += new SerialErrorReceivedEventHandler(gsmSerialPort_ErrorReceived);
            gsmSerialPort.Handshake = Handshake.None;
            gsmSerialPort.Open();

            while (true)
            {
                Thread.Sleep(100);
            }
        }

        private static void gsmSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            var inBuffer = new byte[gsmSerialPort.BytesToRead];
            gsmSerialPort.Read(inBuffer, 0, inBuffer.Length);
            var newText = String.Empty;
            newText = new String(System.Text.Encoding.UTF8.GetChars(inBuffer));

            Debug.Print(newText);
        }

        private static void gsmSerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {

            switch (e.EventType)
            {
                case SerialError.Frame:
                    Debug.Print("Serial FrameError");
                    break;
                case SerialError.Overrun:
                    Debug.Print("Serial Overrun");
                    break;
                case SerialError.RXOver:
                    Debug.Print("Serial RXOver");
                    break;
                case SerialError.RXParity:
                    Debug.Print("Serial RXParity");
                    break;
                case SerialError.TXFull:
                    Debug.Print("Serial TXFull");
                    break;
                default:
                    break;
            }
        }
    }
}


#6

Robert,

better to use a Q&A approach for this module, instead of using the event handler. So you write something to the serial port and then immediately read the response.

This is the code I use to send a command to the GSM module.


 static string sendCommand2GSM(string command, int delay)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(command);
            GSM.Write(bytes, 0, bytes.Length);
            Thread.Sleep(delay);
            byte[] inData = new byte[GSM.BytesToRead];
            GSM.Read(inData, 0, GSM.BytesToRead);
            string str1 = new string(Encoding.UTF8.GetChars(inData));
            return str1;
        }

where GSM is a


static SerialPort GSM = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);

The delay to use differs for each GSM command: e.g. sending a message will be a longer process than reading the GSM signal power.

This is the code I use to send a message:


static void sendSMS(string message2Send)
        {
            try
            {
                GSM.Open();
                string GSMResponse = "";
                string GSMCommand = "";
                GSMCommand = "AT+CMGF=1";
                GSMResponse = sendCommand2GSM(GSMCommand + "\n\r", 1000);
                GSMCommand = "AT+CMGS=\"00XXXXXXXXXXXX\"";
                GSMResponse = sendCommand2GSM(GSMCommand + "\n\r", 1000);
                GSMResponse = sendCommand2GSM(message2Send + (char)26, 15000);
            }
            finally
            {
                GSM.Close();
            }
        }

where XXXXXXXX is my telephone number.

This is the code I’m using to receive a message. Please note that my application is only searching for a RESET string into the received messages. I’m not parsing the message content because I don’t need this.


 static string receiveSMS()
        {
            string sms = "";
            try
            {
                GSM.Open();
                string GSMResponse = "";
                string GSMCommand = "";
                GSMCommand = "AT+CMGF=1";
                GSMResponse = sendCommand2GSM(GSMCommand + "\n\r", 1000);
                GSMCommand = "AT+CMGL=\"ALL\"";
                sms = sendCommand2GSM(GSMCommand + "\n\r", 1000);
                GSMCommand = "AT+CMGD=1,4";
                GSMResponse = sendCommand2GSM(GSMCommand + "\n\r", 1000);                         
            }
            finally
            {
                GSM.Close();            
            }
            if (sms.IndexOf("RESET") > 0)
            {
                ... do something
            }
            return "OK";     
        }

VERY IMPORTANT: after you power up the module, YOU HAVE TO WAIT FOR ITS INITIALIZATION!!! It keeps about 30 secs to start up (think at the time your cell phone needs to be ready to make a call).

So use a Thread.Sleep(30000) before using the module!

Hope this helps!

Stefano.