Decibelmeter With Co2-meter | Deco Meter
by Tim Ramon in Circuits > Raspberry Pi
107 Views, 0 Favorites, 0 Comments
Decibelmeter With Co2-meter | Deco Meter
I am a student at Howest studying MCT. In our second semester we have an end project called Project One. I decided to make a Decibel meter combined with a CO2 meter, which can be used at smaller or bigger parties. I named this the Deco meter
Supplies
- 1x Rasperry Pi 4 model B
- 1x Raspberry PI T-cobbler with cable
- 1x SparkFun Sound Detector
- 1x M5STACK CO2L Unit - SCD41
- 1x Rotary encoder
- 1x LCD 16X2
- 1x PCF8574
- 1x MCP3008
- 1x Potentiometer
- 1x Push button, used in combination with resistor
- 1x LED's (Red), used in combination with resistor
- 5x resistors (I use Ω470 resistors but those can be higher or lower)
- 1x Breadboard supply 5V and 3.3V
- 1x Breadboard
- 1x cables
Downloads
The Encasing
For the encasing, I 3D printed a box with a lid that can be taken off. I designed these in Tinkercad, which is a handy online 3D designer.
You can download the files in the attachments down below.
Setting Up the Hardware
While you are 3D printing or if it has finished, you can start setting up the hardware of the raspberry pi.
I draw this scheme using Fritzing, which is a very useful program to create electrical circuits.
Use the pdf to make sure you connect all the wires right.
After you connected everything correctly, you can put everything in the encasing you printed. You could also 3D print the encasing later if you don't have a 3D printer in your house.
Make sure you also put the power cables out the holes and the buttons, leds and rotary encoder as in the picture above. Use a little glue/tape if it doesn't stay in place.
Downloads
Configuring the RPI
Once you have all the hardware set up, you can start configuring the Rasperry PI
- Import the github link to your RPI: https://github.com/howest-mct/2022-2023-projectone-RamonTim
- Make sure you have SSH,VNC,SPI and I2C enabled in your raspi config
- If you haven't, do the commando 'sudo raspi-config' in your terminal
- Go to '3 Interface options'
- Now you can enable each individually
- Now you got to make a Virtual environment (venv) with the commando `py -m venv venv`
- Make sure you link your terminal to your venv now by doing 'CTRL + SHIFT +P' in VSC
- Type 'Python: Select Interpreter'
- Select venv
- Terminate your terminal and start a new one to enable the venv
- Make sure you install the basic requirements by doing the command: `pip install -r ./requirements.txt`
- Also install the external library for the SCD41 component: `pip install adafruit-circuitpython-busdevice`
- Open MySQLWorkbench and make a new connection
- Under Connection Method, select Standard TCP/IP over SSH
- SSH Hostname: `<your own rpi ip>`
- SSH Username: `<your own rpi user>`
- SSH Password: `<your own rpi password>`
- Save this if possible.MySQL
- Hostname: `127.0.0.1`
- MySQL Server Port: `3306
- `Username: `<your own rpi user>`
- Password: `<your own rpi password>`
- import the SQL-file in this connection from the database map
- Make a copy of the config example in the back end map, and name it config.py
- Change the user and password to your own raspberry pi
Programming the Components
Lucky for you, all the coding has been done by me. I will go over every component that I programmed
Sparkfun Sound Detector
It was a little of a struggle to find out how to convert the analog value from the envelope pin to an actual decibel value. I have used a formula to calculate it roughly around the right value, since it's not a top notch component but it does the job.
SCD-41
I tried writing my own python class for this component, but I couldn't figure it quite out, so I used a public library to read out the data from this SCD 41. This also uses I2C.
MCP-3004
I use this in combination with the Sound detector to send the analog value the RPI using SPI.
PCF 8574 with LCD
Using the PCF 8574 in combination with the LCD saves a lot of GPIO pins that can be used for other components by making use of I2C too.
Rotary Encoder
I also wrote my own class for this component to read the values out. This is used to update the limits of your graphs
Usage
Connect to the home page by typing in the IP address of your PI via ethernet cable or wifi. You can now use the interface of the website that I also have created. You can start a measure session by pressing the start button on the screen and stop it with the stop button. You will see live data on the graphs once you start a session. In the historiek page, you can review older session data with it's average values.