Project ElectroTerra

by Hann_wow in Circuits > Raspberry Pi

360 Views, 1 Favorites, 0 Comments

Project ElectroTerra

20200614_134555.jpg

I made a "smart" terrarium/vivarium as a school project.

ElectroTerra is run by a Raspberry Pi which hosts a website and stores data gathered from the sensors in a MariaDB database.

The website shows temperature and relative humidity from the sensors and allows control of the fan and LED strip. That strip can also work automatically bij a LDR sensor.

I assume some practical knowledge of using Raspberry Pi, Arduino, MariaDB (Mysql) and on wiring breadboards.

Supplies

I made a list of materials so that you can find everything needed for this project.

Raspberry Pi Setup

First you need to set up the basics for the Raspberry Pi: https://www.raspberrypi.org/downloads/

I used a ssh connection to control the Pi with a laptop: https://www.raspberrypi.org/documentation/remote-access/ssh/

For coding I used Visual Studio Code with a ssh extension: https://code.visualstudio.com/docs/remote/ssh

To make the website available within your private network you can check this instructable from step 1 - 3: https://www.instructables.com/id/Host-your-website-on-Raspberry-pi/ There is no extra security build in this project so beware of exposing it on the internet.

Creating the Electronic Circuit

electroterra_breadboard_sheme.png

In the fritzing scheme you can see every needed component in this project. The 1-wire temperature sensor can be replaced by the build in temperature sensor of the DHT22.

The Arduino is powered by the Pi via the USB cable.

Arduino + Programming

dht22.jpg
RGB-LED-Strip-Driver-Module-Full-Color-RGB-Strip-Controller-Board-Can-be-Cascaded-for-Arduino.jpg

Since the functions in the Arduino libraries for the DHT22 and the LED strip driver are very elaborated, I decided to add an Arduino for these parts.

Therefore you need the Arduino IDE.

Make sure to import these libraries:

Testing the Sensors and Actuators on the Pi

In the Github repository are some test files for the individual components.

These are the classes: mcp.py (coverting the analog data from the LDR) pcf.py (communicating I2C data) and pcf_lcd.py (interfacing with the LCD).

Database

2020-06-13 16_07_24-MySQL Workbench.png
2020-06-15 10_56_01-Forward Engineer to Database.png

Create the electroterra database on the Mysql worckbench via the dump file (final_dump_electroterra.sql in the Github repository) with some test data.

There is a compatibility issue by using the "Forward Engineer to Database" wizzard in Mysql Workbench. Make sure to remove the VISIBLE parameter in the sql statements since this is not working in MariaDB.

Frontend

2020-06-13 14_59_25-.png

The HTML, CSS and Javascript code can be found in the Github repository. They should be put in the directory where the website will be hosted. The design is optimised for mobile use and was tested on the latest stable Chrome, Firefox and Edge versions.

Backend

The app.py, datarepository.py and Database.py code must be in the home directory of the Pi user. To make the Pi run the file automatically at reboot use these instructions: https://www.raspberrypi.org/documentation/linux/usage/systemd.md

You can find the code in the github repository: https://github.com/DeblaereHannes/ElectroTerra

Putting Things Together

20200614_095749.jpg
20200614_133713.jpg

This setup is a proof of concept.

The fan is fixed in place with hot glue. Some extra holes were drilled in the ventilation strip for wiring.

Next up was a box to keep the electronic parts. A simple plastic box was used. Consider adding a ventilation strip in case of overheating.

Testing

ElectroTerra test demo (terrarium/vivarium)
20200615_153507.jpg
20200615_153511.jpg

Power up the Raspberry Pi and the power supplies.

Browse to the IP address shown on the LCD display.

By this, you can monitor the data and control the actuators.