Using a DS3231 RTC Alarm output to re-set Arduino Pro Mini 3.3V

Hi,

I have a remote weather station that uses a Arduino Pro Mini 3.3v (for low power) to transmit weather info via GSM with a SIM800 breakout.

Every few weeks it goes offline and pressing re-set on the Arduino fixes the issue. I suspect a glitch in the sensors or similar Rx/Tx issue is locking up the Arduino occasionally.

The Arduino is connected to a DS3231 RTC breakout to give it the time. I was wondering if anyone has tried using the alarm function (and associated SQW pin) on a DS3231 RTC to re-set a Arduino? I'd like it to re-set Arduino daily so if it locked up it would be fixed with the daily reset.

Could I connect the SQQ pin via a pull up resistor to the RST pin on the Arduino?

I've tried using the WDT before but have found difficulties with the Pro Mini lockup on WDT (!) which is a known fault with the Pro Mini.

Any help that avoids future boat trips to the station would be greatly appreciated.

Thanks

Donal

Every few weeks it goes offline and pressing re-set on the Arduino fixes the issue. I suspect a glitch in the sensors or similar Rx/Tx issue is locking up the Arduino occasionally.

My guess is an error in the software. If you post it we might find that error.

The Arduino is connected to a DS3231 RTC breakout to give it the time. I was wondering if anyone has tried using the alarm function (and associated SQW pin) on a DS3231 RTC to re-set a Arduino? I'd like it to re-set Arduino daily so if it locked up it would be fixed with the daily reset.

Although that may be a solution most people would use the watch dog timer of the Arduino ATmega CPU to reset the board if the software locks up. This can be done completely in software and will reset the Arduino if and when it locks up and not just once a day.

Could I connect the SQQ pin via a pull up resistor to the RST pin on the Arduino?

The RST pin of the Arduino already has a pull-up resistor, so you could simple connect the SQQ pin by a capacitor, if you really want to realize it that way.

I've tried using the WDT before but have found difficulties with the Pro Mini lockup on WDT (!) which is a known fault with the Pro Mini.

That's a know fault of the Pro Mini bootloader. Burn a new bootloader and the WDT will work without any problems.

Thanks for replying, attached is the current code. It has been running since May. I’d be interested to determine what would cause a lockup.

I will look again at watchdog timer code, can you suggest a bootloader that will work with the 3v3 Pro Mini?

I’d like to try the RTC option as well, what value do you suggest for the capacitor and should it be connected to ground or in series?

Ard_stn_R31mini_Sim800_Eir.ino (12.8 KB)

Thanks for replying, attached is the current code. It has been running since May. I'd be interested to determine what would cause a lockup.

You've most probably a memory problem because you're using the String class. This class isn't a good choice for embedded hardware as it gets the memory fragmented and sooner or later you'll end with a situation where you cannot allocate more memory and you start overwriting other memory parts.
Try to replace that class by C-strings (character arrays). For most cases you know how long the string to be read is, so you can allocated a fixed amount of memory and avoid to get a fragmented memory.

I will look again at watchdog timer code, can you suggest a bootloader that will work with the 3v3 Pro Mini?

I never tried it myself but the optiboot code of the UNO should work. The baudrate for sketch upload will be half of the UNO as the 3V3 version runs on 8MHz.

I'd like to try the RTC option as well, what value do you suggest for the capacitor and should it be connected to ground or in series?

Must be in series and I would try a 100nF. Alternatively you can use the DTR pin of the serial connection as that one is already connected to RST by a 100nF capacitor.

pylon:
You've most probably a memory problem because you're using the String class. This class isn't a good choice for embedded hardware as it gets the memory fragmented and sooner or later you'll end with a situation where you cannot allocate more memory and you start overwriting other memory parts.

Great suggestion on character arrays, I will work on converting all strings. Would the WDT pick up this memory overwriting or will it have to lock up the arduino first?

pylon:
I never tried it myself but the optiboot code of the UNO should work. The baudrate for sketch upload will be half of the UNO as the 3V3 version runs on 8MHz.

I've ordered a 5v-3v3 logic converter to try optiboot with a UNO as bootloader at the low baudrate as suggested.

pylon:
Must be in series and I would try a 100nF. Alternatively you can use the DTR pin of the serial connection as that one is already connected to RST by a 100nF capacitor.

I'll try both, I have ordered a new RTC module that has the alarm pin broken out.

The station is transmitting occasionally now after dead silence for a few days, I suspect the Arduino code is still running but the GSM unit is not getting connection to the network. The intermittent data from the sensors and battery monitoring looks realistic.

https://www.wunderground.com/personal-weather-station/dashboard?ID=IPORTROE2#history

Would the WDT pick up this memory overwriting or will it have to lock up the arduino first?

The WDT simply resets the processor if it's counter isn't reseted periodically.

I've ordered a 5v-3v3 logic converter to try optiboot with a UNO as bootloader at the low baudrate as suggested.

I don't understand what you mean by this sentence. You don't need a logic converter if you still use the same hardware. I suggested to replace the bootloader, not the hardware.

The station is transmitting occasionally now after dead silence for a few days, I suspect the Arduino code is still running but the GSM unit is not getting connection to the network. The intermittent data from the sensors and battery monitoring looks realistic.

That sounds like it's not necessary to reset the Arduino but the GSM device.

pylon:
I don't understand what you mean by this sentence. You don't need a logic converter if you still use the same hardware. I suggested to replace the bootloader, not the hardware.

I have a 5v Arduino Uno which I will use as a bootloader ISP. As the Pro Mini is 3v3 I will need a logic level converter to change the 5v signals to 3v3.

pylon:
That sounds like it's not necessary to reset the Arduino but the GSM device.

Yes, I am beginning to think the same. The GSM is powered up (and down on finish) for each data send sequence so it is re-set each time. However it uses time outs for some of the communications commands.

I will add logic to check if comm command is complete (with a longer timeout as well) so it should be more reliable.

I plan to re-code as discussed with WDT and character arrays to make the code more reliable as well.