The story has begun with two greek tortoises. They were christmas gifts to my son. Cute reptiles, they just need some special circumstances like controlled temperature, humidity and UVB light for their healthy shell growth. I have red a few books about the tortoise habitats and tried to look for a "smart" terrarium controller for them, but I couldn't find any.
OK. Then build one!
Step 1: Project Summary
The base is a Wemos D1 ESP8266 arduino compatible board. Why not Arduino? Because ESP8266 has wifi capabilities and I needed internet connection for OTA (Over The Air) updates and NTP (Network Time Protocol) updates for the built in RTC (Real Time Clock) module. The tortoises need controlled temperature between 33°C and 38°C, and controlled humidity around 50-60%. That's why the terrarium has four temperature sensors (three DHT22 temperature/humidity sensors and the DS3231 RTC module's own integrated temperature sensor).
These sensors are in the cave, on the runway and in the furnace (where the heaters are) and the last one is integrated in RTC module in the control-room which is measuring the temperature near to the electronics. In the furnace there are three lightbulbs, two pieces (a 25W and a 50W bulbs) for the heating, and a special UVB one. The terrarium has a thermostat part, it can control these bulbs through the 4 channel relay module (I use only three relays, but there was no 3 channel module:))
The heating works based on the cave sensor data, the thermostat is checking every 10 minutes and compares the sensor data to the predefined optimal temperature and turns the bulbs on or off as the temperature requires. It's not working night and day of course, the controller counts the sunrise and sunset time every day (based on the date and geographic coordinates) and the heating is working only on daytime. The UVB control is using sunrise/sunset also and it's working 9 hours a day.
On the front face of the cave there is a built in 2*16 character LCD display which shows the most important parameters, and informations about the terrarium, for instance:
- Terrarium start parameters
- Connect to wifi (SSID)
- IP address
In the night the LCD backlight is turned off, and just a 5mm blue LED shows the working status of the terrarium.
Step 2: Internet of Things Tortoises
Web, cloud, mobile
The terrarium is connected to Twitter (https://twitter.com/smartterrarium), tweets important changes and errors, and connected to Thingspeak (https://thingspeak.com/channels/126060) where you check the current temperature and humidity parameters of the system (the cave, the runway, the furnace and the control room) and there is a chart about the heating power output. Last but not least the Smart Terrarium has a web server, from the local network you can check the main parameters with an internet browser.
I have installed the IoT ThingSpeak Monitor Widget app (https://play.google.com/store/apps/details?id=ua.livi.thingspeakmonitor) to my mobile, and I can check my smart terrarium parameters anytime and everywhere.
Step 3: List Materials and Tools
The terrarium (glass):
- Plate glass with the edges sanded
- 100% silicone transparent sealant (or aquarium glue)
- Masking strip or duct tape
- Caulking gun
- and a few large box or some heavy books for holding up the glass
- XPS foam
- Utility knife
- Mini heat hot air gun
- Kitchen torch
- Foam knife
- Caulking gun (again :))
- Silicone sealant (white or whatever)
- Aluminum grid
- Gelato boxes
- Wemos D1 ESP8266 board
- 2*16 LCD display
- Blue LED
- 270 ohm resistor
- I2C interface
- DHT22 temperature and humidity sensor
- DS3231 RTC module
- Standard proto screw shield board for arduino compatible double-side PCB
- Soldering iron
Step 4: Create the Glass Terrarium and the Base of Cave
The glass part
Unfortunately I haven’t got images about the glass terrarium building process, but there are good articles and videos about it on the youtube. I just bought the sanded edge glass sheets and put together with special aquarium glue.
The XPS cave
The cave was more interesting part of the terrarium. I have measured the place in the terrarium and I had cut the proper size parts for the cave from the XPS foam board. I have formed the base of the cave in this step. You don't need to be so precise (aside from the external dimensions!), because you actually create an irregular shape piece of rock.
Step 5: Formatting the Cave
The surface of the cave must be irregular. You can form it with a kitchen torch, a utility knife and a hot air gun. Be creative! You can create a realistic rock form easily. I have glued some cut off part to the cave wall to formatting hollows and emersions. Top of the cave I have built in two gelatos box. One for the electronics and a second one for the plant.
After I have finished the formatting of the rock, I mixed outdoor tile adhesive and painted the full surface of the cave - except the glass-fitting parts. After it dried it looked like a real rock.
Step 6: Build the Electronics
Low current system
After I received every ordered parts I started to build the controller. I used an Arduino Standard Proto Screw Shield Board, as a shield connector, the sensors connected with CAT5 ethernet cable and soldered it into the proto board. In this way I can disconnect the ESP8266 board easily if I had any problem and I would need to change the controller board.
- (Pin 01)----> RELAY1_UVB
- (Pin 02)----> RELAY3_25W
- (Pin 03)----> LED
- (Pin 04)----> SDA
- (Pin 05)----> SCL
- (Pin 12)----> DHT22 Runway
- (Pin 13)----> DHT22 Cave
- (Pin 14)----> DHT22 Furnace
- (Pin 16)----> RELAY2_50W
One pin, two pin
I2C is a serial protocol for two-wire (SDA/SCL) interface to connect devices like ESP8266. That’s why I used that for the LCD and the RTC module (each I2C slave device has a 7-bit address that needs to be unique on the bus) and in this way i could connect more I2C compatible devices to I2C port of the microcontroller.
Step 7: Hiding the Cables, Finishing the Terrarium
High current system
Separating the high and the low current circuits is important. I used a 2 way boat rocker switch, first switch is to high current (heater bulbs, UVB bulb) the second one is to low current (ESP8266, relays, sensors, etc.). I wanted to hide all of the cables inside the rock, it was simple electrician task, I have used foam and utility knife to formatting the XPS board and to create channels for the conduits. All of conduits are soldered, I didn’t want to use releasable connections inside the cave because when I finish the project I want to bond the parts together permanently.
Be careful with the electrical isolation, mains voltage electricity is dangerous! There is a significant risk of death through electrocution if mains voltage electricity is allowed to pass through your body!
Step 8: The Software
Install the ESP8266 Package
Go to Tools > Board > Board manager and add ESP8266 package. Then, restart your IDE.
Select the Board
Go to Tools > Board and select Adafruit HUZZAH ESP8266. CPU Speed Select 80 MHz as the CPU frequency by going to Tools > CPU Frequency. Upload Speed For Upload Speed, select 115200 baud. Selecting the Port Select the matching COM port for your FTDI or USB-Serial cable.
Go to GitHub to download the code:
Fill in the SSID and the password for your WIFI, but do not upload it to the board yet.
You can download and Install Arduino IDE from here:
Connect ESP8266 board to serial USB connector of your PC. Open Arduino IDE Change Tools-> Board -> “WeMos D1 R2 & mini” If you don’t see this board in the list, Install the ESP8266 Package:
Go to GitHub to download the code: https://github.com/vakaati/smartterrarium
Change in the SSID and the password for your WIFI (Line 18 & 19)!
Set password for OTA upload in line 353 (default: PASSWORD)
First time You need to upload the sketch via USB, but this code supports OTA and you can upload the changes through your wifi connection.
Please vote me in the contest - top right - Thanks! :)
Third Prize in the
IoT Builders Contest