Hello I need some help.
I have a Arduino Ethernet and an Arduino Gsm shield, the official one.
-I have working a script that make calls and sms. from that calls I save the time when they are established.
Now I want to push that info to the web.
My first option was to create a web server on arduino and put the results online. But I can't but it working.
///////////////////////////////////Programa 1//////////////////////////////////
// Set up the GSM conection //
// Get the UTC time //
// Present at 172.20.30.50 //
// 1. Call From +31635118*** to +31635118*** //
// 2. SMS +31635118*** to +31635118*** //
///////////////////////////////////////////////////////////////////////////////
#include <GSM.h>
#include <SPI.h>
#include <Ethernet.h>
////////////////////////////////////////////////////////////////////////////////
////////// Enter a MAC address and IP address for your controller below.////////
////////////////////////////////////////////////////////////////////////////////
byte mac[] = {0x90, 0xa2, 0xDA, 0x0F, 0x45, 0x1A };
byte dns1[] = { 172, 20, 10, 17 };
byte gateway[] = { 172, 20, 30, 254 };
IPAddress ip(172, 20, 30, 50);
////////////////////////////////////////////////////////////////////////////////
//////////////////// initialize the library instance////////////////////////////
////////////////////////////////////////////////////////////////////////////////
EthernetServer server(80);
GSM gsmAccess;
GPRS gprsAccess;
GSMVoiceCall vcs;
GSM_SMS sms;
GSMClient client;
char charbuffer[20];
////////////////////////////////////////////////////////////////////////////////
///////////////PIN Number of the SIM card, phone numbers and SMS////////////////
////////////////////////////////////////////////////////////////////////////////
#define PINNUMBER ""
String Number1 = "+31635118***";
const char* Nr2 = "+31635118***";
String txtMsg = "Hello from Arduino GSM Shield.";
GSM3ShieldV1DirectModemProvider modemAccess;
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
//start the Ethernet connection and the server:
Ethernet.begin(mac, ip, dns1, gateway);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
//Start the GSM shield
boolean notConnected = true;
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
//Get the time
Serial.println("UTC Time: ");
modemAccess.writeModemCommand("AT+CCLK?",1500);
modemAccess.writeModemCommand("AT+QNTP=\"0.nl.pool.ntp.org\"",123);
modemAccess.writeModemCommand("AT+QNTP?",1500);
modemAccess.writeModemCommand("AT+QNTP",1500);
//Serial.println("UTC time:");
Serial.println(modemAccess.writeModemCommand(("AT+CCLK?"),1500));
//Start the page and listen for incoming clients
EthernetClient client = server.available();
Serial.println("??");
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c == '\n' && currentLineIsBlank) {
//send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
// client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html><head></head><body>");
// output the value of each analog input pin
client.print("The Network Test ");
client.println("
");
client.println("
");
//////////////////////////////////////////////////////////////
//1. Call
Serial.print("1. Call From +31635118*** to ");
Serial.println(Number1);
Serial.print("Calling to : ");
Serial.println(Number1);
//Call the remote number
Number1.toCharArray(charbuffer, 20);
Serial.print("Start time: ");
Serial.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("Call start time: ");
//client.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("
");
//Checkde if the receiving end has picked up the call
if(vcs.voiceCall(charbuffer))
{
Serial.println("Call Established at: ");
Serial.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("Call Established time: ");
//client.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("
");
Serial.println("Hang up in 30s");
delay(30000);
// And hang up
vcs.hangCall();
Serial.println("Stop time: ");
Serial.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("Call Stop time: ");
//client.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("
");
}
/////////////////////////////////////////////////////////////////////////////////////////
//SMS
Serial.println("2. SMS From +31635118*** to +31635118***");
Serial.print("SMS: Hello from Arduino GSM Shield.");
//send the message
sms.beginSMS(Nr2);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nSMS sent at: \n");
Serial.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
Serial.println("\nCOMPLETE!\n");
client.println("SMS Time: ");
//client.println(modemAccess.writeModemCommand("AT+CCLK?",1500));
client.println("
");
////////////////////////////////////////////////////////////////////////////////////////
//End Page
client.println("</body></html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1000);
// close the connection:
}
client.stop();
Serial.println("client disonnected");
}
void loop() {
}
Do you have any idea why it is not working?
Can someone help me to put this working?