Snackofoon
I am an MCT student from Howest in Kotrijk, Belgium.
My project is a Snackofoon using a Raspberry Pi 4 Model B. Its purpose is when you are working or gaming, to eat a snack without to make your keyboard and mouse sticky.
The Snackofoon can be used by everyone who doens't want their electronics sticky.
Eat good, work good. Just keep your electronics clean with Snackofoon.
What are the features?
- Measuring the temperature
- live data on the dashboard
- live data on the forehead
- charts and history
- tracking distance of screen
Experience to work with it.
Github Repository: https://github.com/howest-mct/2021-2022-projectone-VandenbrouckeRobin
Supplies
Raspberry Pi 4 Model B
The Raspberry Pi is a computer that runs Linux, but it also provides a set of GPIO pins, allowing you to control electronic components for physical computing.
Temperature sensor (LM35)
It is used to measure the room temperature.
Ultrasonic sensor (HC)
I use this to keep track of how far you're from your screen. To have healthy eyes.
LCD Display 16x2
With the LCD you can see the IP address, temperature, distance and the angle size.
Two servo motors
The first servo is used to let the M&M fall between the 2 motors. The second is used for the M&M to roll into your mouth.
Light-dependent resistor (LDR)
This is used to measure how much light there is around you.
Two Buttons
This used to let the motors turn, and to shutdown the raspberry pi.
Breadboard and wires
To connect everything I needed a breadboard, I used the GPIO T-Cobbler clearly know which component goes where.
Schematic
I created my schematics in Fritzing.
my colors used in scheme are:
- Red = 5V
- Orange = 3.3V
- Black = GND
You can find my files below.
Important!!
Look at all the components very carefully, as some operate at 5 volts. Do not confuse between 5 and 3.3 volts and do not connect directly 5 volts to your GPIO pins.
Database
I store all the data from the sensors and actuators in a relational database of SQL.
I'm going to explain a little more about my 5 tables that I using.
Device
You can see the name, id, price and unit of measure, type....
Historiek
Here is all the history data of all sensors with value and time. You will also find actuators and website actions. Some example:
- measure temperature
- starting lcd
- measure light strength
- measure distance between you and the screen
- measure angle size motors
Actie
There are all the actions are stored of all the things that can happen such as sensors, actuators and web.
Hoeveelheid
You can see how much you eat on a daily base.
Configure Raspberry Pi
Before we can run the code we are going to prepare the raspberry pi.
Downloading Raspberry Pi OS.
Go to Raspberry Pi OS and download image (Raspberry Pi OS with desktop).
Writing image to your SD Card.
When it is finished downloading, you can write the image to your sd card with (recommend 8 or 16GB) Win32 Disk Imager.
Configuring the SD Card. When writing is done, we can start setting up the SD Card.
- Open file explorer.
- Go to my pc --> find boot disk
- Create a new file ssh without extension Notepad++.
- Add 'ip=169.254.10.1' to the end of the file and save it.
Starting the Raspberry Pi.
- Connect an internet cable from your PC to your Pi
- Open Putty.
- Choose port 22 and enter the ip address of your Pi 169.254.10.21 and connection type SSH.
- Enter login pi and the password raspberry.
- If you get a warning message, click Yes.
Some configuration.
Enable I2C and SPI on the Raspberry Pi with:
- --- sudo raspi-config ---
- Choose Interface Options and enable SPI. Navigate to "Localisation Options" change timezone and WLAN Country.
- Then reboot the Pi.
- sudo reboot
Adding WiFi.
Adding your own home wifi.
- --- sudo wpa_passphrase 'Networkname' 'Password' >> /etc/wpa_supplicant wpa_supplicant.conf ---
Reload your wireless network card in the PI.
- --- wpa_cli -i wlan0 reconfigure ---
You can now check the connection by requesting the ip-address.
- --- ifconfig ---
Installing some packages.
Stay up to date with the latest version.
- --- sudo apt update ---
- --- sudo apt upgrade ---
Install the following packages and libraries for python:
- --- sudo pip install flask-cors ---
- --- sudo pip install flask-socketio ---
- --- sudo pip install simple-websocket ---
- --- sudo pip install mysql-connector-python ---
- --- sudo pip install gevent ---
- --- sudo pip install gevent-websocket ---
- --- sudo pip install selenium ---
- --- sudo apt install chromium-chromedriver ---
- --- sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel ---
- --- sudo python3 -m pip install --force-reinstall adafruit-blinka ---
- --- sudo apt install python3-dev python3-pip ---
- --- sudo pip3 install mfrc522 ---
Now reboot the Pi.
- --- sudo reboot ---
Get github code.
Clone the github repository. git clone https://github.com/howest-mct/2021-2022-projecton...
Database
Install MariaDB and configuration.
- --- sudo apt install mariadb-server mariadb-client -y ---
Securing the database.
- --- sudo mysql_secure_installation ---
Enter > Type a password (remember) > y > y > y > y Create a user on the database.
- --- sudo mysql -u root -p
- --- create user 'USERNAME'@'localhost' identified by 'USERNAME'; ---
- --- grant all privileges on *.* to USERNAME@localhost; ---
- --- flush privileges; ---
- --- exit; ---
Make a new connection on MySQLWorkBench
Open MySQL WorkBench and make a new connection.
- Connection Method --> Standard TCP/IP over SSH.
- SSH Hostname: 169.254.10.1
- SSH Username: pi
- SSH Password: raspberry
- MySQL Hostname: 127.0.0.1
- MySQL Server Port: 3306
- Username: USERNAME
- Password: PASSWORD
Apache
Install Apache and configuration.
- --- sudo apt install apache2 ---
Some plugins:
- --- sudo a2enmod proxy_http ---
- --- sudo a2enmod rewrite ---
- --- sudo a2enmod ssl ---
Follow this link to configure Self Signed Certificate for https: Tutorial Change some configurations.
- --- nano /etc/apache2/sites-available/000-default.conf ---
Replace the following lines with the following lines and change DocumentRoot to the path of your project (SAVE: CTRL + X > Y > Enter):
Go to GitHub copy apache file
Now restart the Apache.
- --- sudo systemctl restart apache2 ---
Check the status of Apache.
- --- sudo systemctl status apache2 ---
Building the Snackofoon
- First:
- You make an rectangle:
- 200 x 30 mm
- Stick the lcd trough the hole
- You install the lcd with super glue
- You make an rectangle:
-
You cut a hole:
-
Ø 30 mm
-
cut the tube 70 mm
-
Glue the tube in the hole with super glue
-
Take the corner and glue it on the other side of the tube.
-
Cut another piece of the tube:
-
Ø 30 mm cut the tube 100 mm
-
Glue the tube in the corner with the super glue
-
Take another corner and glue it on the other side of the tube.
-
Cut another piece of the tube:
-
Ø 30 mm cut the tube 220 mm cut 2 line with a Ø 15 mm
-
Glue the tube in the corner with the super glue
-
Take another corner and glue it on the other side of the tube.
-
Cut another piece of the tube: Ø 30 mm cut the tube 100 mm
-
Glue the tube in the corner with the super glue Take the last corner and glue it to the tube.
-
First you make 2 metal flipper:
-
Ø 15 mm see picture
-
make a hole Ø 5 mm in the flippers
-
screw the flippers to the servomotor
- Take a black box
- Measure where the components wil pop out / the output of the battery and internet cable
- Cut out the place where the components will come
- Cut out a hole Ø 5 mm for the battery
- Cut out a hole on the other side Ø 6 mm for the intenet cable
- At least cut out a hole on the side Ø 8mm where the cables on the headset wil come togheter.