element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino resets when solenoid shuts off
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 54 replies
  • Answers 16 answers
  • Subscribers 396 subscribers
  • Views 8630 views
  • Users 0 members are here
  • emi_protection
  • arduino
Related

Arduino resets when solenoid shuts off

Former Member
Former Member over 11 years ago

I have an arduino hooked to a 2 relay board. Each relay is opto-isolated. The arduino and board each have their own 5V power feed. The relays are switching 12V to controll a motor and a solenoid valve.

Sometimes when the solenoid turns off, the arduino resets. From what I've read, it's likely an EMI problem caused by the solenoid. If I disconnect the solenoid, I don't see the problem.

I've seen various suggestions about using a varistor or a diode, but I don't know which is better or what values to try. Any recommendations?

I'm assuming that the varistor or diode should be as close to the solenoid as possible, shorting the power and ground lines, is this correct?

 

Thanks,

Chris

  • Sign in to reply
  • Cancel

Top Replies

  • c4m4ch0
    c4m4ch0 over 8 years ago in reply to maranatha +3 suggested
    Hello maranatha, you just need to connect the diode as it is in this image
  • Former Member
    Former Member over 11 years ago in reply to michaelkellett +2 suggested
    I put an IN4004 Rectifier Diode across the terminals of the solenoid and that seems to have solved the problem. I also found this page pretty educational: http://en.wikipedia.org/wiki/Flyback_diode
  • maranatha
    maranatha over 8 years ago in reply to Former Member +1
    Hi Chris Do you happen to have the connection diagram? I am facing similar problem and it would be really helpful if you could share a connection diagram (basically how you connect the rectifier diode…
Parents
  • D_Hersey
    0 D_Hersey over 8 years ago

    You may also want to use some ferrite beads on your power feed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • COMPACT
    0 COMPACT over 8 years ago in reply to D_Hersey

    Trying to find the root cause first.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • COMPACT
    0 COMPACT over 8 years ago in reply to D_Hersey

    Trying to find the root cause first.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 8 years ago in reply to COMPACT

    In nearly every conversation we've had on this forum that involved a stepper, relay or other inductive load, adding a large (10,000uF) cap fixes it.

     

    Most people are not using a decent supply with suitable capacitance to handle the spike, and therfore when it is energised it causes a brownout on the supply which resets the Arduino.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • COMPACT
    0 COMPACT over 8 years ago in reply to mcb1

    Didn't I already suggest that as a possible cause by saying - "You also need enough power budget on the driving voltage as not cause it to sag and stop correct operation."

     

    It doesn't immediately explain why the lack of connection of an HDMI monitor to the Rpi is causing the arduino to misbehave.

    From what I understand thus far;

     

    • The arduino and Rpi work fine when the Rpi is connected or not connected to an HDMI monitor if the RPi and arduino are not connected together but can be in close proximity to each other.

     

    • The arduino becomes intermittently unstable when its relay is controlling the Rpi power only when no HDMI monitor is connected to the Rpi.

     

    However I don't know the behaviour when the Rpi Power is not controlled by the arduino but with only one Rpi power lead connected to the relay (with or without the HDMI monitor attached to the RPi).

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • maranatha
    0 maranatha over 8 years ago in reply to COMPACT

    Hi COMPACT

     

    Yes, you did say "You also need enough power budget on the driving voltage as not cause it to sag and stop correct operation." My battery can provide 2.1A@5V for the RPi and I thought that should be fine. I also tried to power the Arduino from an external power supply 2.25A @7-12V.

     

    If I understand your last question correctly, I think I already answered what happens when one of the RPi power lead is connected to the relay (in the three points I mentioned before). The Arduino doesn't reset. I tried both power leads one by one and it didn't affect.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • COMPACT
    0 COMPACT over 8 years ago in reply to maranatha

    So is the problem only evident when the Rpi power is switched on/off by the arduino relay?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • maranatha
    0 maranatha over 8 years ago in reply to COMPACT

    Yes, that is the situation.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • COMPACT
    0 COMPACT over 8 years ago in reply to maranatha

    Is it only at the time the Rpi is turned on?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • maranatha
    0 maranatha over 8 years ago in reply to COMPACT

    The relay unlatches after few seconds (~3-4 sec)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to maranatha

    The schematic for the relay board is here

    http://shop.emscdn.com/catalog/emskits/relayshield/kitv1/G5LA_E.pdf

     

     

    The 100uF is not adequate for powering via the USB ...

    image

    BUT you made the statement that you have tried powering the Arduino from an external 7-12v supply.

     

     

    The Arduino will switch between USB and external power to whatever has the greater value.

    The external socket goes through a regulator so it needs 7v minimum and the regulator is 500mA on proper Arduino's.

    Some copies may not be supplying 500mA, and if the input voltage is not greater than the regulator dropout (2v) then weird stuff can happen.

     

    The relay specs are 72mA for the 5v version BUT this is after it has pulled in and is operating.

    It is very likely to draw 2-4 times than amount as it pulls in. ie 288mA

     

     

    An Arduino draws 46mA when running.

     

    So you could experiment by putting a large (more than 1000uF) cap across the Vcc and GND pins of the shield.

    This should help eliminate any voltage sag causing a reset.

     

    Also just to be sure can you attach the Arduino code (paste it, highlight/select it and use the >> Syntax highlight and C++)

     

     

    Eventually we'll sort out the issue.

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • maranatha
    0 maranatha over 8 years ago in reply to mcb1

    Hi Mark

     

    I will replace the 100uF. I will rather solder a socket for plugging different capacitor values. Here is my code..

     

    // define pin for the relay output 
    #define RELAY 4
    
    //define pin for the PIR sensor input
    #define PIR 8
    
    //define pin for reading status of raspberry pi
    #define RPi 9
    
    void setup() {
      // put your setup code here, to run once:
      pinMode(RELAY, OUTPUT);
      pinMode(PIR, INPUT);
      pinMode(RPi, INPUT);
      digitalWrite(RELAY, LOW);
      digitalWrite(RELAY, LOW);  
      delay(1000);
    }
    
    void loop() {
      
      if(digitalRead(PIR) == HIGH){
        digitalWrite(RELAY, HIGH);   
        }   
    
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 8 years ago in reply to maranatha

    Thanks

    I presume the RPi detection aspects haven't yet been implemented ...

     

    You will need to tie the RPi GND and the Arduino GND together if you intend to detect it's state.

    Because the GPIO on the RPi is 3v3 the Arduino can handle it and it will be detected.

     

    You can simply put the cap onto the pins of the relay shield in the meantime.

    It will be enough to sort out the issue.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube