Smart Guitar Using Capacative Touch With Build-in Tuner.
by Thomas Brink in Circuits > Raspberry Pi
22 Views, 0 Favorites, 0 Comments
Smart Guitar Using Capacative Touch With Build-in Tuner.

Have you ever experimented with chord fingerings on your guitar and wondered, ‘What chord am I playing?’ Or wished for a built-in tuner to keep your sound spot on? The SmartGuitar is designed to enhance your playing experience by identifying chords in real time and providing a seamless way to save progressions. With an intuitive dashboard displaying detailed chord information, this innovative project helps guitarists play with confidence and precision.
The SmartGuitar is a project I made for Project One at Howest MCT. It is built to register finger placement on the fretboard, calculate the played chord, store it in a database and show it in a useful dashboard application. It has a built-in tuner and supports multiple users to track individual statistics.
In this instructible I will explain the project step by step.
Warning: If you can't handle cutting holes in a guitar than this might not be the project for you.
Github repo: link
Supplies
Sensors:
MPR121 capacitive touch breakout board: To register finger placement on the fretboard. At least 2 boards needed.
RFID-RC522 RFID reader: To create a user system that allows multiple users to track their playing individually
--------------------------------------------- Piezo / Electreet
Actuator
Neopixel LED matrix board: Showing chord diagrams to teach new chords.
0.96 inch I2C OLED Screen: Showing tuner data and webserver address
Other
Guitar:
Raspberry Pi 4/5: I'm using a Pi 5. A Pi 4 is perfectly fine as well
Micro-USB/USB-C data Cable: Depending on the model of your ESP32
resistors 4K7-10K ohm: 3pcs
Soldering tin
Nails
Copper tape
Tools
soldering iron
Creating the Circuit



To rebuild the SmartGuitar, just follow this schematic I made using Fritzing. You might need to solder some pin headers on some of the sensors. In case you don't know how to solder these, here's a tutorial.
The MPR121 capacitive touch breakout board uses I2C and has a configurable address pin. It has 4 possible address configurations: GND, VCC, SCL and SDA. However, when configuring the sensor to VCC , SCL or SDA, it's important to note you have to scratch out the address connectors on the bottom of the board.
I used 2 MPR121 sensors in this project but I made the ESP32 code expandable so you can add up to 4. All you have to do is change the variable SENSOR_AMOUNT before uploading 'main.cpp' to the esp32 (step 6). One MPR121 has 12 electrodes (these are the conducting parts you touch to get a reading). This means using 2 of these boards gives us 4 frets to work with.
Preparing the Raspberry Pi
To set up the Raspberry Pi you'll need to download a few things:
Software: Win32 Disk Imager
Start Image: Image
Once you have downloaded these, put your SD card into your computer using an SD card reader, open up win32 disk imager, select the image you downloaded and press 'write'.
Once it's done uploading, eject the SD card (if win32 disk imager hasn't done this for you) and insert it into the Raspberry Pi.
Connect the Pi to your computer using a network cable and open an ssh connection to 192.168.168.169 with password P@ssw0rd
On boot the Pi will ask you to configure a new password. Follow the steps and reboot.
To connect the Raspberry Pi to visual studio code using ssh follow this guide: Setup shh in vscode
Wi-Fi connection
In the terminal run following commands
Cloning Repository
Now is the time to clone all the files you need to make the project work.
Run this line in the command-line. Make sure you have git installed.
Database Design

All of the sensor readings and other data are stored in a mySQL database. You can find the dump file in the github repo under 'data'.
Virtual Environment
To make sure the project runs smoothly, it is good practice to use a virtual environment.
To create a virtual environment, run following lines in the command line.
Uploading the Code to the Esp32
In the github repo there is a folder called esp32 under backend. This folder contains a platformIO folder structure that allows to upload code to the esp32 directly from vscode. Here is a tutorial to get started with platformIO.
If you'd rather use the arduino IDE, you could copy the main.cpp file from the src folder and upload it using the IDE. Don't forget to install the necessary dependencies.
If you're using more than 2 MPR121 touch sensors, make sure to update the SENSOR_AMOUNT variable before uploading the code.
You can now test the sensors using the serial monitor.
Backend
To run the backend you need to connect to the database first. In the backend directory there is a file named 'config_example.py'. To be able to connect to the database you need to duplicate the file, call it 'config.py' and add your username and password. Don't worry config.py is included in .gitignore so it won't be committed to github. This way your username and password are perfectly safe.
Once you've done that you should be able to run 'app.py' without any problems.
Serial connection with ESP32
If 'main.cpp' is uploaded to the esp32 you can plug the USB cable into the Raspberry Pi. Make sure your serial monitor is turned off. When running app.py you should get a serial connection. If it gives the warning 'No such file or directory found', try plugging it into a different USB port.
Running on startup
If you want the project to run automatically when you plug in your Pi, paste the following lines in the terminal.
Frontend
Having a good backend is fun but it is not as good without a fitting user interface. This application has a dashboard website with real-time sensor data.
To run a webserver on your Pi you need to execute the following steps.
Use the arrow key down until you reach
'DocumentRoot /var/www/html'
Replace this line with
'DocumentRoot /home/student/project/<repo_name>/front'
Save: press Ctrl + X then Y and then Enter
Use the arrow key down until you reach
'<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>'
Replace this with
'<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>'
Save: press Ctrl + X then Y and then Enter
If your backend and circuit are implemented correctly, you should see an IP address on the display. If you browse this IP address you should see the website (as long as you're on the same network as the Pi)
Housing






All this time I've been telling you how to build a SmartGuitar but up until now we just had a guitar and some loose unconnected electronics. It's time to change that.
Step 1: Cutting a hole
The SmartGuitar has a lot of electronics it needs to fit inside. The Raspberry Pi, ESP32 and everything that comes with them need to have a safe place to fit inside. I decided to cut a hole in the top and put a box in it.
Steps
- Draw the dimensions of the box on the guitar.
- It's important to think about the inside of the guitar when drawing dimensions. You can't go as wide as the guitar because there are reinforcements inside the guitar you want to keep.
- Drill a small hole at the corner of the drawing big enough to fit a rocking saw.
- Saw a hole following the lines of the drawing.
Step 2: Creating a box
Steps
- Saw thin planks of wood in the size of the dimensions of your hole and the depth you want.
- Glue the side and bottom planks together with wood glue and fortify with nails.
- Affix the top plank with screws and hinges so you can still easily access your electronics.
Step 3: Capacitive Touch Sensors
To register touch data on the fretboard, there has to be an electrode connected to a the MPR121 capacitive touch sensor. I've chosen for electrical tape
Steps
- Cut off the strings
- Drill holes where you want the electrodes to go through the fretboard (you can use wires to connect, but I've chosen for thin long nails). There should be one for every string on every fret you're using.
- Put the electrodes through the holes (hitting the nails in in my case)
- Put small strokes of copper tape over the electrodes. There should be a bit of a gap between every piece of tape.
- On the other end of the guitar neck, connect wires to the electrodes. I've soldered them to the nails.
- Isolate the sensors and streamline the wires using electrical tape and connect the other side of the wires to the sensors.
- Now just add the electronics inside the case and you're done
Conclusion
Although I didn't get this project where I wanted it to be, it was still a lot of fun to work on. I hope you enjoyed reading this post and potentially recreating it. If you do attempt this yourself, I would love to see the results and I'm open to any questions you might have.