Hello,
I have both the Arduino GSM A000043 shield as well as the Arduino GSM A000105 shield. I have used the code below to make GET requests successfully with the A000043, but I have not been able to even connect to the network with the A000105. Does anyone have any ideas on what might be going on here?
Thanks,
Ian
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// APN data
#define GPRS_APN "apn" // replace your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true);
// URL, path & port (for example: arduino.cc)
const unsigned long __TIMEOUT__ = 10*1000;
int port = 80; // port 80 is the default for HTTP
// FLOW DATA VARIABLES
volatile int NbTopsFan; //measuring the rising edges of the signal
float Calc;
int hallsensor = 2; //The pin location of the sensor
float d=0; //my summation variable
void setup()
{
pinMode(A0, OUTPUT);
pinMode(A3, OUTPUT);
digitalWrite(A0, LOW);
digitalWrite(A3, HIGH);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);
// initialize serial communications and wait for port to open:
Serial.begin(9600);
// ++++++++++++++++++++
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
// ++++++++++++++++++++
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// After starting the modem with GSM.begin()
// attach the shield to the GPRS network with the APN, login and password
while (notConnected)
{
if (gsmAccess.begin(PINNUMBER) == GSM_READY){
Serial.println("gsmAccess good");
if(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY){
notConnected = false;
Serial.println("Connected");
}else{
Serial.println("Gprs access bad");
}
}else{
Serial.println("Not connected");
delay(1000);
}
}
// if you get a connection, report back via serial:
// initialize pump data stuff
//pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
//attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
void loop()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
//cli(); //Disable interrupts
Calc = (NbTopsFan/(5.5*60)); //(Pulse frequency x 60) / 5.5Q, = flow rate in L/hour
int transmit = 100 * Calc;
Serial.println("Buffer filled. Sending:");
long t = millis();
send_data(transmit);
Serial.print("\n\n");
Serial.print("Time was: ");
Serial.print(millis() - t);
Serial.print("\n\n");
// FLOW DATA CODE
/*
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (NbTopsFan/(5.5*60)); //(Pulse frequency x 60) / 5.5Q, = flow rate in L/hour
byte transmit = 100 * Calc;
Serial.println("Buffer filled. Sending:");
long t = millis();
*/
}
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal
}
void send_data(int stuff){
//int datat_256 = map(data, 0, 1023, 0 256);
Serial.println("connecting...");
if (client.connect("-----.com", port))
{
client.beginWrite();
Serial.println("connected");
// Make a HTTP request:
client.print("GET /?light=");
client.print("10");
client.print(" HTTP/1.1\n");
client.print("Host: ");
client.println("-----.com");
client.println("Connection: close");
client.println();
Serial.println("disconnecting.");
client.stop();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
delay(1000);
}
}