Not that there will ever be a clear night in my area again.. I’ve continued to refine the barn door tracker.
So as I said in my last post.. the tracker will home itself now upon power up or reset. The process takes about a minute — mostly because the stepper won’t go more than 10rpm, and in the final homing stage I go 2rpm so I approach the home click slowly.
Well other than looking at the gears to see what direction they are spinning, which seems difficult if it’s dark out, also considering everything is in black plastic, I decided to put some audio feedback in the system. Now it beeps out beep codes telling me what it’s up to.
To do that I bought one of these, Fielect Active Buzzer Modules:
Click the image if you’d like to check it out on Amazon. If you decide to buy one too, and use that link it will help support this blog.
Now it came with no instructions, just labels on the pins, vcc, i/o, gnd. and some printing on the bottom saying it has a low trigger. Oh, and the buzzer itself has a sticky label on it that says “Remove after washing”… uhm… washing? At any rate, it seemed logical to remove the sticker since it covers up the sound hole of the buzzer.
So my assumption is, if I put a logic low on the i/o pin it will beep, and a logic 1, it should be silent. and I connected up power to 5 volts.. hey because I have a pin header where I can get 5 volts, and not where I can get 3.3volts.
Well that’s not gonna work… the ESP32 logic level 1 is 3.3 volts. Apparently that’s not high enough to convince the transistor on the unit to see logic level 1. So no matter what digital output, LOW, or HIGH I put out, it just constantly beeps. And it beeps loudly.
OK, so I’m lazy, I could unplug all the leads to the ESP32 for the tracker, solder on a pin header where I can get 3.3 volts to supply the beeper, and re-wire everything. What a mess.
So it was time for some hacking. Normally in Arduino land, you say “pinMode(PIN, OUTPUT). Then digitalWrite(PIN, HIGH) puts out 3.3 volts), and digitalWrite(PIN, LOW) puts out 0 volts.
But if you say pinMode(PIN, OUTPUT_OPEN_DRAIN) it does something else… digitalWrite(PIN, HIGH) floats the pin (in other words like no connection), and digitalWrite(PIN, LOW) grounds the pin.
Now that works. I can turn the beep on and off. But yes.. it is a total hack, that avoids taking things apart and getting out the soldering iron.
I did verify, using a different ESP32 I have which has 3.3v on a pin header, and the beeper works as expected. Configuring it as just OUTPUT, and sending out a LOW turns makes it beep, sending out a HIGH turns off the beep.
I’ve seen people online try to use Arduino tone() with these things, and yes that will make it put out different frequency tones, but an active buzzer is not supposed to be used that way.
Here is some code demonstrating both switching the beeper on and of — for a little blip of time, and then using tone.
// pins -- beeper vcc to 3.3v, gnd to gnd, i/o to io26
#define BEEP_PIN 26
void setup() {
pinMode(BEEP_PIN, OUTPUT);
digitalWrite(BEEP_PIN, HIGH);
}
void loop() {
digitalWrite(BEEP_PIN, LOW);
delay(2);
digitalWrite(BEEP_PIN, HIGH);
delay(1000);
tone(BEEP_PIN, 400, 500);
delay(1000);
}
Overall, I’d say I like this buzzer. It works exactly as expected.