For most of my life I have kept reptiles and fish, and I have also enjoyed computers and tech projects. With this project I was finally able to combine my passions. I initially set out to write my own software that would run on a single board computer like a Raspberry Pi or a BeagleBone. I started prototyping the design, laying out the features I wanted and how I wanted to implement them, all the things you do when starting a new project. This specific project was intended to control the environment for my Veiled Chameleon (Chamaeleo calyptratus). They have fairly specific needs; a temperature gradient, a humidity window of 70-90%, a day/night cycle, and the biggest thing is they need to be misted multiple times a day because they do not drink from standing water. So with that the project had the needs outlined. I needed to be able to:
And the stretch goal –
So with those goals in mind I went to the internet to find any open source projects I could potentially utilize to make some of those goals easier, and found my project done for me already in the form of TerrariumPi – https://github.com/theyosh/TerrariumPI
TerrariumPI is an opensource GPLv3 licensed habitat control system that checked all my boxes and more, even the weather one. It’s actively maintained and at 3 years old has a nice mature stability about it. The author has added support for many different types of sensors and also IOT switches and outlets to make your setup relatively easy. For my setup everything is ran through the Pi using basic relays and sensors.
Below I’ll describe the process of building the control electronics and setting up the server so you can access your animals habitat from anywhere. We’ll start with the electronics, you will need a Raspberry pi (Zero, 2, 3, or 3B+) and your MicroSD card. TerriariumPI is made to work with the Raspbian Stretch Lite distro so make sure you get the right ISO at: https://www.raspberrypi.org/downloads/raspbian/
Once the image is flashed, eject the MicroSD and then plug it back into your PC so that it mounts and we can setup SSH and Wifi if you plan to use wifi with your habitat.
Open the BOOT partition of the MicroSD. This will be the only partition readable if you are on windows.
To enable SSH create a new empty file in the root directory called “ssh” with no extension. This will let the Pi know to enable SSH on first Boot.
To enable wifi create a file called wpa_supplicant.conf and add the following code inside it:
Change “your_wifi_ssid” and “your_password” to the real values for your network and save the file. You can eject the MicroSD from your PC and plug it into the Pi and power it up now.
Once powered up we need to find the IP address our router assigned to the Pi. You can log into your router and find the “raspberrypi” entry or I like to use an app called “Fing” on my phone that will show all the connected devices on a wifi network and their IP Address.
Once we have the IP we can SSH into the pi to do our installation of TerrariumPi using for favorite SSH client like Putty for windows or the terminal for Ubuntu or OSX:
Remember the default password for the Pi is “raspberry” and you need to change that immediately. Once you’re logged into the pi change the password with:
pi@raspberrypi:~ $ passwd
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
Pick a good non-dictionary password as this will be connected to your network.
From there I like to immediately update my install with:
sudo apt-get update
sudo apt-get upgrade
Next we’ll start the TerrariumPi install by installing “git”
sudo apt -y install git
Then use git to clone down the latest TerrariumPi Directory
git clone --recursive --depth 1 https://github.com/theyosh/TerrariumPI.git
Enter the new TerrariumPI folder
Run the installer script and wait (first install takes about 45 minutes and has a couple prompts)
Reboot Raspberry PI to get all the needed modules loaded
Now to build the physical hardware. You will need an enclosure to hold all of your electronics and protect them and you. For the enclosure it can really be anything that will safely house the electronics. I used a great website called boxes.py, specifically the electronics box, to create laser-cuttable box with finger joints to put my electronics in. These are the settings I used for my box because I wanted a lot of room for future expansion.
Once you get your settings the way you want click generate and it will open a new tab with the SVG. There are other export options like DXF but I had issues opening those files, so I stuck with SVG. Next Bring it into your laser software of choice. I use LightBurn for my lasers.
Once I brought this in, I also brought in another SVG I drew in Inkscape to add mounting holes for my Din rail and other components and added that in.. I also repositioned the large rectangle at the top out of the cut area and to an uncut layer as I wanted to cut that from PET-G sheet later so you could see into the box, and I repositioned a couple of the parts for more efficient material usage.
In the above drawing it is set so only the black vectors will be cut, the red and magenta are turned off for the current operation.
After cutting glue up the box and clamp the box
From here I screwed down the DIN rail and snapped in the Pi and Relay Board boards, and screwed down the 12v power supply and start wiring.
First let’s wire the solder the sensor cables to an extension to the box.
The DS18b20 temperature sensors can all be soldered together as they transmit on a 1wire protocol. They they need an i/o pin, 5v and ground. So go ahead and match all the colors up ( Red to red, Yellow to yellow , etc) *image*
The AM2303 needs its own i/o pin and it also needs to be on 3.3v rather than 5v. The Ground can run on the same wire as the DS18b20.
Solder these to your multi-conductor cable, taking note of what colors are what if you weren’t able to match colors all the way through.
Next we can move to actually wiring the box up. Here is a basic diagram of how my box is wired.
In my setup I am using a water solenoid hooked to my main plumbing in my house and using the municipal water pressure to run my misters. If you wanted to use a water pump for this purpose you need to look for a diaphragm type pump with a pressure cut off around 70PSI that pumps around 0.5-0.7 GPM. These are the type of pumps that are used in commercial misting systems. The high point of these is they have a limited water supply to draw from, but can be noisy and are expensive.
Next we will define the your access and unit preferences in TerrariumPI.
Now let’s add the Temperature and humidity sensors to get your terrarium, fish tank or whatever automated!!.
Next is the switches. These will flip your relays on and off based on timers, sensors, weather data, and simply clicking on an icon to trigger it. They can control almost anything and you can even add multiple switches to the same I/O port to have it triggered at different times for different periods of time for example.
The last thing we’ll add is a webcam. I used a Logitech USB webcam, but TerrariumPi also supports PiCams, and remote cameras. To get the USB camera working, you’ll need to do the following.
--- Opening /dev/video0...
Trying source module v4l2...
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
Corrupt JPEG data: 2 extraneous bytes before marker 0xd4
Captured frame in 0.00 seconds.
--- Processing captured image...
Writing JPEG image to 'image.jpg'.
At this point you should have the basics of TerrariumPi functional and your enclosure is automated!! The possibilities with the software are just starting now though. If you go to System -> Environment you can set your lights and mister to come on based on the weather in the part of the world you are trying to recreate, you can set up music to play when your lights come on, you can even get a text message when your webcam sees your lizard move!!
Created by Joe Spanier