WatchDog timer error

hi, i am using a watchdog timer in my project. the watchdog responds to the hardware around it and restarts the arduino. What's wrong with him? I'm using a time relay that has nothing to do with arduin when I quickly turn the time relay off and on watchdog hits. I don't have any special parameters in the watchdog the timer is at 4s and I restart quite often

Code ?
Schematic ?

More details needed

#include <avr/wdt.h>
 wdt_enable(WDTO_4S);
wdt_reset();

one is a long code that is tuned and non-jamming I tried it to run for a few days and tried the function without a watchdog timer. only one function makes a mistake and it is a time relay


label revi only starts when the switching frequency variables are valid at most once an hour. If relay K1 closes, the power supply for the magnetic contact, which is in series with the time relay controlled by AC24V, closes. When I disconnect all the peripherals from the arduino and leave it connected only the power restart is done as well, so it comes from the noise in the power supply.


Power supply: transformer 230 / 24v 50HZ and further according to the diagram above

bootloader latest optiloader, I tried to change Fuses according to the board, but nothing helped even the huge capacity in the power supply

Show your entire code or, even better, a minimal working sketch which demonstrates the problem.

What is the purpose of the watch dog timer in your sketch ? To force the sketch to restart if something gets blocked for 4 seconds or, on demand, enforce a sleep for 4 seconds ?

Which Arduino are you using ?

Despite extensive software and hardware testing, faults will still occur in real devices. Even momentary noise spikes on a power supply can lock up a processor occasionally. Such events will occur on the power grid several times a year. Watchdog timers provide a last line of defense to prevent system failure with minimal hardware cost.

I found this and I think this is the problem of the whole arduino nano even if I load an empty code in the power supply it shows an anomaly that is able to hack the program
I need to come up with some filtering that will effectively remove the noise. do you have any ideas?

The major problem here is the scrambled wiring. To avoid interference between different parts, it is essential to keep all connections between one part and another tightly bundled either by using ribbon-type wire, or tying with cord (nylon fishing line is convenient) so that there are no open loops in the wiring between a power or signal line and its matching ground return as such open loops function as little coupling transformers. It is necessary to understand that these microcontrollers operate at "RF" - radio frequencies - and the principles of radio transmission apply.

The components you are using operate at radio frequencies ("RF"). By having open loops of wire, you are introducing "air wound" RF coupling transformers and coupling capacitors all over your layout to couple impulses from one part to another.

And note this especially applies to the wiring to motors, solenoids etc.

Yes, it's a power supply when the inductive load changes rapidly, it makes a mess. I don't know how to filter it. My cables are shielded

It's not so much a matter of shielding, as wiring layout - avoiding any form of open loop between a power or signal line and its corresponding ground.

The problem is not so much voltage spikes, as switching large currents, so it is more the magnetic field than the electric.

I take it you do reset the watchdog within “loop” ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.