Reset by software Arduino R4

Hello,

How can I "reset by software" the R4 ?
An idea ?
It's not an Arduino R3

The advice I've generally seen is to use the Watchdog timer and force that to reset it.

Thanks for the quick answer,

but the microcontroller on the R4 is a Renesas and not an AVR...

On UNO R4 you have NVIC_SystemReset(); for immediate reset.

(There's also a pending proposal for a nicer, portable, command for that)

2 Likes

Why do you need to reset it?

Thank you it's perfect !

Does your software crash, is that why you are resetting it?

My Arduino R4 drive via I2C some other card raspberry pi pico RP2040, and sometimes the I2C crash (I must investigate more precisely...) So the reset for all modules is my solution for the moment. (It's not really a good solution, but she works ...)

All 4 of my Uno R4's are connected to ArduinoCloud. Works great for a while, then after 1 hour or 10 days, they enter a loop where every 500mS it says its trying to reconnect to the cloud. It stays in this loop forever. Generally associated with reading A0 input, but I've seen it do this even when I have no analogReads. Doesn't happen on my nano esp32.

It happens in both of my homes. Its kind of hard to reach the reset button 85 miles away, so I would like to reset the R4 when this function gets called.
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, doThisOnDisconnect);
I have confirmed this function is getting called when it enters this endless loop.

Hi @alranel - is there a way to reset the ESP32 module?

I have constant failures for the BLE module failing to start and even if you use this NVIC_SystemReset command the BLE module will continue to fail to start until power is completely removed from the board from all sources.

Maybe take look at this post

At thr part


static const char RESET[] = "AT+RESET\n";
      Serial2.write(RESET, sizeof(RESET) - 1);

2 Likes

That works great - thank you @KurtE !

Has anyone finally found a reliable method to hard reset an Arduino UNO R4 WIFI?

The root problem is that my BME280 (connected via i2c) spits out wrong number after a while (around these values: H = 100%, T = 180C and P = -180). However, after disconnecting the power, the sensor immediately starts working again.

I've tried adding an if statement that check for unrealistic values and then calls NVIC_SystemReset(); but this doesn't not reset the Arduino so that it starts working again, which turning it off and on does.

I also tried these two methods (https://www.thegeekpub.com/276838/how-to-reset-an-arduino-using-code & https://www.instructables.com/two-ways-to-reset-arduino-in-software/) that connect the reset pin with another pin but as soon as they are connected it stops working.

So I am looking a way to properly restart the Arduino to get normal sensor values again.

I could easily be wrong, but I am not sure that is what you need in this case.

The problem may be with the actual sensor, and just rebooting may not fix the issue.

Not sure what software you are using to talk to the device. But I assume the
startup code probably does the Soft reset of the device as part of the start up code.
(Sending a B6 to register E0) and maybe wait 10ms...

If not try doing that.

The other possible alternative would be if you could potentially momentarily remove power from the sensor? Not sure of the power requirements if you could use an IO pin to power it. I probably would not try it directly but maybe through a transistor or relay...

1 Like

Thanks for the suggestion. This was indeed helpful.

Here what I did: I used a NPN 2N3904 transistor and 1kΩ resistor for the control pin. As soon as I detected wrong values (e.g. negative pressure value), I turn off the power to the I2C devices, wait 5 seconds and turn them back on. After that I also initialise the sensors again.

So far it worked once under real conditions but I will keep an eye on it and report back if it is not a long term solution.

1 Like