Terrarium Controller: 💡idea ➡️ v1.4

Grigorii Merkushev
9 min readApr 3, 2022

--

breadbaord ➡️ PCB v1.4

🧐 Problem

For the last 2 years, we got 4 different corn snakes. All of them are different, different colors, characters, and sizes, but all of them like the same things. They like to be warm during the day, cool during the night, and be fed every other week. For the feeding process, there is not much to automate, but for temperature control, I found some ugly solutions. The most common solution is to have a wall plug with a timer.

off the shelf timer switch

It is simple, but this solution doesn’t take into account room temperature changes, which is critical in our apartment as in winter temperature range can be more than 5 degrees Celsius. It is obvious that if we want to keep our pets in good temperature conditions, we need to measure temperature and turn on or off the heater based on that. This article is all about me over-engineering a solution to keep snakes in the right temperature ranges.

I like to engineer solutions even if I can find something on the market. 😅

🔥 Terrarium heating design

Usually, inside the terrarium should be 2 zones with different temperatures. One zone is around 30C during the day and another around 23C. This difference is needed for reptiles to be able to digest food in a warm corner and be able to cool down in the cold one. Keeping minimal temperature is required as reptiles are cold-blooded and cant generate heat for normal operation. Overheating would cause damage and could lead to animal death.

🛠 First workaround

The first workaround that I built was a Bluetooth thermometer that was checking temperature, sending it to Home Assistant, and a smart WiFi plug that was turning on and off to keep the given temperature. This solution was working but if sensors start to fail or something happens to the WiFi plug, a snake could get overheated or get cold. It happened once and the snake got cold for a few hours so I decided to move forward and work on a standalone solution for the terrarium.

⌨️ PoC based on perf-board and third party board

This is my second take on this problem and I wanted to build something more stable and ideally autonomous. I had experience with esp32 (usually used in IoT micro-controller) and thought that it should be a good fit for simple temperature sensors & relays circuit. Firstly I built a prototype with a breadboard and wrote simple firmware that grabs time from NTP (stands for Network Time Protocol) and controls the temperature in given ranges: 29–30C during the day in the hot corner, 23 at night, in the cold corner was passively heated due to convection.

The breadboard has shown that it works fine, so I ordered some components and started to assemble this prototype.

This prototype consists of 2 main parts, a relay array from a third party and a perf-board with esp32, and 4 JST 3 pin connectors for sensors. I really wanted to separate the power circuit from the electronics, so designed it in a stackable way where the electronics box can be detached from the relay enclosure.

For the case, I went for a 3D printed custom solution and secured components in place with hot glue.

https://cdn-images-1.medium.com/max/1600/1*Er_JFYRchMj0j0xrTvh2Pw.jpeg

This prototype was built when we had only 1 snake, so I didn’t have any need to scale it.

🌡 Sensors DHT22

For temperature and humidity measurements I evaluated 3 solutions DHT11, DHT22, and BME280. I wanted to try BME280 as this is the most precise but it turned out that there is a chips crisis and it is nearly impossible to have hands-on BME280 sensors. The next sensor by accuracy was DHT22 and after several tests, I decided that it would be a good fit for my project. I ordered sensors on a small PCB board with the necessary resistors and 3 pin interface.

After a bit of 3D modeling, I got this nice 3d model for this sensors board.

process of finding the best form for sensor enclosure

When everything was printed and assembled, all 4 sensors went to the terrarium and I started to do the wiring of this project.

⌨️ PoC based on perf-board and daughter boards v0.2

At this point, we bought 2 more snakes, so I had to create 2 more automatic terrariums. This is my third attempt to create a controller and I didn’t know how to design PCB yet. I chose a perf-board and some DuPont (black connectors on the picture) connectors so it would be easy to get esp32 out for flashing. Everything got wired with solid core wires as multi-core wires are a pain to solder.

After several evenings I finished all 3 controllers and was happy, but not for a long time. The main issue started to appear from an RTC module as it started to respond with corrupted time. Real-time is required for the controller to decide is it day or night and adjust the temperature window. The issue was in software, but I didn’t catch it at that point and started to design a custom PCB to eliminate hardware issues with wiring.

📺 Display

In order to be able to see if the controller works as expected, I integrated an LCD with an i2c interface, a simple and reliable (kind of) protocol often used in IoT projects. For the enclosure, I designed and 3D printed a case to be able to mount a screen on the front side of the terrarium.

Key metrics that are shown on the screen are temperature and humidity at each zone, heating phase per zone, current time, and network status. Network is required to obtain initial time from NTP and flash it into RTC, and to be able to send telemetry data.

https://cdn-images-1.medium.com/max/1600/1*imwHNF447R_Vf1U-wn7xbw.png

In the rest of the article, I am going to tell you about my journey through custom PCB design.

1️⃣ Custom PCB v1.0

This is my first custom PCB. I was scared when I just started, but it turned out that it is relatively easy to design a simple PCB like this. I spent one evening on this and was ready to order a PCB. For manufacturing, I chose JLCPCB as I saw them often on Youtube and wanted to give it a try. The cost of manufacturing surprised me as it costs just $5 to produce this high-quality PCB.

In this design, I simply replaced all wires with copper traces and created a ground copper plane. This PCB was working great and I still have it in 3 of 4 terrariums.

PS. Planning to upgrade all 4 terrariums with PCB v1.4 soon.

Features and changes

  • custom-designed PCB
  • 2 layers (GND backplane)
  • i2c screen
  • 4 DHT22 sensors
  • 2 relays
  • esp32 debvoard socket

2️⃣ Custom PCB v1.1

After I finished with the first custom PCB I got so excited so started to design the next version with more things cleaned off. First I wanted to make it prettier so I rounded corners and added a nice logo. Then added ws2812b LED for status notifications, rotated JST connectors for sensors, added 2 more, and in the end, migrated relay modules on the mainboard. Developing this board was a joy and manufacturing was quick.

Features and changes

  • relay daughter boards are now transferred to the mainboard
  • added 2 more DHT22/sensor connectors, rotate connectors to fit more
  • moved to right footprints for JST connectors
  • added ws2812b led to show the status of the controller
  • round corners of PCB just for aesthetics

Failures

  • I messed up with a component footprint for the transistor and had to bend transistor legs to fit in this design.

3️⃣ Custom PCB v1.2

Well, v1.1 got some bugs as I didn’t verify all component’s footprints. The Transistor footprint was completely wrong so I had to bend its legs to solder and test it. So once I soldered v1.1 and realized that there are issues, I immediately started to work on this revision with a fix. Also as I removed some legacy components from this revision, managed to fit 1 more relay on the same board size and added 220v input for relays, so there is no need for a power strip for all heaters.

Features and changes

  • added 3rd relay for lamp
  • added 220v input and pass-through to relays
  • fixed footprint for s8050 transistors
  • rotate JST connectors from left to right

4️⃣ Custom PCB v1.3

After 3 PCB designs and tons of Youtube videos and tutorials watched and read, I decided to go wild and create a fully custom PCB with esp32 WROOM integrated right into it. Also, I got a bit tired of THT components so switched to SMD.

This is the first free from daughter boards revision. Also tested 4 different colors of solder mask.

Features and changes

  • moved to SMD components (for most of them)
  • transfer RTC daughterboard on the mainboard
  • transfer esp32 devboard to the mainboard (external programmer still needed)
  • added new mount holes with VIAs

Failures

  • First of all, I had to add EN and IO0 pins for flashing via the programmer.

5️⃣ Custom PCB v1.4

Finally, we get to the latest board that I designed. This is revision v1.4 and eights revision in order from the beginning of this project. All major bugs got squashed, overall stability is fine and this board will be a replacement for old v1.0 in all terrariums soon.

Features and changes

  • all SMD components
  • sensors enabling transistor, to be able to reboot sensor if they stuck
  • angled detachable power connectors
  • metallic logo on the front side
  • updated silkscreen with less noise
  • RTC battery change level circuit

Conclusions

This journey was a great use of time and I had a lot of fun. I highly encourage everyone who makes their own project to try PCB design as it is way easier than it looks.

👏🏻 I would like to thank JLCPCB for the great quality of PCB and quick & reliable manufacturing.

PS. For now, I am working on version 1.7 which features an onboard programmer, USB-C for power and data, SSRs (solid-state relays) for silent operation, i2c & 1wire sensor connectors for better flexibility, and much more.

--

--