Waterhealth MCT Howest
As a student Multimedia & Creative technology in Howest Kortrijk, I had to make my own IoT project. This would combine all of the modules followed in the first year into one big project. at home we have a pool and i thought it might be a great idea to make a system to check up on all the different values our pool has such as ph and temperature. I also added an ldr to see how much sunlight we get daily.
I will be referring to this Github quite a bit in this instructable so make sure to check it out!
My Github: Github
Supplies
Main computing units:
DS18B20 TEMPERATURE SENSOR - WATERPROOF
PH Sensor Kit (E-201C-Blue)
GL5516 LDR Lichtgevoelige weerstand (Photoresistor)
128X64 OLED blue i2c display module
Raspberry Pi 4 model B 8GB RAM
Arduino Uno REV3 [A000066]
MCP3008 8-kanaals, 10-bits ADC met SPI-interface
Level shifter
waterproof foam
in the following excell file you have a bill of materials where i bought them and for what price
Fritzing
Before we can start on anything else, we NEED to get an idea of what we will make. In this case, we make a fritzing schema because they are easy to use and they give you a good overview of your project. later on if you are confused or something is not working right you can look back at it if you made any mishaps.
Normalized Database
To log and store sensor data I have designed my own database which contains 3 tables.
The EER diagram is shown in the image above.
1.Meting
This table stores the main sensor data such as temperature, Ph, and light
2.Device
This table stores the what device we send the data to.
3.Actie
This table stores any description if you want to add some
To get this database on your Raspberry Pi, forward engineer this EERD in MySQLWorkbench.
Writing the Code
Installing Python packages
Before we try to run anything, we need to install some packages for python first. Head into the terminal of your RPi and type the following commands:
- pip3 install mysql-connector-python
- pip3 install flask-socketio
- pip3 install flask-cors
Raspi-config
We will have to enable different interfaces and to do that we first have to typ following code:
sudo raspi-config
The things we need to enable are in the interfacing section. We need to enable following interfaces:
- Serial
- SPI
- i2c
- Serial Port
-1-Wire
We will have to enable different interfaces and to do that we first have to typ following code:
sudo raspi-config
The things we need to enable are in the interfacing section. We need to enable following interfaces:
- Serial
- SPI
- i2c
- Serial Port
-1-Wire
That was everything we needed to do with raspi-config
Writing the backend
I used Visual Studio Code for my whole backend, you just need to make sure your Visual Studio project is connected to your Raspberry Pi, this means your LAN cable has to be connected to your RPi and to make an SSH connection.
(info on how to create a remote connection can be found here
I used my own classes and these are also all included in my GitHub. In my backend file, I used different classes, so everything can be used separately and so that my main code isn't a mess with all the different threads. I used threading to run all the different classes at once. And at the bottom, you got all the routes so we can easily get data in our frontend.
check out my github for the full code
Writing the frontend
Now that the backend is done, we can start writing the full front-end.
Do your best to make it mobile first and then add media queries for the desktop version. You can design your dashboard in any way you want to, i'll just leave my code and design here, you can do whatever you like! In javascript be ready to work with a few GET's from your backend routes, tons of event listeners and some socketio structures to get the data from the sensors displayed on the website.