# Reset by software Arduino R4

**URL:** <https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313>\
**Category:** UNO R4 Minima\
**Created:** [August 2, 2023, 3:32pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313 "2023-08-02T15:32:22Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![moulletd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/moulletd/32/1013044_2.png) [@moulletd](https://forum.arduino.cc/u/moulletd)\
**Post date:** [August 2, 2023, 3:32pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/1 "2023-08-02T15:32:22Z")

</div>

Hello,

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

---

<div class="post-metadata">

**Author:** ![apf1979](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/apf1979/32/966781_2.png) [@apf1979](https://forum.arduino.cc/u/apf1979)\
**Post date:** [August 2, 2023, 3:37pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/2 "2023-08-02T15:37:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moulletd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/moulletd/32/1013044_2.png) [@moulletd](https://forum.arduino.cc/u/moulletd)\
**Post date:** [August 2, 2023, 3:47pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/3 "2023-08-02T15:47:21Z")

</div>

Thanks for the quick answer,

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

---

<div class="post-metadata">

**Author:** ![alranel](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alranel/32/211210_2.png) [@alranel](https://forum.arduino.cc/u/alranel)\
**Post date:** [August 2, 2023, 3:54pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/4 "2023-08-02T15:54:36Z")

</div>

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

(There's also a [pending proposal](https://github.com/arduino/language/discussions/7) for a nicer, portable, command for that)

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [August 2, 2023, 3:55pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/5 "2023-08-02T15:55:20Z")

</div>

Why do you need to reset it?

---

<div class="post-metadata">

**Author:** ![moulletd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/moulletd/32/1013044_2.png) [@moulletd](https://forum.arduino.cc/u/moulletd)\
**Post date:** [August 2, 2023, 4:48pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/6 "2023-08-02T16:48:40Z")

</div>

Thank you it's perfect !

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [August 2, 2023, 4:50pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/8 "2023-08-02T16:50:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moulletd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/moulletd/32/1013044_2.png) [@moulletd](https://forum.arduino.cc/u/moulletd)\
**Post date:** [August 2, 2023, 4:57pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/9 "2023-08-02T16:57:49Z")

</div>

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 ...)

---

<div class="post-metadata">

**Author:** ![togletree](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/togletree/32/1283244_2.png) [@togletree](https://forum.arduino.cc/u/togletree)\
**Post date:** [October 9, 2023, 6:55pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/10 "2023-10-09T18:55:30Z")

</div>

> [@alranel](#):
>
> NVIC\_SystemReset

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.

---

<div class="post-metadata">

**Author:** ![flynace](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@flynace](https://forum.arduino.cc/u/flynace)\
**Post date:** [October 10, 2023, 4:03am UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/11 "2023-10-10T04:03:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KurtE](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kurte/32/1246572_2.png) [@KurtE](https://forum.arduino.cc/u/KurtE)\
**Post date:** [October 10, 2023, 4:39am UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/12 "2023-10-10T04:39:12Z")

</div>

Maybe take look at this post

> [@Uploaded sketch with HID.h difficult to upload new sketch](https://forum.arduino.cc/t/uploaded-sketch-with-hid-h-difficult-to-upload-new-sketch/1168847/8):
>
> Proof of concept sketch that includes HID.h then switches back to the ESP32-S3 for the next upload. // Uno R4 WiFi serial console to WiFi/BT AT command processor running on the // ESP32-S3. Including HID.h results in the USB mux switching to the RA4M1. // The serial console (Serial) is the RA4M1 USB controller. // // Example Send: "AT+FWVERSION?\n" Receive: "+FWVERSION: 0.3.0\r\nOK\r\n" // // Special feature: If '~' is received on the serial console, the USB mux is // switched back to the …

At thr part

```arduino

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

```

---

<div class="post-metadata">

**Author:** ![flynace](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@flynace](https://forum.arduino.cc/u/flynace)\
**Post date:** [October 10, 2023, 9:23am UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/13 "2023-10-10T09:23:58Z")

</div>

That works great - thank you @KurtE !

---

<div class="post-metadata">

**Author:** ![jaquent](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jaquent/32/1181194_2.png) [@jaquent](https://forum.arduino.cc/u/jaquent)\
**Post date:** [January 23, 2025, 2:35pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/14 "2025-01-23T14:35:47Z")

</div>

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.thegeekpub.com/276838/how-to-reset-an-arduino-using-code) & [https://www.instructables.com/two-ways-to-reset-arduino-in-software/](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.

---

<div class="post-metadata">

**Author:** ![KurtE](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kurte/32/1246572_2.png) [@KurtE](https://forum.arduino.cc/u/KurtE)\
**Post date:** [January 23, 2025, 4:44pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/15 "2025-01-23T16:44:52Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![jaquent](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jaquent/32/1181194_2.png) [@jaquent](https://forum.arduino.cc/u/jaquent)\
**Post date:** [January 25, 2025, 1:08pm UTC](https://forum.arduino.cc/t/reset-by-software-arduino-r4/1154313/16 "2025-01-25T13:08:06Z")

</div>

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.
