Arduino Pro mini hangs

Hi. My Arduino gets hang some time
3.3v 8mhz Arduino Chinese clone. Resonator with clock pins.

#include <SoftwareSerial.h> 
#include <TinyGPS.h>
#include <avr/wdt.h> // Include the watchdog timer library

float lat = 28.5458,lon = 77.1703;
String latitude, longitude; 
SoftwareSerial gpsSerial(4,3);//rx,tx
TinyGPS gps; // create gps object */

// Function to configure the watchdog timer
void enableWatchdog() {
  cli(); // Disable interrupts
  wdt_reset(); // Reset the watchdog timer
  WDTCSR |= (1<<WDCE) | (1<<WDE); // Enable the watchdog timer configuration
  WDTCSR = (1<<WDE) | (1<<WDP3) | (1<<WDP0); // Set watchdog timeout to 8 seconds
  sei(); // Enable interrupts
}

void disableWatchdog() {
  cli(); // Disable interrupts
  wdt_reset(); // Reset the watchdog timer
  MCUSR &= ~(1<<WDRF); // Clear the Watchdog System Reset Flag
  WDTCSR |= (1<<WDCE) | (1<<WDE); // Enable the watchdog timer configuration
  WDTCSR = 0x00; // Disable the watchdog timer
  sei(); // Enable interrupts
}

void setup() {
  Serial.begin(9600);
  gpsSerial.begin(9600); // connect gps sensor
  Serial.print("AT+CMGF=1\r\n");
  delay(100);
  Serial.print("AT+CNMI=1,2,0,0,0\r\n");
  delay(100);
  Serial.print("AT+W\r\n");
  delay(100);

  disableWatchdog(); // Disable the watchdog timer for 5 seconds initially
  delay(5000); // Wait for 5 seconds

  enableWatchdog(); // Enable the watchdog timer with an 8-second timeout
}

void loop() {
  while(gpsSerial.available()){ // check for gps data 
    if(gps.encode(gpsSerial.read()))// encode gps data 
    {  
      gps.f_get_position(&lat,&lon);
      if(Serial.available()){
        String c = Serial.readString();
        c.trim();
        if(c.indexOf("GPS")>=0){
          Serial.print("AT+CMGS=\"my mobile number here\"\r");
          delay(100);
          latitude = String(lat,6);
          longitude = String(lon,6);
          Serial.print("http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=");
          Serial.print(latitude+","+longitude); 
          Serial.write(0x1A);
        }
      }
    }
    wdt_reset(); // Reset the watchdog timer to prevent it from triggering
  }
  wdt_reset(); // Reset the watchdog timer to prevent it from triggering
}

GPS is SW serial, and GSM is with inbuilt serial, 3.7v battery power provided to all.

I got sms along with latitude and longitude. But once my battery went low voltage. I go with recharge without removing circuit from battery. Once battery charged then I am not able to receive sms.

Why my Arduino hangs after a battery recharge cycle ?. Any idea. I don't feel any hardware issue. Why because it is working 2days without any problem(until battery gets die) the problem is only when I put recharge. After my battery gets 100%charage also not responding for my messages. Some how hangs my pro mini.

Will brown out reset BOR resolve my issue ?.

After a year, you did forget how to use code tags :wink: Fixed it for you.

It's either [code] to start a code block and [/code] to end it or ``` to start it and ``` to end it. Note that they all must be on their own line.

Ok sorry. I am using my mobile phone to post this. I am bit outside from my laptop. Yeah ofcourse I tried to show separately about the code some how technical mistakes happened.

Thanks for fixing it.

Can you verify that the GPS and GSM are working properly after the brown out condition? It might be necessary to perform a reset or power cycle on those.

What kind of charger are you using ? can you show us the full schematic of how you have wired that up. You don't remove the battery from the circuit, but does your charger allow for load-sharing ?

that probably would be a good idea !

Waiting until the battery reaches 2.7v probably isn't, does your circuit have any hardware 'low-voltage detection' ?

Yes. My GPS blinks every 1second and my GSM blinks every 3second once. Which means properly fixed with network. Only I need to press the rest button on my Arduino Pro mini board to bring back to normal.

Ofcourse, here I will paste my schematics. And photos. I am not doing anything much in hardware just bought some reliable modules and added power and data lines between them.




Connection between these modules
GSM SIM800L, GPS Neo 6M, Arduino Pro mini 3.3v 8mhz

1 Like

This Smart Flex li-ion battery charger using TI chip. So it's a reliable one.

Functionality of this code. Whenever I send sms to this system (inserted sim card in SIM800L) with "GPS" keyword. Then the system will reply back to my number its latitude and longitude with it Google maps link as a SMS.

Is the battery connected to RAW or Vcc on the mini?

On the VCC. Not on the Raw. If I connect with Raw then 3.3v regulator will not work if my battery goes down. My battery voltage is maximum 3.7 volt so I connect with Vcc

There are several problems.

That battery is unprotected, so it will discharge to 0V if you let it.
That will cause the mini to act erratically, maybe reset several times and hang.
Connecting the charger to the battery AND the mini at the same time is not a good idea.
The charger may go off/on when it detects a low battery voltage, again that will cause the mini to act erratically, maybe reset several times and hang.
The charger may also pulse the voltage when it is charging near the fully charged voltage.

So:

  1. Don't let the battery discharge below 3.2V
  2. Disconnect everything from the battery while it is charging.

I tend to use a diode to bypass the charger (so from the 5v power source to the units that need to be powered) and a diode between the battery and the those units to prevent feedback into the battery. Of course the voltage drop may cause the voltage then to be to low, so an added buck converter to create a constant 4.0v would be ideal.

No it's in the charger and it will disconnect it at 2.8v if i read correctly.

Main thing of course is not to load-share, it will influence the charger and it will appear to the chip that the battery still needs charging since there is still current flowing when there isn't. That can actually cause the battery to explode. (in theory, in practice it may damage it)

Hi, thanks for the reply. But this system I will be mounted in vehicle. So this should be function automatically. Also the battery charger is not allowing to drain to 0 voltage. Because the over/under voltage protection taken care by the TI BMS chip

What is the solution for this ?. My Arduino should not hang,
I have an Idea, I plan to burn attiny, in that it will give one second pulse for every 5min once. so I can connect this Pro mini reset button, so that it will reset by the Attiny85

I'd use an AtTiny13 for that, it will do the job.

Is that how often the battery drops out and needs to be re-charged ?

No it shouldn't, what was the sequence leading up to this again ? low voltage => cutting the power => re-charge, which causes it to lose sync ?
I actually think that because you load-share, the power comes up gradually which causes some device to come on before others. Really it is best not to load-share on the charger.

Yeah try the AtTiny thing, but just get it to reset arduino & sensors in sequence after power-up, once should be enough though, no need for every 5 minutes.

BTW you know there is trackers for dogs and bikes available which are significantly smaller, have a much better battery life and are really not that deer. Also good for kids at the beach, App is all included and everything.

I will try. thanks for reply

I think, Finally I identified the problem, I the charging module is doing this problem.
I plan to remove battery module and I will design LM2576HV power supply and I will connect directly with my car ODB 12v(alwayls 12v will be available) pins.
from this power supply I will connect my Pro mini 3.3v, Neo 6M GPS and SIM800L modules as same as I have connected with my battery earlier.

I have attched the screen shot of the power supply circuit here.

Please provide your comments/feedback to take care points before going into this.

35Ah capacity battery available in my car

The power supply I will design like