Project ElectroTerra

Introduction: Project ElectroTerra

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.


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

Step 1: Raspberry Pi Setup

First you need to set up the basics for the Raspberry Pi:

I used a ssh connection to control the Pi with a laptop:

For coding I used Visual Studio Code with a ssh extension:

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

Step 2: Creating the Electronic Circuit

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.

Step 3: Arduino + Programming

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:

Step 4: Testing the Sensors and Actuators on the Pi

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

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

Step 5: Database

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.

Step 6: Frontend

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.

Step 7: Backend

The, and code must be in the home directory of the Pi user. To make the Pi run the file automatically at reboot use these instructions:

You can find the code in the github repository:

Step 8: Putting Things Together

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.

Step 9: Testing

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.

First Time Author Contest

Participated in the
First Time Author Contest

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge
    • Big and Small Contest

      Big and Small Contest