Control buzzer via 5V relay system

Hi, I am trying to control piezo passive buzzer with a 5V relay system.
I practiced with this piano example using a switch and pull-down, and it works fine. When I click the switch, the tone is on, and normally it is off.
image

int buzzerPin =8;

void setup() {
  pinMode(2, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  if(digitalRead(2) == HIGH) {
    tone(buzzerPin, 100, 20);
  }
}

What I want is, instead of the switch, use my relay system to turn on and off the buzzer.
I already have a c++ visual studio code for sending digital output to my relay system, and successfully used in controlling other systems like controling active buzzer.

But when I connect my relay system instead of the switch, it does not work. Even though I activate my relay system to send out DO of 5V signal, no sound is generated.


The picture above is my relay system, and the connections I used in this example is colored in yellow. The red line is connected to 5V(+), the other black line is connected to the green grayhill board. And the other side of the red line is connected to number 4 in the circuit below (where switch's number 4 was, in previous example circuit). The black line is connected to place number 3.
Connection vice versa (red line-number 3, black line-number 4) generates sound continuously, even though I didn't send the DO 5V signal via relay system.

I want to know if my connections are wrong. If so, what should I do to control this passive buzzer with relay system's 5V on/off? Any advice would be helpful.

you need shared GNDs between your relay system and your arduino

PS: you might want to add a resistor in series with the piezo to ensure it does not draw too much current.

Thanks for the advice and I will add a resistor.
I connected a new wire with my relay system's 5v(-) to the arduino's GND, and it still does not work (no sound generated).
Am I missing something?

remove the buzzer, connect only the GNDs and the relay to pin 2

Try a simple code

const byte relayPin =2;

void setup() {
  pinMode(relayPin, INPUT);
  Serial.begin(115200);
}

void loop() {
  Serial.println(digitalRead(relayPin) == HIGH ? "HIGH" : "LOW");
  delay(10);
}

connect your arduino with USB to your computer, upload the code and open the serial monitor at 115200 bauds et see if the output on the screen matches the relay's state.

Make sure the relay does not output more than 5V...

You can tell that from the picture posted by @mmmmnimmn ?

If the connections labelled 3 & 4 on the breadboard connect to the NO and COM terminals of a relay, then no common ground is needed.

Piezo devices have a very high impedance. No resistor is needed.

OK - I think I had read that somewhere - probably misinformed then - you are right if they have a very high impedance then it's not needed

I could not from my phone.

The forum is unlikely to be able to help you with this.

You have already proved that the Arduino circuit works correctly by connecting that button in place of where your relay system connections go.

So the problem probably lies with how you connected your relay system, and it's unlikely anyone here will be familiar with how that works.

Are those conventional mechanical relays on that Grey hill board? Or are they solid state relays? If the latter, they may only work with high voltage AC devices.

@mmmmnimmn
What screw terminal number is the red wire connected to?

red wire is connected to 5V(+) and the black wire is connected to grey hill board's number 45.
The other sides are connected to arduino.

Thanks for the help anyways 8)

They are from Grey hill board. I am not sure which of the switch should correspond to the relay system. What I am trying to do is send an 5V signal to arduino's digital pin 2, and whenever digital pin 2 reads HIGH, generate the sound in buzzer.

Then neither wire provides a common ground?

Please provide a link to the schematic for that board.

The board is "Grayhill 24 Channel Rack (70RCK24)".

This is the link:
https://grayhill.com/products/control-products/racks/70xrcx24/70rck24/

gray hill.pdf (1.9 MB)

Connect like this:

Set pin 2 mode to INPUT

Thanks for the advice. I will try this.
Though I am concerned that number 46 of the Gray hill board is already used for other purpose.
For the GND connection, is it right that I should somehow find where the (-) GND in Gray hill board is located, and connect that part with Arduino's GND?

Then you need to find a free pair of relay contacts that you can use.
What about 39 and 40

oh I get what you mean, my problem should be that I didn't connect corresponding GND.
I will try 39 and 40. Since I am out of my lab, I will try it tomorrow. Thanks for the help everyone I really appreciate it

In my diagram connect 39 to the RED wire and 40 to the black

Okay I will. Thank you so much jim-p

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.