Hard Reset ideas for Arduino

Hello,

My project has an issue with a component and I need to do a hard reset(loss of power) remotely when it happens.
Currently, when pin 9 in my Arduino stays high for more than 2 loops, it means it's stuck and I need to cut all power to my system, along with the faulty component and turn it back on.

My project's specifications:
I'm using a 3.3V regulator, and 3 x 1.5 V batteries to supply the circuit. The faulty component is a cheap Chinese NRF24L01 that I bought in bulk and cannot afford to replace with original NRFs. I understand when I need to restart the system by checking if the CE pin in the NRF is stuck in the HIGH position, since it shouldn't be for more than 10us. My main loops lasts around a second, and if it's still on by the time the loop finishes, something is wrong and must be dealt with.

For this purpose, I'm thinking that I should use a MOSFET to switch the system, an NPN transistor to switch the MOSFET, and a 555 Timer to turn it on after a while when the Arduino is off.
Would this work? I'm going to go shopping after new year and if any better solutions are proposed I'd switch to that. Any ideas are welcome :slight_smile:

You are aware of the built in watchdog timer? It is for exactly that purpose.

Hi, thanks for the comment,

Yes I'm aware of the watchdog timers, but a software reset doesn't fix my problem for some reason. When the module is stuck, if I press the reset button, it doesn't fix it. I need to manually remove the battery, and plug it back in for it to work. A watchdog timer does the same thing as pressing the reset button, right?

“Currently, when pin 9 in my Arduino stays high for more than 2 loops, it means it’s stuck and I need to cut all power to my system, along with the faulty component and turn it back on.”

May well be some issue with the code you are using instead of the chip. Generally speaking, chips are probably more reliable than the code that is loaded on them.

Sound like a typical XY problem.
Post all the details of your project.
Read the 'how to post' guidelines first.
Leo..

Hi, thanks for the valuable input,

However, I'm certain that it's the chip's fault, after some thorough testing of my code and the hardware with my colleagues.

I have some GPIO pins free to use, I just need to figure out how to hard reset the hardware remotely and I'll add some reset code when the exception occurs.

A schematic would help as well. If you have designed the circuit in such a way that power to the nrf24l01 is dependent on an Arduino pin being high, it is difficult to see how pressing the reset button does not clear the problem.

Sound like a typical XY problem.
Post all the details of your project.
Read the 'how to post' guidelines first.
Leo..

I'm sorry if I caused any misunderstanding. However, I don't think there's any Y problem here, I have already tried most of the other solutions, such as a watchdog timer, a remote software reset, with none bore valuable results.

To give some more details to my project:
I'm sending data over NRF every 4 minutes, for low power purposes. But after a week or so, the NRF is stuck in TX mode, and uses up more battery than needed. Since the NRF is a Chinese clone, it is suggested to me that this is a known issue with them and I need to use power up / down commands of NRF. I've checked my code and I already had such commands in place. Therefore, I've concluded that I need to do a hard reset when such an event occurs. Since the problem happens after so long of a time, I can't really hope that a "software reset" would fix the solution, I need a permanent solution, as one would need.

I'm attaching the schematic of my circuit, however, I don't understand what you mean by

designed the circuit in such a way that power to the nrf24l01 is dependent on an Arduino pin being high,

I'm using the Pin 9 as a ways of troubleshooting, as in, I'm checking if the system is problematic with that pin.

I hate search a word schematics.

Can you draw a PROPER schematic with ALL the wires connected to show signal and power flow.
All your schematic is good for is making a PCB.
Are you using D4 to power the TMP36?

Now can you draw one that can be used for trouble shooting.

Have you got a 10uF cap on the supply pins of the NRF AT the NRF pins?

Have you made a PCB, if so can you post a jpg image of it please.

Thanks.. Tom... :slight_smile:

Hi,
Yes, D4 is a power pin for TMP, I'm turning the temperature sensor on when I need to measure it, then I turn it off.
I'm going to post the PCB now, but wiring the schematic might take me a while.

Yes, I have a 10 uF cap at the supply pins, however, that was a later revision that I forgot to add to the schematic.(don't worry, that's the only thing different from this schematic!)


An ATmega328 is running out of specs with a 16Mhz crystal and a 3.3volt supply.
Leo..

Hi,
Thanks for the PCB, does the NRF plug directly into socket U3 or is it on a lead?

Is this a single sided PCB?
You seem to have a lot of ZERO Ohm resistors on the PCB to jump tracks.

CE is a 328 output, not a NRF output.

Tom... :slight_smile:

does the NRF plug directly into socket U3 or is it on a lead?

It's a socket, I plug the NRF on the socket for better maneuverability.

Is this a single sided PCB?

Yes, I have a CNC in the workshop and I'm only capable of manufacturing one sided PCB's, hence all the 0 ohm jumps to be able to fit everything in the one side :slight_smile:

An ATmega328 is running out of specs with a 16Mhz crystal and a 3.3volt supply.

I'm not sure how to respond to this, isn't ATmega328p supposed to run at 16MHz? What's the specifications use if not?

TomGeorge:
CE is a 328 output, not a NRF output.

+1
CE is input of the nRF! If it is stuck HIGH it is probably ATMega's fault. Why do you think the problem is on the nRF side?

bassumex:
I'm not sure how to respond to this, isn't ATmega328p supposed to run at 16MHz? What's the specifications use if not?

ATmega328p can run at 16Mhz, but the datasheet will tell you that its needs a supply of around 4.0V min to run at that speed.

If your running the processor at 3.3V use 8Mhz.

Useful sources of information are datasheets.

The ATmega328p is only specified for 16Mhz from a supply of about 3.85volt.
3.3volt/328 boards normally run on an 8Mhz clock.
There is a clock speed/voltage graph in the 328 datasheet, page 303,section 29.3.
Leo..

CE is the input of the nRF!

Huh, there goes my only hypothesis as to how to detect when the NRF is stuck.
I have read the NRF’s datasheet and since it says “when CE pin is HIGH, along with the PWR pin, the NRF is in TX mode and will send data” I automatically assumed that if I’m able to track when CE pin is high, maybe I’ll be able to detect when the NRF gets stuck.

Why do you think the problem is on the nRF side?

Because, as I said on the first comments, the NRF is a Chinese clone and it is suggested to me that there’s a known problem with Chinese clones being stuck in transmit mode. I’m quoting the exact reply:

There is a known common problem with some cheap Chinese clones of the nRF24L01+ whereby they get stuck in TX mode waiting for an auto-ACK that never arrives.

Now I’m left with more questions than answers :confused: How can I detect when the NRF is acting out?

bassumex:
Now I'm left with more questions than answers :confused: How can I detect when the NRF is acting out?

Hard to tell. IIRC there is no way to know in which mode the nRF is. But if you know the CE pin is stuck HIGH, there is likely a SW bug.

Hi,
What makes you think the problem is with the NRF?

If you run some simple code that just makes the NRF TX at regular intervals, does your problem still occur.
Make this simple code JUST NRF, don't put anything else in the code.

You now have to do some troubleshooting, which is different to design and building your project.
So a proper schematic will help.

Thanks.. Tom.. :slight_smile: