Raspberry Pi Smart Bottle
by HyperHydroX in Circuits > Raspberry Pi
752 Views, 0 Favorites, 0 Comments
Raspberry Pi Smart Bottle
Hi I'm a student at the Howest Who is studying Multimedia & Creative technologies, I have made my own project that I like to call the HydroBottle. I'ts like a smart bottle but with some hickups in it. I chose this as my project because I like to drink a healthy dose of water everyday but never actually know how much exactly that I drink, so that why that's why I chose to make a smartbottle as my first year endproject.
The HydroBottle is a raspberry Pi powered bottle designend to track your waterconsumption of the day. It also wil track how many times you've opened the bottle, show you how cold the water is and also has a feature that, if you ever lose your bottle that you can find it back by pressing a button.
Here are all the items that you need to make this project:
Downloads
Supplies
Main computing unit:
- Raspberry Pi
This is the main computer that everything runs on.
Electronics & sensors:
- USB charger
Main powersupply for the Raspberry Pi. - MCP9809 temperature sensor
Sensor that will measure the temperature of the water. - Reed switch sensor
Sensor that will detect how manny times you've opened the bottle. - HC-SR04 ultrasonic sensor (Recommended)
Sensor that wil measure the depth of the bottle I recommend that you use this sensor because of the minimum reading this sensor has. I used another one but that ended not great :/ - jumper cables
For wiring everything togehter. - Neopixel ring 24 LEDS
To see how long it's ago when you drank water & for the alarm to see where the bottle is. - buzzer or piezo buzzer
For the alarm so you can hear where the bottle is. - Oled display
To show some some live stats on the bottle self.
Casing:
- lego bricks
- or something else that you prefer
Tools:
- Soldering iron and solder
- waterproof cable connectors
- glue
- tape
- ...
Prototyping
Before we make everything permanent, we will put together the project on a breadboard. This step can be skipped if you are absolutely certain you won't make mistakes. The electrical/breadboard scheme can be found in the PDF below. You can be flexible with wich pins you use in this project. Before you power up the raspberry Pi double check your circuit. Make sure there are no shorts! Otherwise is there a chance that your raspberry pi will be fried, and we dont wan't that :)
Configure of the Raspberry Pi
The first thing that we need to do is setting up the Raspberry Pi. Its the same as opening a new windows computer and you hace to config everting.
The image that we're going to use has already everything on it that we need for this project to work.
- Apache webserver for hosting the frontend
- MariaDB for the database
- PhpMyAdmin to manipulate the database
- custom permissions to avoid problems
- some python libraries so that code can work without a problem
The custom image can be downloaden from Github
There is also a readme file where you can find everything you need to know about how to setup your Raspberry Pi correctly.
Database
To log & store all the data that we will get from our sensors, I have desigend my own database wichexists out of 6 tables EER diagram is shown above.
1) Table persons:
in table persons contains every person that uses the bottle. The data that is stored in Persons is: Name, Firstname, height, wieght and how much water you want to drink in a day.
2) Table Bottles:
Table bottles contains every bottle with data of: bottle cap count, volume of the bottle and which person it uses. If you like to make more than one smartbottle is that possible.
3)Table BottlecapCount:
this tabble only purpose is to store how many time you've opened the bottle in a day.
4)Table Waterconsumption:
Table waterconsumption stores the data for when and how much water you've drank.
5)Table Sensors:
Stores info over every sensor like which output value they have and name of the sensor.
6)Table History:
Stores everyting that the sensors output of data .
You can Make this database in the MySQL workbench app.
Backend
If you haven't downloaded/clone my repo from Github already then now is the time to do it because you will need it the setup the backend of the project.
installing python packages:
Normally you already have every plugin installed to run the app.py file.If you haven't here are all the commands you'll have to use to install them.
pip3 install flask-socketio
pip3 install flask-cors
pip3 install gevent
pip3 install gevent-websocket
IMPORTANT NOTE: if you have changed your Mariadb/Mysql password, change the password in config.py!
In the backend folder you will find the folder sensors. There you can find sperate classes and test files for every sensor. Feel free to change or test some things :3
Test the backend:
Run the app.py file using the python3 interpreter. Make sure there are no errors!
Running the app.py on boot:
If everything seems to run fine than you can config the file to automaticly start when you boot your Raspberry Pi.
Edit hydrobottle_backend.service and change YOURFILEPATH to the path where the repository is saved. Now copy this file to /etc/systemd/system/ linux code beneath:
sudo cp motoDash_backend.service /etc/systemd/system/motoDash_backend.service.
If everything is correctly done then should your backend automatically startup each time boot your Raspberry pi.
Frontend
Head into the GitHub Repo. Copy the contents of the Frontend directory.
This is all you should do to make the frontend work. This folder contains all webpages, styling and scripts for the web interface. It also communicates with the backend. To test if everything works like it should, make sure you are connected to your RPi, and type the IP address of the RPi in a browser. You should see the homepage of the web interface.
You're free to change the design if you don't like it. I'm not really a fan of it eather :/
Just make sure that if you change anything like class names or add something, check then if the class name is used in the javascript file. Ohterwise errors will strat to appear.
Soldering the Electronics
Okay now I'ts time to solder every sensor and the display so that you van connect them directly to the raspberry pi instead of the breadboard.
Some tips while soldering:
- use something to hold down the the cables while you are soldering them together
- Don't use to much or to little solder, try to practice on some cable that you don't need until you get the hang of it. or look up a tutorial.
- Don't use to much or to less solder.
When you are finished, double check for any shorts or bad connections, and check every connection with the electric scheme if it is the right connection. Once you are certain everything is done correctly
Housing
okay now comes the fun / creative part :)
For the housing I chose to use lego bricks because I love lego some much and you can to anything with it. But actually if you don't like lego's then go with something else that you know will work like 3d printing to go around the bottle ,etc...
just make sure that the electronics are good protected and hidden away.