Introduction: Vivarium Automation With Freya
A vivarium is a simulated habitat for plants and/or animals in a tank. Freya is one of the most advanced systems that currently exist to create a complex climate with seasons, and day and night cycles, with controls for lighting, temperature and humidity. And it's free*. With Freya you can also gain insights in your tank by peaking in through a camera with motion detection, or by monitoring the graphs of all variables.
*Freya is free software, designed and maintained by me. I'd love getting support through whatever skill you could put into this, or some financial support for 1EUR or more on my Patreon. If you like this project, follow Freya on Facebook!
In this Instructable we'll walk through the steps of setting up Freya in a vivarium, with the assumption that you have a tank and the accompanying electro. For this project, I designed a custom 'hat' that sits on top of my tank, and contains the electro and wiring mess, with only Freya's touchscreen visible on the front, and a power connector on the back - I really recommend you consider something similar!
Freya (brain and nervous system)
- Raspberry Pi & Raspberry Pi Power supply (5.1V, 2.5A)
- SD card with Raspberry Pi OS (desktop version) installed
- Raspberry Pi official 7" Touch Display (and mounting bracket)
- Freya Sensor module (for sensing temperature, humidity and light intensity)
- Freya Powerswitch module (for switching the lighting, heating and misting)
- 2x USB 2.0 A-B cable (also known as printer cable)
- Optional: a USB webcam (to see inside your tank)
You'll also need:
- A computer
- A USB keyboard
My Vivarium Electro
Lighting: I use a LED-bar that simulates daylight (22W, 220V - household cord Ø 0,75mm²) - before that I used daylight fluorescent lights (2x 25W, 220V, E27 socket) - check with your local experts which kind of lights you need for your application (!).
Heating: I use a ceramic heater (100W, 220V, E27 socket - household cord Ø 0,75mm²) - a heat mat or infrared lights work great too.
Misting/irrigation: I use a coffeemaker pump (50W, 220V - household cord Ø 0,75mm²) - you can use any misting system with an always-on function. I use 4x6mm pneumatic tubes and couplings, and 6mm atomizing nozzles. I use a 5L jerrycan for water reservoir.
Step 1: Freya System Setup
In this step we'll install the Freya software, and walk through several recommended system settings. In this step, I assume that you've assembled your Raspberry Pi and touchscreen, and have a SD-card with Raspios installed inserted in the Raspberry Pi.
1) Getting started
Connect your USB keyboard to your Raspberry Pi. Boot the Raspberry Pi by plugging in the power connector. Wait until you see the desktop, then press CTRL+ALT+T to open a terminal window. Feel like a hacker yet?
note: for every 'sudo' command, a password will be asked. By default, for the user 'pi', it is 'raspberry'
2) Connect your Raspberry Pi to your WiFi
Run the Raspberry Pi Configuration tool by typing:
Navigate to "1 System Options" and press enter. Navigate to "S1 Wireless LAN" and press enter. Now follow the instructions.
3) Download and install Freya
Freya is Open Source software, you can freely download from GitLab, and install with these commands:
wget https://gitlab.com/SpuQ/freyavivariumcontrolsystem/-/archive/master/freyavivariumcontrolsystem-master.tar tar -xvf freyavivariumcontrolsystem-master.tar cd freyavivariumcontrolsystem-master sudo sh install.sh
4) Automatically display Freya's interface on startup
Freya has a browser-based interface, so when the system starts up, we want a browser to open into Freya. Open the autostart file for editing:
and add the line:
@chromium-browser http://localhost/ --kiosk --touch-events
Reboot your Raspberry Pi. Now Freya should run automatically!
Step 2: Designing and Making the 'hat'
I use SketchUp for 3D modeling just about everything. I modeled how I imagined my tank's hat, with 9mm MDF in mind (for snug fitting joints). I exploded the model and exported all surfaces to .svg files. With these files I went to my local makerspace to have them lasercut out of 9mm MDF. I assembled this puzzle with some standard wood glue, and spray-painted it matte black in several layers with acrylic paint.
I designed and 3D printed this Raspberry Pi Display Bracket to mount the display in the 'hat'.
Step 3: Electrical Wiring
Wiring the Powerswitch Module
It is of major importance that all the components that you connect to the Powerswitch Module work with the same voltage. The Powerswitch Module is designed to handle a maximum of 5A per channel, and 6A in total! (Watts = Amperes x Voltage - so if you use a net voltage of 220V AC, the maximum amount of power you can connect to the Powerswitch Module is 1320 Watts).
CH1: Power output to the lights (connect multiple lights in parallel to this output)
CH2: Power output to the pump for misting/irrigation
CH3: Power output for the heater
CH4: Power output for future use... don't use just yet...
Powercord-labeled connector: Power Input (from the net)
The Powerswitch Module connects to the Raspberry Pi with a USB 2.0 A-B cable. Before connecting the USB cable, make sure the DIP-switches (Address Selection, labeled 'ADDR') next to the USB-port on the Powerswitch Module are both in the up position (to select address 1).
Installing the Sensor Module
Position the Sensor Module in a strategic position in your tank. I've put mine a little above center in the middle of the right-side window inside of my tank, with double-sided tape. Connect the Sensor Module to the Raspberry Pi with USB 2.0 A-B cable. Before connecting the USB cable, check if your sensor has a DIP-switches next to the USB-port, and if so, make sure it's switches are both in the up position (to select address 1). If your Sensor Module has no DIP-switch, its address is 1 by default.
Optional (but awesome): Installing the camera
I have a HD USB camera placed in in the center of the tank facing down, so I have a top-view of what's going on. Connect the USB camera to the Raspberry Pi using USB.
Step 4: Configuring Freya
Now, everything is installed and ready to power up! The system starts in Freya's main view. Freya's interface is designed to be intuitive, so take a moment to tick around and discover the interface!
You'll encounter the climate configuration interface. Here you have 2 configurable seasons; summer and winter, with settings for temperature, humidity and lighting for day and night. Create suitable settings for the content of your tank.
Enjoy your automated vivarium!