H-bridge board interfering with ethernet shield?

I have been banging my head against this problem for the better part of three days now. What I have is an Uno board that uses an ethernet shield (Wiznet 5100) and also connects to an L298N-based H-bridge board. I used a similar (if not identical) board, and identical L298N board on a very similar project last year and it worked perfectly.

What is happening is that the ethernet shield becomes unresponsive at random times, for a second or two at a time. I have found that if I disconnect either of the L298N inputs (to control the polarity of the associated output on the L298N), the problem goes away. Similarly, just disconnecting the motor fixes it as well. Of course, then my motor doesn't move, obviously........

I am using two outputs of the L298N to run one DC motor at 28vDC (also tried backing it off to 12v for good measure). The output of the L298N is jumpered to be always on, I control speed/direction with the two input pins on the L298N. These are connected to pins 3 and 9 of the Arduino.

I've tried three different L298N boards (same design, just different individual boards) and two of my Wiznet shields, no change. I suppose I could go with an opto-isolator, but I'd like to keep this interface as simple as possible.


Does your motor have proper noise supression capacitors on it? You may also want to loop the motor wires thru a ferrite ring.

Also - what are the ratings for the motor (stall current, mainly)?

Does the issue only happen when you are reversing directions? If so - what happens if you slowly ramp the speed down, then ramp it up in the opposite direction? Perhaps the abrupt changes are inducing a voltage spike?

Have you done any testing using an oscilloscope to even determine if noise or voltage spikes is the problem? I mean, it seems likely this is the issue, but using a tool to confirm it could be invaluable.

Unfortunately I don't have any specs on the motor, and it is buried inside a "non-repairable" drivetrain....it's from an old 1990s flight simulator. It belongs to someone else, so I am hesitant to crack it open.

With that being said, I did try placing a cap between the motor leads, no change (just guessing at what cap to try). I also tried a much smaller motor I had laying around, and it seemed to behave the same way.

The problem doesn't seem to be affected by speed or direction. It's completely random as long as power is applied to the motor.

I don't have a scope.....yes, I need one very badly! Getting old aircraft synchros/resolvers interfaced was, shall we say, mysterious? :)

With the problem persisting with another motor, I am starting to suspect this particular ethernet shield design. When I did my other L298N+ethernet instrument, I tried a couple different motors and never had the slightest issue. I also got by without caps on the motor, relying on the protection circuitry on the L298N board.



FIXED IT. There were a couple problems. I tried the sample UDP sketch that was in the ethernet v2 library, and it worked. Examining the code more closely, I found that the following line was different from my sketch. I had this:

#include <EthernetUdp.h>

…but had to change it to this:

#include <EthernetUdpV2_0.h>

But this was only half the problem. For some reason, we have to mess with the SD card enable/detect pins. Pin 4 must be set to HIGH on setup. To summarize, I had to have the following lines…note that I already had the W5200 line, just not the SDCARD line:

#define W5200_CS 10 // (this is presumably not necessary since it doesn’t get called in my sketch)
#define SDCARD_CS 4

Then in my setup function, I had to have this:

digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card

One thing that was messing me up is that I saw a sketch somewhere that had the above two lines, but referenced W5200 instead of SDCARD. I should have known that documentation was suspect, because the comment didn’t make sense either (“deselect W5200”…whaaa?)…but it was from a Seeedstudio official page or example, as I recall. I’m also a bit puzzled as to why the sketch compiled OK with just “#include <EthernetUdp.h>” when EthernetUdp.h doesn’t even exist anymore (like I said, I removed my old ethernet library).

Sure wish they had a “barebones” version of the ethernet shield that did just…ethernet. But it’s fine now that I am aware of the SD card issue. Perhaps I will use the card for logging flight data or something…

The AWESOME news is that my instrument is communicating flawlessly now! As far as I can tell, my entire original problem was caused by this junk ebay no-name ethernet shield. The Seeedstudio v2 looks as though it will perform as fast and rock-solid as the v1 I used on an altimeter last year (100% perfect performance, zero maintenance/tweaking, throughout many “flight” hours). I plan to use only the Seeedstudio ethernet shields from now on.

And fortunately my local RadioShack has more of these bad boys at $12.49 a pop…off I go to RS again after work tomorrow!

Previous post follows**

And another puzzling twist: today I took advantage of the smokin’ deals my local (soon to close) RadioShack has going, and cleaned out a bunch of their Arduino goodies. I got the Seeedstudio version 2 ethernet shield and decided to try it with my troubled arrangement discussed previously.

I changed the following line:
#include <Ethernet.h>

To this:
#include <EthernetV2_0.h>

I also found I had to remove my old Ethernet library and just have EthernetV2_0 in my libraries directory. I did not touch any other part of my code, as the Seeedstudio wiki indicated the new shield should work with old sketches, except for the change above to reference the new library.

The shield responds to ping, but I am unable to communicate via UDP. Specifically, Udp.parsePacket() never returns anything. I have been scouring the web for examples, but so far I see no differences in usage of the v2 shield vs the old one. Has anyone run into this with the latest Seeedstudio ethernet shield?

On the plus side, the shield seems to respond to ping faster, and it has also resolved an annoying issue I was having where the Arduino would frequently drop its USB connection and I would have to unplug/replug it to get my USB/serial debugging back. (No more junk Chinese ebay ethernet shields for me.) I am very hopeful that my original issue will also be resolved, if I could just get the crazy thing to talk!


Resurrecting this thread because I have new info on this issue (and a "rediscovered" problem).

See where I was talking about network communications cutting out at random times, and how the fix for that particular issue was to ditch the el cheapo W5100? Turns out the problem is indeed caused by driving the DC motor, but cheap Chinese junk was (this time) not to blame.....the reason it started working back in April is because I switched to the newer SeeedStudio v2.0 board.

Unfortunately, I ran into another issue with the v2.0: it's the reset-required-on-power-up issue that seems to be a bug in the ethernet shield. Basically, the v2.0 board (usually) does not initialize properly when the Uno+shield are being powered through the Vin pin. Resetting the shield fixes the issue, and the shield starts communicating. My fix was to revert back to the older v1.1 boards, like what I've been using on my own altimeter for over a year now. Strangely, even a couple of those older boards exhibit the same reset issue. I tried some of the fixes I found online, but what finally did it was removing the pin on the v1.1 shield that goes to the Arduino's reset pin, and running a 10k resistor in series between the ethernet shield's reset pin and ground. BIZARRE, but it has been 100% solid now for several days of testing. Now, this little trick does NOT work on the v2.0 shield, and I have no idea why.

But, wouldn't you know it, the v1.1 shields are cutting out randomly when power is applied to the DC motor through my L298N breakout board. Back to square one.

I am caught between "glitches" and it is driving me insane. As I've researched this problem deeper, I've found a lot of other folks having weird little problems with the ethernet shield, and not just the SeeedStudio version. For the amount of interfaces I'll be designing for my own flight simulator, I really need a network shield that "just works", but I'm not sure where to turn if the basic Arduino ethernet design has this many problems.

I suppose I will order some ferrite beads and try that, but I hate to start randomly throwing things at it without really understanding the problem.


ssue was to ditch the el cheapo W5100?

You sure you don't have a w5200 based ethernet shield, or something similar? Hard to dig thru the stuff you have posted.

Sorry for the disorganized brain-dump on this thread....I was posting things as I've found them. The current shield I am trying to make work, which is NOT affected by the motor, is a 5200-based shield.

My cheap 5100-based shield, and the older v1.1 SeeedStudio shield, are 5100-based.

Problem with the older (5100) boards: they randomly freeze (stop communicating) due to RF or voltage spikes or something when the DC motor is engaged. Speed/power doesn't seem to affect it. Various sizes of capacitors across the motor terminals have no effect. I thought this L298N breakout board had enough isolation circuitry to prevent such issues, so maybe it's RF.

Problem with the 5200 board: it simply REFUSES to init reliably on power-up. I've tried init hacks to reset the shield and not the Arduino (by removing the pin that connects the shield to the Uno's reset pin), I've tried a resistor to ground like I'm doing on the 5100 shields, I've tried all sorts of delays in my setup loop at all different stages of setup, nothing works. If I physically press the reset button after power-up, it works fine.

This problem alone has probably accounted for at least 25% of my total development time on the ENTIRE project (5 Uno+ethernet interfaces, six different sim instruments, a custom metal mounting plate, aircraft-grade wiring throughout for logic power, motor power, and instrument lighting). I'm just about to the point of telling the customer this one instrument will just have to be dead, or he will have to have a dumb "reset" button to hit on startup.


Problem with the older (5100) boards: they randomly freeze (stop communicating) due to RF or voltage spikes or something when the DC motor is engaged.

There is a 95% chance that is due to your power arrangement. Motors need to be powered separately from the arduino.

The only thing the motor and the Arduino share is ground. I'm pretty sure there is no way around this, as the H-bridge and the Arduino absolutely have to share ground, no? Power is from a big honkin' industrial-grade regulated power supply. 5vDC and 12vDC are on separate rails.

My solution (for now) was to switch back to the W5200-based shield, spend two sleepless nights banging my head against the reset bug, and finally giving up and installing a reset/init button. At this point I am more interested in the reset bug than the motor interference, since none of the other motors I've been working with here in my shop have caused a similar problem....there isn't really a way for me to explore a fix until I run across another motor/controller combo that causes the same issue.

I'd love to have fixed the interference problem, but this whole fiasco has put me even further behind on this and other projects....I still have a cockpit that is supposed to be ready to show in September.

Thanks to everyone who responded, I really appreciate the help. If anyone has any ideas on fixing the reset bug (or suggestions on my motor interference issue), please feel free to speak up. I'm gonna have to come up with some sort of reliable ethernet solution, my own cockpit is going to have quite a few ethernet-enabled Arduinos.


Do you monitor the output voltage on the motor power supply when the motor is supposed to be running? You might for testing purposes replace the motor with various sizes of 12v automotive light bulbs to see if your code and H-bridge can brighten/dim the bulbs.

xplanematt: If anyone has any ideas on fixing the reset bug, please feel free to speak up.

Hi Matt,

I realise that this post was made two years ago and you probably already have the answer, but I would like to share my experiences with reset issues on Wiznet chips. After purchasing a number of Ethernet Shields with W5100 chips, I found that on power up some would work perfectly but others refused to establish an Ethernet connection until they were manually reset with the reset button.

Upon further investigation, I found that that the Wiznet 5100 chip needs to be reset AFTER power is first applied. I believe that this may also be the case on the W5200 chip as well.

The Genuine Arduino Ethernet Shields were designed and manufactured with a CAT811 supervisory circuit chip. The CAT811 holds the reset to ground for at least 140ms after power has been applied to the board to achieve the required reset.

Unfortunately all of the clone boards that I have found are missing this little component. To make matters worse, some of these boards also have a bypass track added. There will be 4 pads in a SOT143 format adjacent to the reset switch that are empty. This is where the offending part should be installed. To fix the issue, cut the track between pads 2 & 3 and solder the MAX/CAT811 in place.

The original part was a CAT811TTBI-GT3 which is hard to find but the MAX811TEUS does the same job and is a suitable substitute.

More information can be found here: https://simulatorsolutions.com.au/small-part-big-problems/

Hope this helps,