CallanLux

by alecgheeraert in Circuits > Gadgets

160 Views, 0 Favorites, 0 Comments

CallanLux

IMG_8566.JPG
IMG_8570.JPG

In our first year at MCT at Howest Kortrijk we were given the assignment that we have to create a product.
For this assignment we had a few requirements that we had to keep in mind when choosing an idea to work out.
My idea came out to be a device that could connect between a jacuzzi and a solar system. I came up with the idea since we were building a jacuzzi and thinking if solar would be a logical option to consider.

So this idea became CallanLux, in which callan means 'flowing water' and lux is the derived unit of illuminance.

Key features

  • Measure the temperature of water
  • Measure the amount of particles
  • Measure the light level
  • Turn on/off the pump
  • Toggle a servo for automatically dispensing
  • Show values on an oled display

Supplies

Processing unit

  • Raspberry pi 4 2GB

Sensors

  • Waterproof DS18B20 temperature sensor
  • BH1750 Ambient light sensor
  • Analog TDS ( Total Dissolved Solids ) sensor

Actuators

  • 5V Relay
  • SG90 Servo motor
  • A water pump

Display

  • SSD1306 OLED I2C Display

Power

  • 5V PSU

Additional

  • SD card 16GB or more
  • Breadboard
  • 4-Way Bi-directional logic level converter
  • ADS1115 ADC
  • Jumper cables
  • 4K7 resistor
  • Power cables

Setting Up Pi

IMG_8583.JPG

The first thing we'll be doing is setting up our raspberry pi, since this is the brain for the whole project.
It will be taking care of handling our sensor data, the website to control the project and the database.

Image

For my Pi image I used the official Raspberry Pi Imager provided by raspberry pi itself.
I choose the lite version of Raspberry Pi OS, but any version should work.

To configure the OS I plugged my SD card into my Pi and connected it through a monitor. Another option is to set it up for SSH beforehand. Of which there should be plenty of tutorials online for.

The first thing I did was set up the Pi with my home network with a static IP. Which you best write down somewhere since we'll be using it later.

The using raspi-config we set up our configuration, you can follow and make your own adjustments to what you desire out of this project. What we will need it 1-wire, SSH and I2C turned on.
More info and guide can be found here raspi-config guide.

Before rebooting it is best to update your OS.

Software

To install the needed software you can use these commands.

sudo apt install apache2 -y
sudo apt install mariadb-server mariadb-client -y
mysql_secure_installation

Here you will be asked to set up mysql.
The first prompt you can hit enter, the set up a password at the second prompt.
For the remaining you can press 'Y'.

After which we shall create our mysql user.

mysql -u root -p
grant all on *.* to 'username'@'localhost'
identified by 'password'; grant grant option on *.* to 'username'@'password';
flush privileges
exit

Now the final software we will set up is our editor.
This will be on the computer you'll be working on.
You can use whatever code editor you are comfortable with.
Here you just use the IP that we wrote down at the beginning.

Python

Before we get started on working on the project, we need to install some add-ons using pip3.

pip3 install flask-cors
pip3 install flask-socketio
pip3 install mysql-connector-python
sudo reboot

Mysql

To set up mysql between your pi and computer, you'll need to make a new connection in mysql-workbench

  • Method: Standard TCP/IP over SSH
  • IP is the IP of your Pi
  • Hostname is the name of your Pi
  • Mysql hostname: 127.0.0.1
  • Mysql port: 3306
  • Username: mysql

Best to reboot after this to make sure everything is set up correct.

Creating Database

Capture.PNG

To keep track of all the sensor data and actuator data we'll be using a database. Here you can see the ERD that we'll be using. It is a very basic design but has everything we need.

Measurements

The table measurements will keep track of all our data, so it has a rw column to keep track if the data was being read from sensors or written by actuators, then a data column and a datetime to see when the data was created.
We also have an epoche column, which helps us keep track of sensor data so we can see with which other data is was written with and a column for previous data

Devices

This table keeps track of the info about our devices we use in the project, so we have the name of the device, some info about it. The type if it is a sensor or actuator and a unitID to keep track of what units we'll be using with that device.

Units

Here we save the information about the units we are using and the maximum and minimums reach of our sensors.

Prototyping

schematic.jpg

Next we can start prototying our schematic, there will be 2 pdf files available with the schematic I used in this project. If you will be modifying this schematic be aware of what you are doing since a small mistake can break or damage certain parts or components.

Frontend

Capture.PNG
Capture.PNG

Here we made 2 pages.

The first one is the page you will land on, here are all the sensor data shown and presented.
The each also have a small arrow which takes them to a log page of that type of data.

The second control page is where you can turn on the pump and servo motor.
Here is also the ability to set a desired temperature.

These pages have been made with HTML and CSS for the design, and JS for the functionality of it.

Case

IMG_8585.JPG
IMG_8587.JPG

To keep the electronics enclosed I made a case from an old bamboo box, in which I made holes for the aviator connectors, a generic wall plug, oled display and the power cable. Bamboo is a hard wood so it was not very easy to use for this project which is something to keep in mind for later projects.

I used the aviator connectors to use as a presentable transition between the sensors which are outside of the enclosure and the electronics inside.

On the front I cut a small rectangle to show my display through and show the data from the sensors and IP address.

To finish the enclosure I painted it in white to keep it minimal and work away any imperfections, which turned out very good.

Finished Project

IMG_8566.JPG
IMG_8569.JPG

This is the finished project