Sounds Like RFID: Using a Radio Frequency Identification (RFID) Reader to Make Musical Instruments
|Areas of Science||
|Time Required||Short (2-5 days)|
|Prerequisites||Some previous programming experience (preferably in Python), or interest in learning how to write Python code, is preferable. Musical background is also helpful, but not required.|
|Material Availability||This science project requires an RFID reader and tags. See the Materials list for details.|
|Cost||Average ($50 - $100)|
|Safety||The construction steps require use of a craft knife and hot glue. Be careful when using these items and ask an adult if you need assistance.|
AbstractPassports, identification cards, bus passes, and even some credit cards contain RFID tags. An RFID (radio-frequency identification) tag allows a card to be read by a computer from a short distance away. While this is very useful in everyday life, would you believe you can make music with it? RFID + sampled music sounds + a little crafting = a fun musical instrument that is limited only by your imagination. In this science project, you will make handbells out of paper cups that play real sounds, thanks to a little RFID magic.
To use an inexpensive RFID reader to build a simulation of professional handbells.
Howard Eglowstein, Science Buddies
- Microsoft Windows® is a registered trademark of Microsoft Corporation.
- Macintosh®, Mac® and 'OS X'® are registered trademarks of Apple, Inc.
- Apple® is a registered trademark of Apple, Inc.
- Linux® is a registered trademark of Linus Torvalds.
- Hyperteminal® is a registered trademark of Hilgraeve, Inc.
Cite This PageGeneral citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.
Last edit date: 2020-11-20
Why is some of the best technology wasted on boring stuff? What if you could take a radio frequency identification (RFID) reader and turn it into a fun musical instrument?
RFID is an increasingly popular way for people to pass information to a computerized system. It is often in the form of a card that you might have received as a school ID or a bus pass, but can also be found in the windshield transponder device that lets your parents drive through a tollbooth on their daily commute without stopping. Unlike magnetic stripe cards that require you to slide the card through a slot, an RFID reader can simply recognize the card from a distance away and get the information that is stored on it. It is also a great technology for warehouses; for instance, a commercial RFID reader mounted on a forklift can read an RFID tag from 100 or more feet away and help the operator identify what might be inside a box. RFID can be controversial as well (it raises privacy issues), but it can also be a lot of fun. You are going to use a small hobbyist RFID reader to make a musical instrument that sounds just like the real thing. Nothing controversial about that!
Several companies sell small RFID readers that are meant for experiments and fun applications. For example, you could mount one on a robot, and as the robot moves about the room it could figure out its location by reading RFID tags you have left for it to find. You could use one on the door of your room—give your friends an RFID card and then you can tell if that knock on your door is a friend or a bothersome sibling. Or in this science project, use the RFID reader as part of a music synthesizer.
The way RFID systems usually operate is that the reader stays still while the tags come and go. The reader requires a power source of some kind and a connection to the computer. The tags are simply inexpensive plastic cards or fobs. One reader can usually handle a large number of tags. If the reader is going to stay put and a number of tags will come and go, it makes sense that the instrument you make should mimic something where you wave a number of objects around. That sounds a lot like handbells.
Figure 1. You will use an RFID reader and paper cups to make a synthesized set of handbells.
You have probably seen handbells at some time in your life. Perhaps your religious group uses them in a service. Or you have heard them played during the holidays at a shopping mall. Your school might have a set that they use to help teach rhythm.
Figure 2. A handbell choir practicing. The bells range in size from a few inches to well over a foot in diameter, and some can weigh 8 pounds. (Image Credit: Wikimedia Commons user Jeff Muceus)
Handbells have a sound all their own. Music synthesizers often take advantage of such unique sounds and store digitized copies of the sound that you can then play with the touch of a button. While you might not recognize it by that name, you have encountered a music synthesizer if you have ever played an electronic keyboard that looks like a piano, but can sound like an organ, a trumpet, guitar, or any other instrument. You can do the same thing with the very computer you use to surf the Internet or to read Science Buddies project ideas. All you need are sound files of digitized handbells and a way to play each note in the order you want, and before you know it, you will be playing music.
RFID readers have come a long way from the big warehouse readers; now they are small devices about the size of a credit card. To work, the reader sends out a radio signal. The tag uses the energy in that signal to power up a little computer and transmitter of its own, and transmits back some coded data that it has stored. The reader picks up that information and then shuts off. The tag then loses power. Now that the reader knows what data is in the tag, it can do whatever the system designer intended. For example, if the tag is in your school ID, the data on the reader can sign you into school for the day. In this science project, each tag will represent a musical note. The computer will play the associated sound file, you will create a simple handbell design, and voila! Instant handbells!
Terms and Concepts
- Radio frequency identification (RFID)
- What are the different kinds of RFID readers and where might each of these be used?
- How do handbells make sound?
- How are handbells played? Are they ever played in ways other than picking them up?
- RFID Journal. (n.d.). Frequently Asked Questions. Retrieved April 10, 2014.
- Wikipedia contributors. (2014, February 19). Sampler (musical instrument). Wikipedia: The Free Encyclopedia. Retrieved April 10, 2014.
- Wikipedia contributors. (2014, March 26). Scientific pitch notation. Wikipedia: The Free Encyclopedia. Retrieved April 12, 2014.
This article is about an early electronic instrument that used a piano keyboard to play back prerecorded sounds from other instruments:
- Wikipedia contributors. (2014, March 23). Mellotron. Wikipedia: The Free Encyclopedia. Retrieved April 10, 2014.
Here are a couple of online videos of people playing handbells:
Materials and Equipment
- Parallax USB RFID reader kit; available at jameco.com
- USB cable (mini USB); available at jameco.com
- Parallax RFID tags (we recommend at least 10); available at jameco.com
- Paper cups (1 for each RFID tag)
- Plastic knife (1 for each RFID tag)
- Craft knife
- Tape (masking, duct, or almost any kind)
- Hot glue gun
- Hot glue sticks
- Permanent marker
- Computer with at least one USB port, as well as Windows® XP or better, Macintosh® OS X® 10.6 or better, or a fairly recent Linux® version
- Software drivers to read the USB port as serial (free download from manufacturer's site); available on ftdichip.com
- For Apple® (OS X) computers, the SerialTools software app is one option; available at Mac App store on itunes.apple.com.
- For Windows computers:
- Hyperterminal software, which may already be installed on the computer
- PuTTY; available at chiark.greenend.org
- Or some other serial terminal emulator
- For Linux computers, a serial terminal emulator, such as minicom software; available at pkgs.org
- Python 3.x (may be preinstalled on your computer or you may need to install it)
- pySerial module for communicating with connected devices
- pygame module for making sounds on the computer in Python
- Sound files for each note of your synthesized bells (see "Digitized sounds," below)
- Optional: Python programming reference book
- Optional: Music book for handbells; such as the one available at grothmusic.com. A simple book for one octave is a good place to start.
- Optional: Music for beginner piano or handbell players; downloads can be found on the Internet, or books are available on the Internet or at music stores
Python code files to download (on many browsers, right-click on the link and 'Save As'):
Digitized sounds, courtesy of AnOctaveOfCows.org. These files contain .wav files and are in zipped format for easier download.
- Bell_sounds.zip (start with this one)
- Burps.zip (alternative sound files, optional)
- Cats.zip (alternative sound files, optional)
- Cows.zip (alternative sound files, optional)
Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at firstname.lastname@example.org.
Note: Installing the software on your computer might be a little tricky. You will do it in steps, but ask an adult or a tech-smart friend for help if you have a problem.
Setting up the Drivers and Testing the Reader
Notes: Depending on who owns the computer you are using, get permission from your parents or your school before you download and install any software. The exact procedure for installing software on your particular computer may vary depending on how that computer is set up. If you need to, ask an adult for help installing the drivers and application software.
- The RFID reader in the materials list will be connected to your computer via USB. That is very common, of course, but an RFID reader is not like a keyboard or a mouse; the computer will not know what to do with the data. To fix that, you need a device driver, which allows the computer to know how to access data from the reader.
- In the RFID kit, you will find instructions for going to the Parallax website for documentation, and to the FTDI website for drivers. The RFID reader uses chips from FTDI, so it is necessary to have the drivers from their website that are specific to your computer. Drivers are available on their website for Windows XP, Vista, Windows 7 and Windows 8, and for Mac® OS X 10.6 or later. Linux systems may not need drivers, as many Linux installations already support the FTDI chipset.
- The goal is to make the RFID reader look like a standard serial communications port. Follow the instructions provided with the kit and on the Internet to get the drivers installed. Ask an adult if you need assistance.
Serial Terminal Emulator
Here is a little background about the terms serial and terminal. It is somewhat "old school" to keep referring to "serial" and "terminals" on modern computers, but the terms go back decades (to the 1960s and 1970s) when a computer did not have a display or a keyboard. Instead, computers used a different type of port, called a serial port, which was common before USB was invented. The computer may have been in a special air-conditioned room nearby, while the user had a terminal on his or her desk that had the display and the keyboard. So we still use that terminology today when we talk about how a computer communicates with other devices, even though there is no separate terminal on most people's computers, and many computers no longer have the old standard serial port.
In this science project, you will need to look at the data coming from the RFID reader. Because of the driver you installed in the previous section, your computer will think the data is coming in on a serial port. To see the data, you need to install a program that works like an old-style terminal to display the raw data. These terminal emulators are easily found for just about any computer you will be using.
- On Windows, your computer may already have Hyperterminal installed.
- Newer Windows systems may not have Hyperterminal installed, but you can download a free program called PuTTY (the name evokes even older technology) that will do the job perfectly and is actually preferred for this project.
- Under Mac OS X, look in the app store for a program called SerialTools.
- Linux machines can use a serial terminal emulator such as minicom.
Connecting the RFID reader
Figure 3. The Parallax RFID reader connects to your computer via USB. Shown here are the required USB cable, the reader kit with the included tags, and a bag of 10 additional tags that you will need for this science project (you can use as many as you like).
- With the device driver and terminal emulator installed, plug the RFID reader into the computer using the mini USB cable. Depending on your computer, it may take a moment or two for the computer to recognize the device. It will appear in your computer as a serial port.
- On Windows, it is a device that is usually named something like 'COM4', 'COM5', or some other number. Figures 4 and 5 show some sample screens from Hyperterminal and PuTTY (preferred) that you might run on a Windows computer. If using PuTTY, select the options, as shown in Figure 5, using whatever COM port is correct for your particular installation.
- On a Mac or Linux machine, it could be named almost anything, depending on the specifics. That's okay though, as the serial terminal software can find it. Figures 6 and 7 show a successful setup using SerialTools, a program available for Mac OS X machines.
- Be sure to check the 'RTS' and 'DTR' boxes to activate the RFID reader, and click on 'Connect.'
- Once connected, SerialTools will display any data coming in from the RFID reader.
The program Hyperterminal opens a window to attempt to connect to an RFID reader plugged into the computer.
Figure 4. Hyperterminal is one program you may already have on a Windows computer. The RFID reader will appear as one of the higher-numbered COM ports.
The program PuTTY is opened to a setting configuration window. In the session tab there is an option to attempt to connect to a peripheral device that is inserted into the computer with a serial connector. Other options for connection types, speed, and sessions are also available in the window.
Figure 5. PuTTY is a very popular terminal emulator that runs on just about any version of Windows. It is a better choice than Hyperterminal if you have permission to install software on your computer. Select the options, as shown, using whatever COM port is correct for your particular installation.
The program SerialTools for OS X has a drop down menu that displays devices connected to the computer. Options can be changed for baud rate, bits, parity, stop bits, RTS, DTR, CTS, DSR, cr/lf, raw and local echo.
Figure 6. SerialTools for OS X will show you a list of serial ports it found on your computer. In this example, it thinks it found some Bluetooth serial ports as well, but we connected through USB, so select the one with USB in the name. Be sure to check the 'RTS' and 'DTR' boxes to activate the RFID reader, and click on 'Connect.'
When an RFID reader is connected to the SerialTools program, data from the reader will be sent to a small window in the bottom of the program. There is an option to disconnect on the right side of the program window.
Figure 7. Once connected, SerialTools will display any data coming in from the RFID reader.
- Start the terminal emulator software. In the software's menus, you will find a place to select the device. You probably do not have many serial devices connected, so it should be easy to locate the correct port. The RFID reader uses 2400 baud, 8 bits, no stop bits (you can look this up if you want to know what that means). Select these options in your communications software.
- To check if you got it right, take one of the tags that came with your RFID reader and wave it within a few centimeters of the reader. You should see a 10-digit number appear on the screen.
- If you do, that is awesome! You got the configuration right and are ready to proceed.
- If not, you may need to restart the computer to get the driver activated, or you may have selected the wrong serial port in the terminal software. Is the LED on the reader lit? If not, check that you have a working cable and that you plugged the cable into a working USB port.
Note: The tags in this kit each contain a unique 10-digit identifier. The program you will write takes advantage of that to tell which "bell" you are ringing.
Finding or Installing Python 3.x on Your Computer
- The rest of this procedure uses Python 3.x as the programming language to read the data from the tags and starts the corresponding sound. Depending on your computer, Python might be started from a command window, or it might be a clickable icon, possibly labeled "Idle" or "Idle3." Look for some indication of Python being preinstalled.
- If you find it, start it up and see what version you have. We recommend version 3 if you plan to use our sample code.
- If you do not have version 3, you can look at the python.org website to download the correct version for your computer.
- Download and install Python 3.x according to the directions. Again, if you need help, ask an adult or tech-smart friend.
- You have Python 3? Great! The bad news is that Python does not know how to talk to connected devices like your RFID reader. To fix that, you need to install a module called 'pySerial' that you can get from pypi.python.org. Note: Installing it can be tricky sometimes. We suggest that you do an internet search for "pyserial install python 3 windows", "pyserial install python 3 OS X" (for the Mac), or "pyserial install python 3 linux" to get started.
- To make sure you have pySerial installed correctly, start up Python and load the program 'showtags.py' that you downloaded from the Materials list. Edit the program to show the name of the serial port that you determined when you ran the test with the serial emulator in steps 2 and 3, above. You should see something on your screen similar to Figure 8.
Sample code in Phython is color coded and written to connect to an attached RFID reader. Output from the reader is taken by the program and displayed on the computer.
Figure 8.The sample Python program 'showtags.py' will simply display the tag data as it comes from the reader.
- Programs that acquire data have the problem of dealing with devices that can send information any time they like. If you write a program that asks a user to type something in, the program will ask, and then wait for a response. We cannot do that with the RFID reader; it will send whatever it knows as soon as it knows it. To handle that better, this program takes advantage of a concept called threading, where one program starts acting as if it is two or more programs working together. Python does threading really well, so this program takes advantage of it. You might find it helpful to open the 'showtags.py' file in Python or a text editor/word processor as you read this description of how it works.
- The first four lines simply tell Python that you are using some extra features. In this case, serial (pySerial, to be precise), threading, time (so you can accurately time things), and sys (for system functions).
- The next two lines tell the program which serial port you want to talk to (use the name you found earlier), and what 'baud' rate the data comes in. That term refers to bits transferred per second and the RFID reader uses 2400.
- Next, you tell Python to establish a connection to the serial port. You give it the name and speed, and it stores a handle. This handle is how the program will talk to the open port.
- You then define two helper functions.
- The first one, handle_data(), will be called when a tag has been completely read in. You saw the format of the messages when you ran your serial terminal test earlier. This function does not do much now; it simply displays the data on screen. You will use it later to play sounds.
- The second helper does the heavy lifting. read_from_port() will loop forever trying to read data from the RFID reader. The data coming from the port will be 12 characters per tag: 10 digits of a unique number followed by 2 characters to indicate the end of the data. This function collects it all up and when it is complete, it calls handle_data() to turn that into something useful.
- With the helpers defined and the port open, the next step is to start the read_from_port() running in its own thread. That frees you up to do other things like play sounds. You need to set up a thread, start it running, then print out a message. Finally, you cannot just end, so you loop forever doing nothing, assigning the value 0 to a variable. You could do something else here if your program had something to do. If some parts of this program do not make sense to you, you can find explanations of the Python and the pySerial functions on the Internet or in a Python reference book.
- Do you have pySerial and your RFID tag reader working? Time to make some noise! Python has a module just for games, called 'pygame'. It offers the ability to play sounds, play large sound files, read from joysticks, display graphics, and other things that you might want if you are planning to write games in Python. Too bad it does not read RFID tags! You need to install 'pygame' that you can get from pygame.org. Note: The web page offers some installation instructions that might or might not be helpful. We suggest that you do a search for "pygame install python 3 windows", "pygame install python 3 OS X" (for the Mac), or "pygame install python 3 linux" to get started. It is a bit easier to figure out than pySerial.
- Copy 'playsounds.py' that you downloaded from the Materials list into a directory on your hard drive. You also want the file 'Bell_sounds.zip' which is a selection of notes played on handbells. Put the sound files into the same directory as 'playsounds.py'.
- Start up Python and load 'playsounds.py'. Run the program and you should hear two tunes played on handbells.
- Step by step, this is how playsounds.py demonstrates two ways of using pygame to play sounds. First, as shown in Figure 9, you have to initialize the sound system. Import the necessary modules (you always have to do that) and then call pygame functions to set up its sound mixer. You can see a complete listing of pygame functions on the pygame site (link shown earlier).
Sample code in Phython that will initiate a sound mixer in pygame. The commands are pygame.init() and pygame.mixer.init().
Figure 9. To play sounds using pygame, you must initialize pygame's sound mixer.
Example code in Python that loads sound files so they can be played with functions.
Figure 10. This is one method you might use to play sounds. We do not suggest this one, but you will find it on the Internet and it is easy to do.
- To play a sound file of any length, you can simply use the pygame "load()" and "play()" functions. The drawback is that the program has to pause and read the file, which will slow things down a bit, and you can only play one file at a time. With real handbells, you often hear the whole group playing at once. Another problem with this method is that it takes up a lot of program space to decide which file to play. When you write your program that reads the tags, you might end up with something like:
If tag=1 then play("C")
If tag=2 then play("D")
That is okay if you have a few tags, a few notes, and only one kind of sound. Imagine you had dozens of tags for dozens of notes and several different kinds of sounds. This might not be the most efficient way of writing your program. The little code snippet in Figure 10 is okay, but...
- There is another method that creates a list of items that has the sound file name (preloading into the pygame mixer), a space for an RFID tag that you will associate it with later, and a friendlier name. On handbells, the piano, or many other instruments, the octaves are numbered; the lowest is 0 and the highest is 9. This is called scientific pitch notation (see the Bibliography for a link to more information) and is commonly used in reference to handbells. Whether or not the pitches represented in the files are exactly these octaves does not matter. The idea is that using "C4" to represent a C that is one octave lower than "C5" is simply easier. The list of items contains these "friendlier" names. You can then take each of these lists (one per note) and make a list of them. It takes up a lot less space than all of the other 'if-then' tests above. It makes a rather primitive database of notes and their relationships to RFID tags and note names.
Example code in Python that loads sounds and gives each sound an associated note. The sound functions are renamed based on the note and can now be played more easily.
Figure 11. Another way to play sounds in Python.
- After the list of lists is a helper program that will search this database, find the sound by name, and then play it. Once the helper program is defined, you can use it to play a little song.
Writing Your Program
- Now you have a way to read the RFID tags and a way to play sounds. You are almost there. Now you need to write a program that watches for tags and, when it sees one, decides what note to play and plays it. There is no handy example code here, but we are sure you will have fun figuring that out! Consider, too, that some people may not be fond of handbell music. They might like cats meowing out a tune instead, or maybe cows. Can your program play the same notes, but switch from bell sounds to another sound? Consider putting a picture of a bell on one, a picture of a cow on another, and use those tags to switch sounds.
Making It Look like an Instrument
Sure, your program is quite cool and you have sufficiently annoyed everyone in your house with "Mary Had A Little Lamb" as mooed by a meadow full of cows. But waving little tags in front of the reader does not feel a lot like a musical instrument. Continuing with the handbell theme, you can use paper cups and plastic knives to make paper handbells, as shown in Figure 12. Put the tags inside and they will look more like the real thing.
Figure 12. Simply hiding the tags in "handbells" made of paper cups and plastic knives will make people take notice when your little paper bells sound like the real thing.
- Use your craft knife and make a small slit in the bottom of a cup. Keep it as centered as possible.
- Insert the plastic knife into the slit. To get it in the right place, place the cup, mouth side down, on a table. Press the knife down until it just touches the table. You do not want it to stick past the lip of the cup.
- Use hot glue on the outside of the cup to hold the knife in place. Be sure to protect your work surface in the area where you are using the hot glue; it can get a little messy. Do not to touch the glue while it cools. They call it hot glue for a reason! Have an adult around in case you need help.
Figure 13. With the plastic knife stuck through the slit in the bottom of the cup, put a glob of hot glue on both sides of the knife to hold the cup in place.
- Once the glue on the outside is cool, turn the cup over and do the same on the inside. You need a good bit of glue to make sure the cup does not wiggle when you play the handbells. See Figure 14.
Figure 14. Put some hot glue on each side of the knife inside the cup. It is hard to do this neatly; just do the best you can.
- Use a small bit of tape to tape one of your tags to the tip of the knife. You want it to be right at the tip, as shown in Figure 15. If you know you are not going to reuse these tags for anything and want to hot glue them instead, that is okay too. We do not suggest it, though, as you will probably find all sorts of uses for this RFID reader and the tags.
Figure 15. Tape an RFID tag to the knife blade, as close to the tip as possible.
- Use the showtags.py program and read the tag you just taped to the knife. Write down the tag number. Decide which note this handbell will be and write it on the cup using the permanent marker. Is it C4? D4? Pick one for each handbell.
Figure 16. A whole set of paper handbells.
- Once you have made 10 or more handbells and assigned the tag in each to a note, you are ready for a concert! You will need some music, though. Here are several ideas of how to obtain music:
- The music teacher at your school may have some you can borrow.
- The grothmusic.com website listed in the Materials list is a good start.
- You can find music on the Internet.
- Use the sample sound files included in the Materials list; however, they do not have sharps and flats. More files may be available on the AnOctaveOfCows.org website in the future. You can also make your own sound files.
- Are you a singer? Sing each of the notes and record yourself. Save the results as .WAV files and then "play yourself" as handbells.
- Maybe you have dogs that howl, or maybe you know how to make musical water glasses. Record your best sounds and play those with your bells. Note: The AnOctaveOfCows.org website is collecting sounds to share with others doing science projects like this, and they may be able to use yours. Have your parents send them an email.
Keep the fun going! Find local opportunities related to this project.Register on ActivityHero
If you like this project, you might enjoy exploring these related careers:
- As shown in Figure 17, try putting your tags inside something else, like an animal shape that corresponds with an animal sound, or make up your own instrument. Consider making a video of your performance, posting it online, and sharing the link with us at email@example.com.
Figure 17. No one said that these have to look like handbells. If they sound like cats, they can look like cats! Simply tape the tag to the back of a wooden or cardboard cutout.
- There are quite a few different ways to play a handbell. Change your design to include the sounds of some of these.
- The RFID reader is quite small and runs off of USB power. If you have a small laptop and your parents or the school (depending on whose computer it is) gives you permission, what would happen if you laid the tags out on the floor and put the laptop on a small cart? As you pulled the cart past the tags, would it make a sound depending on the position? A musical train perhaps?
Ask an ExpertThe Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.
Ask an Expert
Looking for more science fun?
Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.Find an Activity
Explore Our Science Videos
Make a Hygrometer to Measure Humidity - STEM activity
How to Make an Electromagnet
Fire Snake Experiment