user70362: I'm using Arduino Uno as my microcontroller, but I got a strange behavior. I need to run several function at the same time. One to get GPS and temperature value then send every value to user's phone number when a request received by SIM800L GSM module, and another to display those value on I2C LCD. Everything works fine when my USB port connected to my computer. But when I tried to unplug the USB and using external power source from Li-Po battery I can't get a response from SIM800L module whenever I send a request message.
When I tried to create a separate program (just received a request message and then sent a response by SIM800L) it works fine even though using external power supply (Li-Po battery) without USB port plugged in. Another strange behavior is when I was using both of Li-Po battery and USB port connected then unplugged the USB port it works fine again. But when I unplugged my battery and then plugged it again without USB port connected, SIM800L couldn't send a response. What is wrong ?
This is my full code:


#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include "DHT.h"

//sms 
char ReceivedSms;
short DHT_OK=-1, GPS_OK=-1;
String DataSms;
int _timeout;
String _buffer;
String number = "+62811XXXXXX";

//dht
#define DHTPIN 5
#define DHTTYPE DHT11

LiquidCrystal_I2C lcd(0x27,20,4);
SoftwareSerial sim800l(2,3);
DHT dht(DHTPIN, DHTTYPE);


// The TinyGPS++ object
TinyGPSPlus gps;


void setup()
{
  Serial.begin(9600);
  sim800l.begin(9600);
  dht.begin();
  lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  _buffer.reserve(50);
  ReceiveMode();
}

void loop()
{
   displayInfo();
 
}

void displayInfo()
{
  String RSMS;

  while(sim800l.available() > 0) {
      ReceivedSms = sim800l.read();
      RSMS.concat(ReceivedSms);
      GPS_OK = RSMS.indexOf("All");
   }
   
  if (gps.location.isValid())
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Latitude  : ");
    lcd.println(gps.location.lat(), 6);
    lcd.setCursor(0,1);
    lcd.print("Longitude : ");
    lcd.println(gps.location.lng(), 6);
    delay(5000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Suhu       : ");
    lcd.println(dht.readTemperature());
    lcd.setCursor(0,1);
    lcd.print("Kelembaban : ");
    lcd.println(dht.readHumidity());
    delay(2000);
   
    if(GPS_OK!=-1)
        {
        String link = "http://www.google.com/maps/place/" + String(gps.location.lat(),6) + "," + String(gps.location.lng(),6);
        DataSms = "ALL\nSuhu = "+String(dht.readTemperature(),1)+" C"+" \nKelembaban ="+String(dht.readHumidity(),1)+" %"+" \nMaps = "+link;
        SendMessage();
        ReceiveMode();
        GPS_OK = -1;
        }
  }
  else
  {
 
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("GPS not found");
    delay(2000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Suhu      :");
    lcd.println(dht.readTemperature());
    lcd.setCursor(0,1);
    lcd.print("Kelembaban:");
    lcd.println(dht.readHumidity());
    delay(2000);
   
    if(GPS_OK!=-1)
       {
        DataSms = "ALL\nSuhu = "+String(dht.readTemperature(),1)+" C"+" \nKelembaban ="+String(dht.readHumidity(),1)+" %"+" \nMaps = Lokasi Tidak Ditemukan";
        SendMessage();       
        ReceiveMode();
        GPS_OK = -1;
       }
  }

}

String _readSerial() {
  _timeout = 0;
  while  (!sim800l.available() && _timeout < 12000  )
  {
    delay(13);
    _timeout++;
  }
  if (sim800l.available()) {
    return sim800l.readString();
  }
}

void ReceiveMode() {
  sim800l.println("AT");
  delay(100);
  sim800l.println("AT+CMGF=1");
  delay(100);
  sim800l.println("AT+CNMI=2,2,0,0,0");
  delay(100);
}

void SendMessage()
{
  //Serial.println ("Sending Message");
  sim800l.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);
  //Serial.println ("Set SMS Number");
  sim800l.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message
  delay(1000);
  String SMS = "Hello from 800L...";
  sim800l.println(DataSms);
  delay(100);
  sim800l.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  _buffer = _readSerial();
}

Just for your information I'm using Li-Po battery 7.4V 2200mAh

user70362: I have solved my problem by click on Arduino reset button pin after all of my components got a power supply. Somehow I can't explain why does it work after doing that simple thing

70362: <p>I'm using Arduino Uno as my microcontroller, but I got a strange behavior. I need to run several function at the same time. One to get GPS and temperature value then send every value to user's phone number when a request received by SIM800L GSM module, and another to display those value on I2C LCD. Everything works fine when my USB port connected to my computer. But when I tried to unplug the USB and using external power source from Li-Po battery I can't get a response from SIM800L module whenever I send a request message.</p>
<p>When I tried to create a separate program (just received a request message and then sent a response by SIM800L) it works fine even though using external power supply (Li-Po battery) without USB port plugged in. Another strange behavior is when I was using both of Li-Po battery and USB port connected then unplugged the USB port it works fine again. But when I unplugged my battery and then plugged it again without USB port connected, SIM800L couldn't send a response. What is wrong ?</p>
<p>This is my full code:</p>
<pre><code>

#include &lt;TinyGPS++.h&gt;
#include &lt;SoftwareSerial.h&gt;
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;SoftwareSerial.h&gt;
#include &quot;DHT.h&quot;

//sms 
char ReceivedSms;
short DHT_OK=-1, GPS_OK=-1;
String DataSms;
int _timeout;
String _buffer;
String number = &quot;+62811XXXXXX&quot;;

//dht
#define DHTPIN 5
#define DHTTYPE DHT11

LiquidCrystal_I2C lcd(0x27,20,4);
SoftwareSerial sim800l(2,3);
DHT dht(DHTPIN, DHTTYPE);


// The TinyGPS++ object
TinyGPSPlus gps;


void setup()
{
  Serial.begin(9600);
  sim800l.begin(9600);
  dht.begin();
  lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  _buffer.reserve(50);
  ReceiveMode();
}

void loop()
{
   displayInfo();
 
}

void displayInfo()
{
  String RSMS;

  while(sim800l.available() &gt; 0) {
      ReceivedSms = sim800l.read();
      RSMS.concat(ReceivedSms);
      GPS_OK = RSMS.indexOf(&quot;All&quot;);
   }
   
  if (gps.location.isValid())
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(&quot;Latitude  : &quot;);
    lcd.println(gps.location.lat(), 6);
    lcd.setCursor(0,1);
    lcd.print(&quot;Longitude : &quot;);
    lcd.println(gps.location.lng(), 6);
    delay(5000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(&quot;Suhu       : &quot;);
    lcd.println(dht.readTemperature());
    lcd.setCursor(0,1);
    lcd.print(&quot;Kelembaban : &quot;);
    lcd.println(dht.readHumidity());
    delay(2000);
   
    if(GPS_OK!=-1)
        {
        String link = &quot;http://www.google.com/maps/place/&quot; + String(gps.location.lat(),6) + &quot;,&quot; + String(gps.location.lng(),6);
        DataSms = &quot;ALL\nSuhu = &quot;+String(dht.readTemperature(),1)+&quot; C&quot;+&quot; \nKelembaban =&quot;+String(dht.readHumidity(),1)+&quot; %&quot;+&quot; \nMaps = &quot;+link;
        SendMessage();
        ReceiveMode();
        GPS_OK = -1;
        }
  }
  else
  {
 
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(&quot;GPS not found&quot;);
    delay(2000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(&quot;Suhu      :&quot;);
    lcd.println(dht.readTemperature());
    lcd.setCursor(0,1);
    lcd.print(&quot;Kelembaban:&quot;);
    lcd.println(dht.readHumidity());
    delay(2000);
   
    if(GPS_OK!=-1)
       {
        DataSms = &quot;ALL\nSuhu = &quot;+String(dht.readTemperature(),1)+&quot; C&quot;+&quot; \nKelembaban =&quot;+String(dht.readHumidity(),1)+&quot; %&quot;+&quot; \nMaps = Lokasi Tidak Ditemukan&quot;;
        SendMessage();       
        ReceiveMode();
        GPS_OK = -1;
       }
  }

}

String _readSerial() {
  _timeout = 0;
  while  (!sim800l.available() &amp;&amp; _timeout &lt; 12000  )
  {
    delay(13);
    _timeout++;
  }
  if (sim800l.available()) {
    return sim800l.readString();
  }
}

void ReceiveMode() {
  sim800l.println(&quot;AT&quot;);
  delay(100);
  sim800l.println(&quot;AT+CMGF=1&quot;);
  delay(100);
  sim800l.println(&quot;AT+CNMI=2,2,0,0,0&quot;);
  delay(100);
}

void SendMessage()
{
  //Serial.println (&quot;Sending Message&quot;);
  sim800l.println(&quot;AT+CMGF=1&quot;);    //Sets the GSM Module in Text Mode
  delay(1000);
  //Serial.println (&quot;Set SMS Number&quot;);
  sim800l.println(&quot;AT+CMGS=\&quot;&quot; + number + &quot;\&quot;\r&quot;); //Mobile phone number to send message
  delay(1000);
  String SMS = &quot;Hello from 800L...&quot;;
  sim800l.println(DataSms);
  delay(100);
  sim800l.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  _buffer = _readSerial();
}
</code></pre>
<p>Just for your information I'm using Li-Po battery 7.4V 2200mAh</p>
 70362: <p>I have solved my problem by click on Arduino reset button pin after all of my components got a power supply. Somehow I can't explain why does it work after doing that simple thing</p>
