GPRS works only on serial monitor

Hi,

I worked out a project for a GPS Tracker with GPRS. The Module for sending Http Requests is the Sim800L.
So, everything works well until its connected to the PC, where I can read the Serial Output.
When I put the USB Wire out of the Arduino, then the Module stop sending Requests.
By the way, the Sim800L is connected to an Power Adapter (4Volt, 2A) , which is also connected to Arduino 5V Pin.
All the LEDs blinking further, but the Module stops sending the data :frowning:
My Idea was to comment out all the Code, where I ask for Serial.print(); But its still not working.
Should I upload the sketch or post how I connect the devices?

I see, there is nobody with an idea :frowning: 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);
}

43 Views but nobody has an idea?

Please guys. Help me :frowning:
I create a Fritzing Picture. Maybe this can help?

I have exactly the same problem. My code works standalone with m590 module, no problem. when I use simm800, it works as long as my usb cable is plugged in. when I remove usb cable from PC it will not work.

I have tried sim 800DS, sim800L and smallest sim800l modules. They all do the same.
I have tried plugging the usb into PC with all programs closed - still works
I have tried plugging the usb into 5v usb supply, does not work.

The module remains connected to the network, which I establish by calling the number from my cell.

I am ready to give up and use only M590 module.