layout | title | permalink |
---|---|---|
code |
GSM Shield |
/GSM Shield.htm |
Learn how to use the SeedStudio GSM shield
- Seed Studio GSM shield{:target="_blank"}
- Move the two switches to the rigth (Serial port select as indicates in the image) to select the hardware serial {:width="400"}
- Create a new project from the template.
- Replace the existing code in main.cpp with the following code:
- Add to the project the files GSM.cpp, HWSerial.cpp, SIM900.cpp and sms.cpp found in GSM Library
{% highlight C++ %} // Main.cpp : Defines the entry point for the console application. // // Sample application for sending SMS using GSM library - dacol 07/2014 //
#include "stdafx.h"
#include "arduino.h"
#include "SIM900.h"
#include "sms.h"
SMSGSM sms;
// Helper function for logging to debug output and the console
void CustomLogging(char* str)
{
OutputDebugStringA(str); // for VS Output
printf(str); // for commandline output
}
int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}
void setup()
{
CustomLogging("Init GSM module.\n");
gsm.begin(19200);
}
void loop()
{
// Add your phone number
char phoneNumber[] = { "+49151123456" };
char smstext[] = { "Hi, This message was sent to you By Galileo" };
int smsCounter = 0;
int maxSMSSent = 1;
CustomLogging("Sending sms.\n");
if (smsCounter < maxSMSSent)
{
sms.SendSMS(phoneNumber, smstext);
smsCounter++;
}
CustomLogging("sms sent.\n");
}
{% endhighlight %}
« Return to Samples{:role="button"}{:class="btn btn-default"}