GabrielSoare:
Hi Arduino!I'm trying to send data from my arduino mega which has attached a GPRS module.
Connection and setup for GPRS module it was a success, also the backend part but i have some trouble with connect to my php file.
Take a look on my short code. maybe you can figure what's my problem easily.
// include the GSM library
#include <GSM.h>
// PIN number if necessary
#define PINNUMBER ""
// APN information obrained from your network provider
#define GPRS_APN "web.vodafone.de" // replace with your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;
// This example downloads the URL "http://arduino.cc/latest.txt"
char server[] = "agroaktiv.de";//"agroaktiv.de"; // the base URL
char path[] = "/wetterstation/status.php?device=fromtheroof&temp1=30&temp2=12&rainfall=0"; // the path
int port = 80; // the port, 80 for HTTP
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// Start GSM shield
// pass the PIN of your SIM as a parameter of gsmAccess.begin()
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==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(server, port))
{
Serial.println("connected");
// Make a HTTP request:
client.print("GET ");
Serial.print("GET ");
client.print(path);
Serial.print(path);
client.println(" HTTP/1.0");
Serial.println(" HTTP/1.0");
client.println();
Serial.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(;![]()
;
}
}
This is what I getStarting Arduino web client.
connecting...
connected
GET /wetterstation/status.php?device=fromtheroof&temp1=30&temp2=12&rainfall=0 HTTP/1.0
HTTP/1.1 404 Not Found
Content-Length: 191
Server: nginx
Date: Fri, 09 May 2014 10:21:01 GMT
Content-Type: text/html
Last-Modified: Mon, 09 Dec 2013 10:57:51 GMT
ETag: "82cda-3bf-4ed17de070608"
Accept-Ranges: bytes
X-Powered-By: PleskLin
MS-Author-Via: DAV
Connection: close
Not Found
The requested document was not found on this server.Web Server at v681.ncsrv.de
disconnecting.
I don't know what to say more. Cheers, Gabriel
The 404 error means your ASP script isn't where you think it is. Double check the URL in a web browser and correct your code accordingly. caPAtaLiZatiON matters