magnetic buzzer as alarm

Hello!
I have been trying to replicate this project from Instructibles

but I have to work with this magnetic buzzer

The problem is, when I use the digital pin, the sound is too faint to be an alarm; but when the ID-20 uses the buzzer when it reads a card, the sound is loud. It says that the ID-20 pin 10 transmits 3.3kHz to the buzzer. I tried using an analog pin of arduino to send a frequency to the buzzer but it doesn’t work.

Here’s the code → http://www.instructables.com/files/orig/FLV/OEAK/GCEVBJMU/FLVOEAKGCEVBJMU.txt

#include <EEPROM.h>// Needed to write to EEPROM storage

#define powerPin 10 // Blue LED
#define failPin 11 // Red LED
#define passPin 12 // Grenn LED
#define doorPin 9 // Relay 
#define alarmPin 13 // Alarm

boolean programMode = false; // Initialize program mode to false
boolean deleteMode = false; // Initialize delete mode to false
boolean wipeMode = false; // Initialize wipe mode to false
boolean match = false; // initialize card match to false

byte storedCard[6]; // Stores an ID read from EEPROM
byte readCard[6]; // Sotres an ID read from the RFID reader
byte checksum = 0; // Stores the checksum to verify the ID 

int alarm = 0; // Extra Security 

void setup() 
{
pinMode(powerPin, OUTPUT); // Connected to Blue on tri-color LED to indicate reader is ready
pinMode(passPin, OUTPUT); // Connected to Green on tri-color LED to indicate user is valid
pinMode(failPin, OUTPUT); // Connected to Red on tri-color LED to indicate user is NOT valid or read failed
pinMode(doorPin, OUTPUT); // Connected to relay to activate the door lock
pinMode(alarmPin, OUTPUT); // Connected to alarm
alarm = 0;
Serial.begin(9600); // Connect to the serial port
}

void loop () 
{
byte val = 0; // Temp variable to hold the current byte
normalModeOn(); // Normal mode, blue Power LED is on, all others are off
if (alarm == 3)
{
digitalWrite(alarmPin, HIGH); // Alarm!
Serial.begin(9600);
if(Serial.available() > 0) // Waits for something to come on the serial line
{
if((val = Serial.read()) == 2) // First Byte should be 2, STX byte 
{ 
getID(); // Get the ID, sets readCard = to the read ID
if ( isMaster(readCard) ) // Check to see if it is the master programing card or delete card
{
digitalWrite(alarmPin, LOW);
alarm = 0;
checksum = 0;

}
else
checksum = 0;

}
}
checksum=0;
}
else
{

if ( programMode) // Program mode to add a new ID card
{
programModeOn(); // Program Mode cycles through RGB waiting to read a new card
if(Serial.available() > 0) // Waits for something to come on the serial line
{
if((val = Serial.read()) == 2) // First Byte should be 2, STX byte 
{ 
getID(); // Get the ID, sets readCard = to the read ID
if ( isMaster(readCard) || isDelete(readCard) || isWipe(readCard)) // Check to see if it is the master programing card or delete card
{
programMode = false;
if (isMaster(readCard))
openDoor(2);
else
failedWrite();
checksum = 0;
}
else
{
writeID(readCard); // If not, write the card to the EEPROM sotrage
programMode = false; // Turn off programing mode
checksum = 0; // Make sure the checksum is empty
}
}
}
}
else if ( deleteMode ) // Delete mode to delete an added ID card
{
deleteModeOn(); // Delete Mode cycles through RB waiting to read a new card
if(Serial.available() > 0) // Waits for something to come on the serial line
{
if((val = Serial.read()) == 2) // First Byte should be 2, STX byte 
{ 
getID(); // Get the ID, sets readCard = to the read ID
if ( isMaster(readCard) || isDelete(readCard) || isWipe(readCard) ) // Check to see if it is the master programing card or the Delete Card
{
deleteMode = false;
checksum = 0;
failedWrite();
}
else //if ( !isMaster(readCard) && !isDelete(readCard) )
{
deleteID(readCard); // If not, delete the card from the EEPROM sotrage
deleteMode = false; // Turn off delete mode
checksum = 0; // Make sure the checksum is empty
}
}
}
}
else if ( wipeMode ) // Wipe mode to wipe out the EEPROM
{
Serial.end();
wipeModeOn();
for (int i = 0; i < 512; i++) // Loop repeats equal to the number of array in EEPROM
{
EEPROM.write(i, 0);
}
wipeMode = false;
wipeModeOn();
Serial.begin(9600);
}
// Normal Operation...
else
{
if(Serial.available() > 0) // If the serial port is available and sending data...
{
if((val = Serial.read()) == 2) // First Byte should be 2, STX byte 
{ 
getID(); // Get the ID, sets readCard = to the read ID
byte bytesread = 0;
for ( int i = 0; i < 5; i++ ) // Loop 5 times
{
if ( readCard[i] < 16 ) // Print out 0 if < 16 to prepend output
Serial.print("0");
Serial.print(readCard[i], HEX); // Print out the hex value read in
Serial.print(" ");
}
Serial.println();
Serial.print("Checksum: ");
Serial.print(readCard[5], HEX); // Checksum read from the card
if ( readCard[5] == checksum ) // See if the 5th BYTE (the checksum) read in from the reader
{ // matches the checksum caculated 
checksum = 0; // If so, we can empty the variable storing the calculated checksum
//Serial.println(" passed"); 
//Serial.println();
if ( isMaster( readCard ) ) // Check to see if the card is the master programing card
{
programMode = true; // If so, enable programing mode
alarm = 0;
}
else if ( isDelete( readCard ) ) // Check to see if the card is the deletion card
{
deleteMode = true; // If so, enable deletion mode
alarm = 0;
}
else if ( isWipe( readCard ) ) // Check to see if the card is the deletion card
{
wipeMode = true; // If so, enable deletion mode
alarm = 0;
}
else 
{
if ( findID(readCard) ) // If not, see if the card is in the EEPROM
{
openDoor(2); // If it is, open the door lock
alarm = 0;
}
else
{
failed(); // If not, show that the ID was not valid
alarm++;
}
}
}
else // If the checksum failed
{ // Print out the checksum
/*
Serial.println(" error");
Serial.println();
Serial.print("[");
Serial.print(readCard[5], HEX);
Serial.print("] != [");
Serial.print(checksum, HEX);
Serial.print("] ");
*/
}
}
}
}
}
}

...

I replaced
#define alarmPin 13 to 14; and
digitalWrite(alarmPin, HIGH) to analogWrite(alarmPin, 500) from void loop()

Please help!

Coil Resistance ? 8.5 ± 1.3

If you continue trying to drive that thing directly from an Arduino pin you will damage the processor.

Notice in the E. MEASUREMENT METHOD section they show a transistor, resistor, and flyback diode? You need something similar.

Sorry for the late reply,

I used 2N3904 as driver with 220 ohms resistor and 1N4001 diode.

All I know is, the sound of the buzzer is louder when the ID-20 RFID Reader supplies the frequency but when I try it with my arduino the sound is too faint--like the sound of a mosquito flying near your ear.

Well, there are three possibilities...

  1. Something is wrong with your circuit.
  2. The ID-20 is driving the buzzer with a higher current (150 mA maximum according to the datasheet. Interestingly the math does not work out: 3 volts / 8.5 ohms = 353 milliamps.).
  3. The buzzer has been damaged.

If you can get the cover off of the ID-20 you may be able to work out what is being used to drive the buzzer.

I suspect you can find a piezoelectric buzzer that performs as well or better for under three dollars. Were I in your shoes I'd drop that thing in the trash and get something like this...
https://www.google.com/search?q=cpe+164

I'm using one buzzer to beep when a tag is detected and when an unrecognized tag is tapped 3 times (Is this okay?)
I don't get the number 2 and
the buzzer is working when a tag is detected.

I don't think I can do this without damaging what's inside :frowning: so I don't want to do this as much as possible

Hi, do you have a Digital Multimeter to measure some voltages for us.
Also what supply are you using for the buzzer, it may be too much for the arduino if you are using its 5V output.
Measure the supply volts when the buzzer is off and when its on.

Thanks Tom........ :slight_smile:

We're obviously talking past each other so it's time to take a step back.

...the buzzer is working when a tag is detected.

Time for you to explain what that means. When it works, is the buzzer being driven by this circuit?

...but when I try it with my arduino the sound is too faint...

Try what? Driving the buzzer directly from a pin on your Arduino? Driving the buzzer using a circuit similar to the one above but not the one above connected to a pin on your Arduino? Driving the buzzer using the exact circuit above but somehow connected to your Arduino?

Like this..

Q1 is for the D0 and Q2 is for the alarm. The alarm makes a very faint sound. Am I doing it wrong?

There we go. Instead of digitalWrite or analogWrite use tone...

tone( alarmPin, 4000, 1000 );

OR...

tone( alarmPin, 4000 );

...to start the sound and...

noTone( alarmPin );

...to stop it.