12v relay and external power supplies

Hey all,

So far, I have a pretty successful arduino setup... checking multiple temperatures of an aquaponics setup, water levels, lights, etc. I was noticing that my pH values were very low (~3), so did a ton of reading, and everything seemed to point to a lack of power... easy! I threw a 12v 1A power supply to my arduino, and everything seems to be working nicely now, except my relay!

I have the relay running on it's own 12v power supply, power going to Vin, the normally closed pin and ground. I have my arduino power to Vcc, ground (common ground between both external power supplies) and the individual control pins, so everything SHOULD be separate. The problem is, the relay now will switch between open and closed constantly, with no break between... constant clicks.

Anyone run into anything like this? Obviously it's something I've done, I just don't know what!

Thanks!

Obviously we can't see your relay or code. How you described hooking it up is unclear.

I would like to see a schematic and code

Can do!

Pertinent code:

const int floatSensor = 53; const int waterValve = 7;

if (digitalRead (floatSensor) == LOW) { digitalWrite(waterValve, HIGH); waterOn = false; } else { digitalWrite(waterValve, LOW); waterOn = true; }

As for a schematic, give me a bit... never drawn one and I'm currently at work (hope my boss doesn't check the forum, and hope there isn't a keystroke logger! lol).

ok, also can you put the full code in the correct way please.

when you go to post. just to the top left of the text box above the smiley face there is " </> "

click on that and post your code in the brackets

lol, sure :)

const int floatSensor = 53;
const int waterValve = 7;


  if (digitalRead (floatSensor) == LOW)
  {
    digitalWrite(waterValve, HIGH);
    waterOn = false;
 }
  else {
    digitalWrite(waterValve, LOW);
    waterOn = true;
 }

that's the code? the whole thing?

where's the setup and loop?

That is the pertinent code. The entire sketch is almost 600 lines long and none of the rest of it ever effects this piece of the code, ever. This is the first thing run inside the Loop.

ok.

what is the purpose of the "waterOn"

seems like to turn it on and off you wouldn't need that there if the only think activating it is the float sensor

waterOn is a boolean that tells it to send information via TCP to the server app and database that I've built. It keeps it from pushing the data with every single loop. It doesn't effect the relay at all, and I should have actually pulled it to remove any red herrings, oops! :)

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)

luxton: Hey all,

So far, I have a pretty successful arduino setup... checking multiple temperatures of an aquaponics setup, water levels, lights, etc. I was noticing that my pH values were very low (~3), so did a ton of reading, and everything seemed to point to a lack of power... easy! I threw a 12v 1A power supply to my arduino, and everything seems to be working nicely now, except my relay!

I have the relay running on it's own 12v power supply, power going to Vin, the normally closed pin and ground. I have my arduino power to Vcc, ground (common ground between both external power supplies) and the individual control pins, so everything SHOULD be separate. The problem is, the relay now will switch between open and closed constantly, with no break between... constant clicks.

Anyone run into anything like this? Obviously it's something I've done, I just don't know what!

Thanks!

Sounds like a potential Hysteresis issue.

Hi,

How many floats do you have?

If only one float switch, you will need to monitor the switch as you do now if it is low and needs the pump to run, but once the float switch indicates that the tank is full, turn the pump OFF, then ONLY check the float every minute or so.

Currently I would say that once the tank is full the pump switches OFF, then the level drops a little, turning the float switch back ON, then OFF when it fills that little bit.

Ideally you should have HIGH and LOW level switches, this would give your system some rest time.

Tom... :)

Hmm, I could definitely put a milli timer on it to make sure there's no race conditions. Pretty sure that's not the problem tho as I have it printing out to the serial monitor every time it's changing, and there aren't any entries.

I didn't get a chance to draw out the relay wiring last night (DOH), beers with the boss had to happen, lol. I'm fairly certain that's where the issue is going to be though, as that's where I have the least amount of experience (20+ years of professional programming experience, pretty solid on the code).

Does anyone have any good links that show proper wiring for a relay like this? Something REALLY simple, I'm learning :) I spent a couple days looking for a diagram that's simple enough I could copy it, but maybe the image I copied was flawed itself.

Thanks all!!!

Hi,
Can you post a picture of your project?
Show us what your relays look like and how they are connected?

Thanks… Tom… :slight_smile:

For sure, I just have to finish the work day... currently 10:30am here... stupid work getting the in the way of home projects! ;)