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
  • 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
  • maranatha
    0 maranatha over 8 years ago in reply to mcb1

    Hi Mark

     

    Thanks.

    At the moment, I just want to power up the RPi when PIR sensor is active. If this issue is resolved, I will read the state of the RPi so that I can switch-off the relay when the RPi completed shutdown. I got this working when the display is connected.

    I got now 1F. I will replace the 100uF and see if the problem goes away. I hope I don't get electric shock with the 1F image

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

    Hello maranatha, can you use the arduino led (digital pin 13) to debug the problem? Turn on the led the same time you want to activate relay then click in the button that you replace by the PIR sensor and see what happen.

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

    Hi Mark

     

    Thank you!!!

     

    I have to confess that I had been ignoring some basic principles.  I almost went to cry when the 1F didn't resolve the issue. Desperately, I just connected the grounds of the raspberry pi and the arduino...and it worked. I said desperately, because I had the GNDs of both Arduino and RPi connected when I started the project. It was working. But then, somewhere on the internet I read that connecting the GNDs of two separate circuits can be dangerous. So, I removed it. Removing that common GND didn't affect the operation until I decided to run the RPi headless. I removed the HDMI display and I start to have this ugly problem for more than a month. I should have tested removing the HDMI display in my original setup where both GNDs are connected.

     

    I hope this fixes the problem permanently! I will just keep this 1F capacitor for decoupling. I have also soldered ferrite beads for extra protection.

     

    I would be more than happy if somebody could explain me about the relevance of connecting the GNDs of both

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

    Your diagram of your set up is incorrect. The most vital bit of information was missing - the input feed to the Arduino from the Rpi.

     

    If you want to keep both boards electrically isolated you'll need to use an optocoupler or a relay set in in reverse to drive the Arduino input pin to it's own gnd.

    You've got plenty of relays so it should be an issue.

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

    I'd remove the capacitor and ferrite beads for the moment.

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

    Removing that common GND didn't affect the operation until I decided to run the RPi headless

     

    Are you using wireless or ethernet to connect ot the RPi.?

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

    I am using WiFi. RPi-3 provides integrated WiFi.

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

    Hi COMPACT

     

    This is a preliminary test setup. I will have a pin feed from the RPi to the arduino for status check.

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

    Hi COMPACT

     

    This is a preliminary test setup. I will have a pin feed from the RPi to the arduino for status check.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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