relay

i am using emontxshield to monitor usage of electricity but i want to add a relay shield on top of it has any one done the similar job before, i dont know how to edit the code

calypso_rae's picture

Re: relay

What do you want to use the relay for?

chunyang's picture

Re: relay

for providng the safety for the circuit, for example , if there is current exceeds 5A then the relay cuts the circuit and resume in 5 seconds something like that

calypso_rae's picture

Re: relay

OK, that sounds fairly straightforward.  When you activate the relay, you'll need to record the time, e.g.

if (<the operate criteria for your relay>) {

 <activate the relay>

  static unsigned long relayActivatedAt = millis(); }

You'll also need to include a release block in loop(), e.g.

if (millis() > (relayActivatedAt + 5000)) {

  <release the relay> }

Disclaimer: Please note that the above code fragments are simply to show how you can implement what you have asked for.  I am not saying that this is a good way to deal with circuits that draw too much current!

 

 

Mattia Rossi's picture

Re: relay

... And please note that unless you use a shield with opto isolated circuitry then you really don't want to have 5A of ac running near your arduino circuitry ... And if the load you're measuring is not resistive in nature (incandescent bulbs) then you really really don't want to drive that circuit with a relay on the shield ....

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.