DIY

Wine box with various sensors

Wine box with various sensors  Wine box with various sensors The purpose of this project is to install and configure various sensors, temperature, humidity and light intensity in the wine storage box. As a bonus, a servo is installed to open/close the lock.
Tools and materials:
-Raspberry Pi 4 Model B;
-Servo motor MG 996R; -Sensor DHT11; -Sensor DHT22; -Photoresistor GL5537; -LCD – display; -Electrolytic capacitor; -Potentiometer; -Tactile button; -Jumpers; -Resistor 10 kOhm; -Resistor 470 Ohm; -Wine box ; -Breadboard;
Step one: wine box
The master uses a standard wooden box to store bottles of wine. Several holes need to be made in the box for the display and sensors.
Wine box with various sensors Wine box with various sensors Step two: breadboard
First, the wizard assembles the circuit on the breadboard. The connections are as follows.
Breadboard and GPIOs
Both sides of the breadboard must be connected to the GPIO ground (Gnd) of each side.
One side will be 3.3V and the other 5V. An external power supply is recommended.
DHT11:
Signal – & gt; GPIO (4)
Vcc (+) – & gt; Development board (+) (5V side)
Gnd (-) – & gt; Development board (-) (5V side)
DHT22:
Signal – & gt; GPIO (26)
Vcc (+) – & gt; Development board (+) (5V side) + 10k resistor
Gnd (-) – & gt; Development board (-) (5V side)
LDR (photoresistor) and capacitor:
LDR (-) + Capacitor (+) – & gt; GPIO (27)
LDR (+) – Development board (+) (5V side)
Capacitor (-) – & gt; Development board (-) (3.3V side)
LCD and potentiometer:
Vss – & gt; Development board (-) (5V side)
Vcc – & gt; potentiometer (+)
V0 – & gt; potentiometer (signal)
RS – & gt; GPIO (21)
R/W – & gt; Breadboard (-) (5V side)
E – & gt; GPIO (20)
DB0 – & gt; GPIO (16)
DB1 – & gt; GPIO (12)
DB2 – & gt; GPIO (25)
DB3 – & gt; GPIO (24)
DB4 – & gt; GPIO (23)
DB5 – & gt; GPIO (26)
DB6 – & gt; GPIO (19)
DB7 – & gt; GPIO (13)
LED (+) – & gt; potentiometer (+)
LED (-) – & gt; potentiometer (-)
Potentiometer (+) – & gt; Development board (+) (5V side)
Potentiometer (-) – & gt; Breadboard (-) (5V side)
Button:
Button (+) – & gt; GPIO (18)
Button (-) – & gt; 470 ohm resistor – & gt; Development board (-) (3.3V side)
Servo:
Signal – & gt; GPIO (22)
Servo (+) – & gt; Breadboard (+) (5V side)
Servo (-) – & gt; Layout (-) (side 5 B)
The schematic sketch can be downloaded below.
project_dominic_fritzingschema_bb_july.pdf
Wine box with various sensors Step two: database setup/code
All code can be downloaded here.
Now you need to make some settings and install software.
MYSQL database.
For the database you need to create a new table and configure it as follows: < br> Check the boxes
INT – PK-NN-AI
FLOAT – NN
Next, you need to create a workspace where all the project files will be placed:
Create a file named config.py and connect it to the mysql database.
Create a directory with the name of the repository.
In the directory of repositories, create one by one a file named Database.py and DataRepository.py.
Database.py
You need to install packages using pip3 install mysql-connector-python.
You don't need to change anything in the file.
DataRepository.py < br> This file is used to store received data from sensors in a database.
SELECT statements are used to select specific data from sensor x.
INSERT statements are used to transfer data from sensor x to the database.
Code can be downloaded here.

app.py
Create a file with named app.py.
Install packages:
pip3 install flask-socketio
pip3 install flask-cors
pip3 install gevent
pip3 install vent-websocket
Packages can be downloaded below. < br> app.py
Wine box with various sensors Flask is used for access to sensor data.
app.pyDataRepository.py
< img class = "aligncenter" alt = "Wine box with various sensors" src = "https://usamodelkina.ru/uploads/posts/2021-06/1624607017_1-9.jpg"/> The Adafruit library is used to read the DHT11 and DHT22 sensors.
Wine box with various sensors  Wine box with various sensors To configure the photoresistor, the code contains the read_sensor_light function.
Using the sensor_light function, insert data into the database.
 Wine box with various sensors Wine box with various sensors Wine box with various sensors Packages
index.html
style.css
( normalize.css)
Index.html
Inside index.html there will also be links to
style.css for styling
script.js for javascript
Chart.js and chartJS library for charts
SocketIO library
 Wine box with various sensors Then we write:
Get data from the database (getTempera)
Fill in the data using the (showTemperature) function
Filling dynamic data into our index.html
 Wine box with various sensors Now the web server will display data from sensor.
Wine box with various sensors To display a diagram you need to do the following.
Make sure that index.html has pages for each chart, each chart has its own class.
Next, you need to get data from the database (getTemperatureData)
Create 2 empty lists (showTemperatureData) < br> Insert data into a drawing function to create a diagram
Wine box with various sensors Step three: servo and display control
The open_chest function contains the servo motor control code. When you press a button on the website, the servo motor temporarily unlocks the wine crate.
Wine box with various sensors Wine box with various sensors The wizard has installed the display in the project.
The code is in app.py
 Wine box with various sensors  Wine box with various sensors After checking the circuit on the breadboard, the wizard installs the electronics in the winn th box. Connects power, checks the operation of the servo.

Source:

usamodelkina.ru

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button