I see, there is nobody with an idea
Also google cant help me.
But the problem is real. When I connect the USB to an USB Charger and the other power supply to the Sim800, then I dont get any request on my Server.
I connect now an LCD Display to see the Debug. But I only get the Info, that GPS cant be found and also GPRS cant load the module.
Its so crazy.
I will post the code with the hope it helps.
// It is assumed that the LCD module is connected to
// the following pins.
// SCK/CLK - Pin 8
// MOSI/DIN - Pin 9
// DC - Pin 10
// RST - Pin 11
// CS/CE - Pin 12
// LIGHT - GND
// VCC - 4V
//
#include <LCD5110_Basic.h>
LCD5110 myGLCD(8, 9, 10, 11, 12);
extern uint8_t SmallFont[];
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <Wire.h>
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial gps_ss(2, 3);
SoftwareSerial gprs(5, 4); // RX, TX Pins
String apn = "internet.t-mobile"; //APN
String apn_u = "t-mobile"; //APN-Username
String apn_p = "tm"; //APN-Password
String pin = "";
String url = "http://..."; //URL for HTTP-POST-REQUEST
String serial = "12727B88-9554-4006-B086-0DDC69845BFC";
void setup() {
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
// Open serial communications and wait for port to open:
//Serial.begin(9600);
gprs.begin(9600);
gps_ss.begin(9600);
delay(10000);
gprs.listen();
//deactivatePin();
gsm_connect();
gprs.stopListening();
gps_ss.listen();
}
void loop() {
String gpsParam = "";
while (gps_ss.available() > 0)
if (gps.encode(gps_ss.read()))
gpsParam = gps_data();
if (gpsParam == "") { debugGps(); delay(1000); return; }
Serial.println(gpsParam);
printLCD(gpsParam);
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
printLCD("No GPS detected: check wiring.");
delay(1000);
return;
}
gpsParam += ";" + serial;
gps_ss.stopListening();
gprs.listen();
gsm_sendhttp(gpsParam); //Start the GSM-Modul and start the transmisson
gprs.stopListening();
gps_ss.listen();
delay(10000); //Wait one minute
}
/* GPRS*/
bool gsm_connect() {
//Print GSM Status an the Serial Output;
ATCommand("AT", 4000, false);
//ATCommand("AT+CPIN?", 100,false);
ATCommand("AT+SAPBR=3,1,Contype,GPRS", 100, false);
ATCommand("AT+SAPBR=3,1,APN," + apn, 100, false);
ATCommand("AT+SAPBR=3,1,USER," + apn_u, 100, false);
ATCommand("AT+SAPBR=3,1,PWD," + apn_p, 100, false);
ATCommand("AT+COPS?", 1000, false); // Show all visible Provider
ATCommand("AT+CBAND?", 1000, false); // Show current Band
//ATCommand("AT+CBAND=ALL_BAND", 1000, false);
ATCommand("AT+CSQ", 1000, false); // Check Signal strength
ATCommand("AT+COPS?", 100, false);
ATCommand("AT+CLCK=\"PN\", 2", 100, false); // check if sim800 is locked
ATCommand("AT+IPR?", 100, false); //Check Baudrate
//ATCommand("AT+IPR=9600", 100, false); //Check Baudrate 0 = Autobaud
ATCommand("AT+SAPBR=1,1", 1000, false);
String res = ATCommand("AT+SAPBR=2,1", 1000, false);
if (res.indexOf("0.0.0.0") > -1) {
ATCommand("AT+CREG=2", 4000, false);
gsm_connect();
}
return true;
}
bool gsm_sendhttp(String params) {
int tries = 0;
while (ATCommand("AT+HTTPINIT", 100, false) == "ERROR" && tries < 5) {
gsm_connect();
tries++;
delay(1000);
}
if (tries >= 5) {
return false;
}
ATCommand("AT+HTTPPARA=CID,1", 100, false);
ATCommand("AT+HTTPPARA=URL," + url, 100, false);
ATCommand("AT+HTTPPARA=CONTENT,application/x-www-form-urlencoded", 100, false);
ATCommand("AT+HTTPDATA=192,10000", 100, false);
ATCommand("params=" + params, 10000, true);
ATCommand("AT+HTTPACTION=1", 5000, false);
ATCommand("AT+HTTPREAD", 100, false);
ATCommand("AT+HTTPTERM", 100, false);
return true;
}
String ATCommand(String cmd, unsigned long wait, bool printInline) {
if (printInline) { gprs.print(cmd); }
else { gprs.println(cmd); }
String res = "";
res = gprs.readString();
Serial.print(res);
printLCD(res);
delay(wait);
return res;
}
void deactivatePin() {
ATCommand("AT+CPIN=\"" + pin + "\"", 4000, false);
ATCommand("AT+CLCK=\"SC\",0,\"" + pin + "\"", 4000, false);
ATCommand("AT+CPIN?", 4000, false);
}
/* GPS */
String gps_data()
{
String res = "";
if (gps.location.isValid())
{
res += String(gps.location.lat(), 6);
res += ";";
res += String(gps.location.lng(), 6);
res += ";";
}
else
{
Serial.println(F("INVALID GPS"));
return "";
}
if (gps.speed.isValid())
{
res += String(gps.speed.kmph());
res += ";";
}
else
{
Serial.println(F("INVALID SPEED"));
res += "0;";
}
if (gps.date.isValid())
{
res += gps.date.year();
res += "-";
res += gps.date.month();
res += "-";
res += gps.date.day();
res += " ";
}
else
{
Serial.print(F(" INVALID GPS DATE "));
return "";
}
if (gps.time.isValid())
{
if (gps.time.hour() < 10) res += "0";
res += gps.time.hour();
res += ":";
if (gps.time.minute() < 10) res += "0";
res += gps.time.minute();
res += ":";
if ((gps.time.second()) < 10) res += "0";
res += gps.time.second(); // Korrektur zur GMT Zeit + 3 Sek
/*if (gps.time.centisecond() < 10) res += "0";
Serial.print(gps.time.centisecond());*/
}
else
{
Serial.print(F(" INVALID TIME "));
return "";
}
Serial.println();
return res;
}
void debugGps() {
String res = "";
res += "GPS: ";
res += String(gps.location.lat());
res += String(gps.location.lat());
printLCD(res);
Serial.print("GPS: ");
Serial.print(gps.location.lat());
Serial.println(gps.location.lng());
Serial.print("SPEED: ");
Serial.println(gps.speed.kmph());
Serial.print("DATE: ");
Serial.print(gps.date.year());
Serial.print("-");
Serial.print(gps.date.month());
Serial.print("-");
Serial.println(gps.date.day());
Serial.print("TIME: ");
Serial.print(gps.time.hour());
Serial.print(":");
Serial.print(gps.time.minute());
Serial.print(":");
Serial.println(gps.time.second());
}
void printLCD(String text) {
myGLCD.print(text, LEFT, 0);
//myGLCD.clrScr();
//char testChar[65];
//text.toCharArray(testChar, 65);
//myGLCD.print(testChar, LEFT, 0);
}