I am creating a auto top off circuit for my aquarium. I will using a float switch with a ATTiny85 to drive a relay that will control a water pump running of mains AC. I'll be using a NPN transistor to amplify the current from the ATTiny85 and a diode to protect against inductive current. The float switch is represented by a simple push button.
I have included a Fritz diagram of the circuit and I am hoping someone more knowledgable can review it and point out any flaws. Thank you in advance.
Osgeld:
you want some caps on the voltage regulator to smooth out any wonkyness from the wall supply and to filter out noise, and to prevent oscillation
you also need a resistor on the base of the transistor, and one end of the coil is connected to the diode and nothing else
finally I dont really know why you even need a micro controller, I have a similar setup with just a low current float switch and a relay
Thanks so much for the help! I will post an updated schematic with your changes.
I am only using the ATTiny to prevent the circuit from oscillating rapidly between on and off due to surface agitation. I also want it to turn off and stay off in the event that the switch is closed for more than 5 minutes.
eh what do I know, my original idea was just to cut the pump cord and let the two ends of the neutral wire sit in water, so when it got too low it would shut off the pump (I am watching too low of a level in a rank with a submersible pump pretty much same idea in different direction)
but noooo, the managers wouldn't let me do that, we had to spend money snark
Osgeld:
eh what do I know, my original idea was just to cut the pump cord and let the two ends of the neutral wire sit in water, so when it got too low it would shut off the pump (I am watching too low of a level in a rank with a submersible pump pretty much same idea in different direction)
but noooo, the managers wouldn't let me do that, we had to spend money snark
Wire ends in water doesn't sounds like a very durable solution, to be sure. But I don't get why you're going to all the bother of using a microcontroller when you already have a switch and a relay. Why not just wire the two together? I mean you could put an Arduino in there, or maybe two or three connected via GSM or ethernet or whatever else catches your eye, but it's really just Rube Goldberging your solution.
Thats what I am doing wire, switch and a relay, but the op has a good point as his situation involves a surface in motion (ie air bubbles and fish) so it would probably click on and off a bunch, with the avr in the mix you can use time delays and whatnot to dance around this problem.
Osgeld:
Thats what I am doing wire, switch and a relay, but the op has a good point as his situation involves a surface in motion (ie air bubbles and fish) so it would probably click on and off a bunch, with the avr in the mix you can use time delays and whatnot to dance around this problem.
Correct. That was my thinking with the ATTiny. Additionally, the avr will function as a failsafe. If the pump has been on for more than 2 minutes, it will shut off until the circuit is reset.
From your Fritzing diagram, it looks to me that you've connected the switch between +5v and one of the Attiny input pins, but you have no pulldown resistor. Either add a pulldown resistor from the pin to ground, or else connect the float switch between ground and the pin, then you can enable the internal pullup resistor.
dc42:
Either add a pulldown resistor from the pin to ground, or else connect the float switch between ground and the pin, then you can enable the internal pullup resistor.
Thanks I have modified my switches to use ground instead of +5v. Thanks for catching that.