I'm pretty new to raspberry pi, and have fairly entry-level circuitry knowledge. For this project, I'm using a raspberry pi zero w. I'm putting this question in this stack exchange because I'm hoping that there's a programming solution with minimal circuit modifications.

I'm modifying a digital alarm clock so that while the alarm goes off, it triggers the pi to perform some task. I think the easiest way to do this is to just snip off the piezo buzzer so that the current that was sent there when the alarm sounds is redirected to the pi instead.

This way, I don't have to alter other parts of the clock. Ideally, I would be able to read it through a GPIO pin the same way I would a button press. I need the on state to be continuous, because the task starts when the alarm sounds and ends when the alarm is silenced.

There are two related things I'm not sure how to handle.

  1. The buzzer input is AC. (I don't have an oscilloscope--I'm just using a multimeter.)

  2. The voltage sent to the buzzer ramps up over about a minute. As I said, I'm hoping to treat this input like a button, so I just want it interpret it as on/off.

With my limited knowledge, it seems one straightforward solution might be to get a small AC relay. Depending on the specs, I wouldn't have to worry about the ramping-up voltage, and I'd have my button-like input without having to create any sort of rectifier, etc.

The ideal solution would be to take the input as-is (or with a resistor*) and solve the problem in python. But I don't know whether that's possible.

I'm open to solutions with more involved circuits, but I'd prefer to keep the circuit as simple as possible on this otherwise pretty simple project.

Thanks for the help!

* I'm not worried if the ramping up causes the pi to be triggered slightly after the alarm technically starts. I just don't want the high end of the voltage (~12V) to damage the pi. So I think I'll need to add resistance to the circuit, but there may be a better way.

  • 1
    This is NOT a Pi question. You need to define what the device outputs and design a circuit to convert to 0 - 3.3V signal. The answer would be the same for any microcontroller.
    – Milliways
    Aug 8, 2023 at 5:24
  • 1
    Why not just program the Pi to replace the alarm clock?
    – joan
    Aug 8, 2023 at 8:15
  • @Milliways I see your point, and I was on the fence about whether to post here. Part of what I need to understand is the reading of the GPIO pins—I don't know how constant a DC voltage the pin needs to read a continuous on state.
    – njc
    Aug 8, 2023 at 15:20
  • @joan That's a fair point—I just figured that if most of what I needed (LED time display, brightness control, the system for setting the alarm) already worked, why mess with it. I might still end up replacing everything, but hopefully not just because I don't understand how to read a fairly simple input!
    – njc
    Aug 8, 2023 at 15:26
  • The Pi GPIO will respond in less than a microsecond so depends on your code. There are other issues; specifically isolation (opening the clock casing would probably violate safety rules) and interfacing any external powered device is problematic - requiring circuitry to protect the Pi.
    – Milliways
    Aug 8, 2023 at 22:36

1 Answer 1


Your idea of using an AC relay in place of a piezo buzzer probably won't work, since the relay needs a lot more current than the buzzer, and the driver circuit probably won't be able to supply that.

I'd just connect a diode to one of the buzzer pins, then measure the DC voltage between that and the clock ground. You'll also need a small amount of capacitance between the DC output and ground, 0.1 uF should do.

Once you know the DC voltage, you can think about connecting it to the Pi; you'll need a potential divider if it is more than 3V.

  • Thank you! Will the intermittent (but high frequency) pulses coming through the diode be read as a continuous on state by the GPIO pin? Do I need to adjust the way the pin input is interpreted?
    – njc
    Aug 8, 2023 at 15:14
  • I'm assuming the capacitor is there to smooth it out some, but I don't know the limits/requirements of GPIO
    – njc
    Aug 8, 2023 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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