I have the sm5100b
after a lot of problems with the baud rate i finally have been able to send a ams
But...
now i am trying to connect to ethernet
for this i found the following code on the web
but i think it is not ussible with my shield because nothing happens
my first question now is...
is the code ok?
and can i use it with the sm5100 or is there a better or other web client?
/*
Web client
This sketch connects to a website using a GSM shield.
Circuit:
* GSM shield attached
created 8 Mar 2012
by Tom Igoe
*/
// libraries
#include <GSM3MobileClientService.h>
#include <GSM3ShieldV1ClientProvider.h>
#include <GSM3ShieldV1AccessProvider.h>
#include <GSM3ShieldV1DataNetworkProvider.h>
// APN data
#define GPRS_APN "m2mkit.telefonica.com" // replace your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// initialize the library instance
GSM3MobileClientService client;
GSM3ShieldV1ClientProvider s1client;
GSM3ShieldV1DataNetworkProvider gprs;
GSM3ShieldV1AccessProvider gsmAccess; // include a 'true' parameter for debug enabled
// This example downloads the URL "http://arduino.cc/"
// URL, path & port (for example: arduino.cc)
char url[] = "arduino.cc";
char path[] = "/";
int port = 80; // 80 for HTTP
void setup()
{
// initialize serial communications
Serial.begin(9600);
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if((gsmAccess.begin()==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(url, port))
{
Serial.println("connected");
// Make a HTTP request:
client.print("GET ");
client.print(path);
client.println(" HTTP/1.0");
client.println();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available())
{
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.available() && !client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
Then you should compare the setup routines from each sketch. There must be a reason it is failing in the attempt to connect to your provider. This is the loop I suspect is failing.
that is totaly different because now it is about data
this is the running sms code
/* Example 26.3 GSM shield sending a SMS text message
http://tronixstuff.com/tutorials > chapter 26 */
#include <SoftwareSerial.h>
SoftwareSerial cell(2,3); // We need to create a serial port on D2/D3 to talk to the GSM module
char mobilenumber[] = "xxxxx"; // Replace xxxxxxxx with the recipient's mobile number
void setup()
{ //Initialize serial ports for communication.
cell.begin(9600);
Serial.begin(9600);
delay(35000); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
}
void loop()
{
cell.println("AT+CMGF=1"); // set SMS mode to text
Serial.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS="); // now send message...
Serial.print("AT+CMGS="); // now send message...
cell.write(34); // ASCII equivalent of "
Serial.write(34); // ASCII equivalent of "
cell.print(mobilenumber);
Serial.print(mobilenumber);
cell.write(34); // ASCII equivalent of "
Serial.write(34); // ASCII equivalent of "
cell.println();
Serial.println();
delay(500); // give the module some thinking time
cell.println("They call me the count... because I like to count! Ah ha ha ha"); // our message to send
Serial.println("They call me the count... because I like to count! Ah ha ha ha"); // our message to send
cell.write(26); // ASCII equivalent of Ctrl-Z
Serial.write(26); // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
do // You don't want to send out multiple SMSs.... or do you?
{
delay(1);
}
while (1>0);
}