-1
\$\begingroup\$

enter image description here

I will try to explain as quickly as possible. I am trying to get the solenoid to fire, it is not. The relay however is clicking on command.

I am recreating the circuit shown here https://www.instructables.com/A-Raspberry-Pi-Powered-Junk-Drum-Machine/ but with slight changes since my solenoid is not a 12V but I assume 9 volt (since it is typically charged by a 9 volt battery.)

I am forced to assume it is a powering issue or my wiring is wrong (although I do not understand how since I am posting here.) The wire I am using is typical bell wire from Home Depot. The relay I am using I believe is the same as the one in the project I linked but I believe has the same specs as the one below:

enter image description here

I am trying to get the solenoid to fire on command from the Raspberry Pi.

I have gotten it to work in the past with a 12volt 10 ampere battery pack but with code that executed as soon as the program started and then turned off. I changed the code and fried my previous solenoid realizing I had no idea what I was doing. But now I cannot get the solenoid to fire (even though my relay does click on command.)

The code I am calling is here:

const LED = new GPIO(9, 'out')


function fire(){
const blinkInterval = setInterval(blinkLED, 250);

function blinkLED() { //function to start blinking
  if (LED.readSync() === 0) { //check the pin state, if the state is 0 (or off)
    LED.writeSync(1); //set pin state to 1 (turn LED on)
  } else {
    LED.writeSync(0); //set pin state to 0 (turn LED off)
  }
}

function endBlink() { //function to stop blinking
  clearInterval(blinkInterval); // Stop blink intervals
  LED.writeSync(0); // Turn LED off
}

setTimeout(endBlink, 500); //Each 500 is a single shot
};
\$\endgroup\$
16
  • \$\begingroup\$ I just realized the circuit diagram I made isn't fairly accurate. The raspberry pi I KNOW is hooked up to the relay correctly so please ignore that part. \$\endgroup\$ – J. Doe Feb 26 at 11:28
  • 1
    \$\begingroup\$ Please fix your schematic and proofread your text. It's very unclear how you have this thing hooked up. \$\endgroup\$ – jwh20 Feb 26 at 11:54
  • \$\begingroup\$ So, we are to assume that the circuit is right and try to find what's wrong? Anyway, the most likely culprit is that your microcontroller does not have enough juice to make the solenoid work as expected. Try to add a transistor along the path to increase the current. Like here: nutsvolts.com/magazine/article/… (under relay drivers) \$\endgroup\$ – Sredni Vashtar Feb 26 at 12:04
  • \$\begingroup\$ @SredniVashtar: The solenoid isn't supposed to be powered from the Pi. There's a separate power supply for the solenoid in the schematic. The schematic is wrong, though. \$\endgroup\$ – JRE Feb 26 at 12:06
  • 2
    \$\begingroup\$ @J.Doe: 1. Your schematic is wrong. The relay cannot click if it is wired as the schematic shows. Fix the schematic. 2. After you fix the schematic post photos of how you built the circuit. You seem to have wired something wrong, and we can't help you find that from just the schematic diagram. \$\endgroup\$ – JRE Feb 26 at 12:09
2
\$\begingroup\$

The comments have made it clear that you don't understand the difference between a relay and a relay module, and that you don't understand what the contacts on a relay are for.

Here's a circuit that shows how your gadget should be built:

schematic

simulate this circuit – Schematic created using CircuitLab

I've shown the internal circuit of the module to make clear just what is going on.

You seem to have the input side wired correctly, since you hear the relay click.

The output side is where the error lies.

If you connected your solenoid and power supply to the NC and NO contacts, then the relay would click but the solenoid would not activate.

Your module should have the NC, NO, and C terminals marked, probably on the bottom side under the blue connector.

\$\endgroup\$
5
  • \$\begingroup\$ Hello, thank you with your help. I have tried to study what you have given me and I am still failing to understand why I am failing at designing this circuit. The solenoid does activate but it's uncontrollable with my current design (the one in the given link description I sent in the original post). Once plugged in, it just constantly clicks once I run the program instead of waiting on my queue. I really am trying to understand here. \$\endgroup\$ – J. Doe Mar 3 at 22:20
  • \$\begingroup\$ I guess what I am asking is I still don't fully comprehend in plain English why I might need to add extra steps to my circuit to get it to run while the original guide I have been using seems to only need the relay \$\endgroup\$ – J. Doe Mar 3 at 22:35
  • \$\begingroup\$ You probably don't need extra steps. You probably just need to do the ones you have right. You might have forgotten to connect the ground from the Pi to the relay module. \$\endgroup\$ – JRE Mar 3 at 22:57
  • \$\begingroup\$ I'll go over the circuit and rebuild it from the ground up again and try to explain clearly any issues I am having. I appreciate the continued help. \$\endgroup\$ – J. Doe Mar 4 at 0:36
  • \$\begingroup\$ Just wanted to bring this to a close. I appreciate the help. I tried to check the relay to see for NC NO and C terminals. I couldn't find where they were but realized that since I was getting power to the solenoid and you helped me walk through the issue, I figured if I kept taking note of where I plugged it in, I would figure out which contacts are which. The relay was setup backwards. I figured out the contacts by just plugging and playing. It works as designed now. Thank you. \$\endgroup\$ – J. Doe Mar 7 at 20:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.