Piezo beeper warbles over 880 hz?

I’m trying to add a warning beeper piezo to my project by following this documentation
https://docs.particle.io/reference/device-os/firmware/electron/#serial

I get nice stable beeps at 880 hz or less but above that the tone flutters noticeably (and annoyingly)
I’ve got an RGB LED strip with two color chasing effect (“Circus Combustus”) could that be the cause?

I’ve tried several of the output pins listed in the above doc, but they all do the same thing.

The beeper is a warning and the 880hz tone just isn’t quite right for that purpose. (I also want the beeper as loud as possible).

Could you link to the beeper you are trying to use? I can’t really correlate the serial documentation to how you are interfacing a beeper. Seeing some code would help too.

These are the beepers: https://www.amazon.com/gp/product/B07D8MQ9ZW/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1

And this is the loop:

int beepdelay=0;
void loop() {


//  Servo management code

    if(millis() - startupTime < 10000)
    	{
        myservo.write(0);       // move servo to 0° - ding!
        delay(10);
        beepdelay=0;
        }
    else 
        {
    	if(millis() - startupTime < 15000)
    		{
    		myservo.write(100);       // move servo to 25° - ding!
    		delay(10);
    		if(beepdelay>60)
    		    {
    		        tone(B3, 880, 60);
    		        beepdelay = 0;
		        }
	        else
	            {
                    beepdelay++;
	            }
    		}
		else
    		{
            if(millis() - startupTime > 15000)
        		{
    			myservo.write(0);       // move servo to 0° - ding!
    			delay(10);
        		}
    		else
        		{
    			myservo.write(0);       // move servo to 0° - ding!
        		}
        	}
    	}

The details in the Amazon link seem to indicate that the buzzer outputs a fixed frequency of 2300 Hz. All you have to do is apply 5v and it will continuously output sound. Why are you trying to drive it with the tone() function? I don’t have one to test so correct me if I’m wrong.

3 Likes

@ninjatill,

You are correct. Those types of buzzers have internal electronics to produce the tone. They are not meant to be given a PWM signal to adjust it. Just straight DC voltage only.

4 Likes

If you want to emit a specific frequency you’d rather need a (piezo) transducer/speaker and not a buzzer.

Confirmed!

Setting the pinMode to output and setting it HIGH does beep properly, the beep is perfect now.

The weird thing is before switching to Particle I was using Arduino and the tone command worked fine, but there was nothing else going on at the same time at that point in the project. Now that I’ve got the chaser lights running when the beep occurs it sounded different.

Thanks everyone!

1 Like