controlling a solonoid

I have a solonoid that fills a bottle by weight using a HX711
I have eveything working ok but am confused regarding components.

I have a 12v solonoid conected to a 9v ac/dc adapter.
The solonoid is triggered by 5V relay.

My question is should I use the relay or a circuit with a TIP120 ?
I am not sure of the difference ?
I have a diode between the solonoid and resisters were needed.

Does the solenoid work reliably from the roughly 9V DC that I assume your adapter provides?

If not, you need a higher voltage supply.

If yes, you should take your supply to the solenoid via the relay contacts, with a diode in parallel with the relay coil, (with its cathode to +V). The relay isolates the solenoid from your Arduino.

Despite the protection of the diode, to be on the safe side I'd personally use a separate 5V supply for the relay too, not the same supply powering the Arduino.

I'd recommend not powering your 5V relay directly from an Arduino pin, even if its current requirement is low. Instead, use an NPN transistor with the relay in its collector. A TIP 120 seems a bit on the heavy duty side though? Any small general purpose transistor should be satisfactory. Don't forget its base resistor.

(Sorry if you already know all this basic stuff!)

Wait… what now?

a 12v solenoid… being powered by 9v?

Why?

I have a 12v solonoid conected to a 9v ac/dc adapter.

And it works with only 9V?

The solonoid is triggered by 5V relay.

My question is should I use the relay or a circuit with a TIP120 ?

If you are using a relay board with a built-in driver circuit you don't need both. Either one can be used to control a larger current/voltage with a lower current/voltage. If you have just a relay you probably need to use the transistor in a driver circuit for the relay coil.

I am not sure of the difference ?

A relay is electrically isolated. There is no electrical connection between the coil and the contacts. A relay is simply an electromagnetically-controlled switch so it's a little easier to use in this application.

I have a diode between the solonoid and resisters were needed.

I'm not sure what you are using the resistors for.

There should be "flyback" diodes wired "backwards" across (in parallel with) both the relay coil and the solenoid coil. If you're using a relay board, that should already be built into the driver circuit.

...When power is disconnected from a coil the electromagnetic field collapses, generating a high reverse voltage ([u]back EMF[/u]). The voltage is high (maybe more than 1000V) when the circuit is first opened because the coil is "trying" to maintain current (as the field collapses) through an infinite resistance. The diode provides a low-resistance path for the current, keeping the voltage down to the diode's forward voltage (about 0.7V).