Terrarium seasonal climate controller
With arduino mega 2560
WARNING THIS SYSTEM PARTLY USES MAINSPOWER WHICH CAN HARM YOU AND YOUR ANIMALS IF NOT BUILD PROPPERLY! I AM NOT RESPONSIBLE FOR ANY WRONG IMPLEMENTATION OF THIS SYSTEM. YOU ARE FREE TO TO MAKE THIS AS YOU FREE TO NOT MAKE THIS, I DO NOT CONCENT WITH WRONG ELECTRONICAL PRACTISCES. IF YOU ARE NOT SURE IT IS SAFE TO USE DO NOT USE IT OR CONSULT AN EXPERT!
Hello fellow terrarium lover. This system is an all-in-one solution for your animals enclosure to simulate its specific natural habitat as best as possible. First, my building ethos. I'm a biologist who keeps and breeds chameleons. They are my passion and because of my background in biology I have a ton of advanced knowledge about animals (metabolism, habitat, ecology, physiology etc.) which will only expand in the future. So i began a search for something better for my animals and how to propperly mimic my animals natural habitat. Since allmost all reptile based product a highly influenced by financial benefit, most products are just bad. They also tend to be seperated into singular parts and for an avarage reptile keeper its quite the journey to get all the elements to make up 1 propper enclosure. When done and setup in general it tends to still be not what you've been looking for. For example, since forever simple on/off timers are tused for lighting in the hobby, these are very archaic and dont come close a natural dawn/dusk as we see in the wild. I am to imporve on that. So it had to be an all-in-one system. The best example i found was the raspviv project, which sadly has been discontinued. The rest are all hobby projects by IT/Electronics enthusiast which, once i've seen the workings of the systems they created, dont propperly know the biological implications temperature or humidity has for an animal and the habitat is lives in. Time to make something myself that does follow the physics and biology, but also stays practical since a terrarium still is and always will be, a cheap copy of the real life thing. It was also important for me to design something that could be used by people who have less knowdledge of electronics or biology so they can still improve on thier animals healthcare regardless. As knowing what to use and how things work and why is something that comfuses most of the reptile keepers. But since the market for reptile products is so dispersed, i have to work with that. And with nature and ease-of-use in mind, the system needs to be modular. Better for you and better for the envoirement if you can re-use your existing stuff! Lastly, to build in safety for the organisms and for the end user, I abstained from any direct feedbakc loops. So the system doenst have any thermostat or humistat build in or any way of the system reacting of interferring with the change of values in your terrarium. This was one the most alarming things i found in most hobby projects and speaks for the lack of knowledge in most of them. Example, since i find it very important to educate people about this so you get a better understanding why some things shouldnt be done. Chameleons are heliocentric exotothermic animals. This means they heat up by the sun and need the sun to maintain thier metabolism, so to live. Most thermostats srill work by a simple feedback loop that dictates that at a certain temp, a heatsource will turn on or off. In most cases people use thier heatlamp for this. Which ofcourse is strange and bad since that would mean that when its to 'hot' the light goes away and when its cool enough again the light comes back. This is bad for most reptiles and amfibians since it greatly messes with thier day/night cycle and circadian rithme. Now there are smarter ones amough us which use a thermostat with a non light emitting heatsoource such as a ceramic bulb or heatbed or heatcable. For any heliocentric exothermic animal such as a chameleon, this again is very bad. These animals have had millions of years of evolution of adaptation to the sun so they directly link heat to light. so a non light heatsource messes with thier natural instinct and causes unnecessary stress and is a hazzard since they will actively be looking for light while goint to the heat source. In thier mind its a simple 'where there's smoke, there's fire' but there isnt so burns are very common with these sort of setups. The best option is a dimmer stat, which dims the heatbulb to cool down or heat up. But since our lamps tend to be in close proximity and the temp falloff of lamps is way steeper than the sun. this also tends to throw off most animals since the difference in temps tends to quickly rise and fall when this happens. Biggest problem of these 3 of all is, that the system dictates the heat the animals gets, not the animal whillst the animal probably knows best. To be fair a good implementation of a dimmer stat is probably the best solution as it mimics cloudcover the best, but so far the ones on the market tend to not be able to be programmed so the just uphold a certain avg temp stead of introducing some dips or ups in temps like a average day has. A normal day has normal distribution of temp. Lastly all thermostats are as good as thier sensor is, and when the sensor is bad or fails, it can have devestating effects of your animals. Remember the arduino is 'blind' if the sensor says its hot, arduino thinks its hot even if it isnt because of malfunction of bad sensor placement. So since i havent yet formulated a propper naturalistic way of implementing a thermostat, so there is none. Same goes for a humistat since water, air and heat have their own intricate dynamics that can cause severe harm to your animal is not propperly intergrated. So in short my design ethos for the system is: Modular All-in-one Solely benefitting animal health (no feedback loops)
So now for the features. Time management: My 'parade' implementation is a dawn/dusk implementation by using the Dawn to Dusk lib. .This lib uses astronomical algoritmes to calculate the position of the sun and earth on a given date. Which means it can calculate the lenght of day per day, per month, per year, creating seasonal shifts since summers have long days and winter have short days. It does this by putting in coordinates. So you only have to put in the coordinates of your house (which can be found when you out in your adress in google maps) and it will calculate your dawn and dusk times and thus lenght of day. You will need a RTC in the 24-hour format for this since it needs to know the date an time to function. In short the system should function as a seasonal shifting reptile 'wake-up light' stead of the abismall on/off timers. This should greatly reduce the animals stress and better mimic natural day cycles and greatly improve overal health and animal behaviour such as mating (since mating is seasonal bound). This is also where i had to make my first concessions. Since the dawn and dusk time itself also fluctuates between seasons so from 0>>100% light for dawn is lower in the winter than in the summer. I for some reason could not get this propperly coded, so i just made a simple 30 min timer, which is the avg of summer and winter times (winter<<30<<summer). The dawn/dusk is linked to the daylight via pwm. You can do this in 2 ways, which are hardware based and dont need any coding adjustments, either use leds (or any 12v pwm light source) in conjunction with the 230/110v heatbulb. So you can have the leds dim and @ 100% (255 pwm) the heatlmap goes on (for dawn). Or use as 230/110v pwm mosfet driver to directly link the dimming tot he heatbulb and make that the dimmer. Bot options need to be connected to a mosfet via pwm so on the arduino side nothing changes. I have it setup with led strips.
Lighting: In chronological order a day light cycle goes like this with this system: dawn time is reached, say 6:55>>> leds go from 0>>100% in 30 minutes, 100% reached>>> heatbulb goes on (now both leds and heatbulb are on for the rest of the day)>>dusk time is reached, say 18:46, heatbulb shuts down, leds stay on, leds go from 100%>>0%. its nighttime.
Lighting is split under two buttons, 'light' for UV and heatbulb (230/110V AC) and 'led' for the leds (12v DC). This isnt perfect since the on/off of the heatbulb creates peaks and dips of light. But the more lumen the leds give, so either use a lot of use higher output ones, the less of a problem the heatbulb poses since the delta light gets smaller. Since UV bulb cant be dimmed and if the can, please dont since that makes the uv output unpredictable, this spike and dip of light when the dawn is done and dusk begins, will always be there. One of the imperfections of a artificail envoirement. So with this first explanation you probably got an idea of the power management of the system. It has been split in 2 ways. 12v for pwm fucntions and 230/110v for timer functions. Fans and leds and other smaller things that need pwm control all go via a mosfet termial via 12v. All 230/110v so lamps,pumps etc. go via relay modules via timers. this way makes it safer to controla an safer to use. Still sticking at timer use and not may dreaded feedbackloops make it so that something failes it wont cause big problems like a malfucntioning hum sensor and the pump will keep pumping, flooding the terrarium (read a lot of messages about this problem, most cases not even a failing sensor but bad sensor placement). I use normal relays since i like the hear the clinking of the relay so i know it works and can check without opening the electro box. The bases system has 2x 230/110v AC ouput, 1 for heatblub, 1 for UV light. It has 3x 12v DC output for 3x leds strips you can add 3 led strips for dawn/dusk functions. This can be expanded on if needed. The mainspower lights have 2 main settings, one is called 'auto', which makes it work by the daily dynamic cycle and automatically makes the lights go on/off when the leds reach a certain value as explained above. The other function is 'time' which swithces the lamps to simple on/0ff timers. Where you have a starting and an end time. This i implemented for potentioal fails/errors withing the dawn/dusk fucntion. This way you can fast and easy switch to timers, so the lamps will work as usual while you can check for the problem. Its a ease of use function if theres a bump on the road. The 3 leds all have a separate pwm slider from 0 >> 255. I kept the 255 since is more is more precise, but you easely concert it to percentage in the code. The slider sets the max led output. This is because of my modular ideal. Since all ledstrips tend to have different max lumen output on max, with this you can manually mix and match different ledstrips so they all have a similar max output and thus give a better light output overal. The also each have a on/off so you can adjust needs. The led outputs are only ground and V+, NO RGB. Since RGB is terrible for animals. Im already a bit split on led implementation since leds tend ot have a very narrow light spectrum (sunlight has a very broad spectrum) which isnt ideal for reptile eyes. But when mixed with normal heatbulb this is less of a problem and leds are the easiest and most broadly implemented way of pwm lighting. Again a concession, have less ideal lighting and natural daylight dimming or no dimming with better light. Im still actively investing this point, updates in the future. But RGB is alsways bad. Reptile eyes are way different then ours and putting in different colors of narrow spectrum light is bad. Pls dont use them.
Watermanagement: Water management again goes via relay on timers. On the display this is split in the buttons 'Misting' and 'Fogger'. The base program has 2x 230/110v AC output, 1 for a misting and 1 for a fogger. But you can put any sort of 230/110v watermanagement on there. Just look at what it needs to do since both timers are coded differently. The fogger worjs the same as the light timer, where you can set a start and end time and the pump will work within that 2 times. Since a fogger needs at least 30 minutes to function (with could water, the higher the water temp, the longer it will take for water to fog up) this is anm easier way to implement. Be default thisis times 3x, so 3x you set a fogging interval. All 3 also have a separate on/off function. Some enclosures need multiple shortere fogging, some 1 long time. Watch out, the timers cant overlap so having one end @ 14:00 and the other start @ 13:50 will make the 14:00 one not work! I recommend to NOT USE THE FOGGER DURING THE DAY. This in creases bacterial growth and therefor infection greatly en for dryshedding animals hampers shedding which has a negative effect on thier health! Misting has a different timer. Again bij default you have 3 water events. Here we set a starting time followed by a misting duration in seconds. This because misting doenst need to be long in most cases. I have the duration set on max 60 seconds, but this can be adjusted in the code if it needs to be longer. It also has a 'test' buttom. When pressed this will activate the mister for 10, a countdown timer will show in the button when pressed. When pressed again it will stop. This is so you can always manually mist when needed and dont need a separate misting bottle etc. For my chameleons a fogger set during the night is enough. But a mister is widely used for paludaria and easely used within this system. But since they are only timers, you can use any sort of watermanagement on them for example a waterfall will work fine on the fogger timer.
Fan: This one is easy, its functions exactly the same as the leds, but its isolated from the dawn/dusk function. So the fans works with any kind of 12v DC fan since these are the most common used fans (pc fans). These are also 3x. The also have a pwm slider to set the speed of the fan and a separate on/off so you can mix andmatch which fan you want. but you can also just switch out weak and strong fans. I recommend using the fans sideways to create an airflow around the lamps, or put them upsidedown so the suck the air out of the terrarium. NEVER blow IN the terrarium unless its a mesh one. Most solid enclosures have sufficient passive ventilation for the animal using the 'chimney effect' (google it its pretty easy to understand physics) which will be hampered if you blow air into the enclosure in most cases messing with airflow and ventilation and potential harming the animal. It can also cause draft and cool a reptile excessively when it wet, which again can cause harm. You can also connect anything 12v pwm here. Like a peltier element ('TEC's' as a lot people call them) and add to the fans to for more intricate cooling.
System: This is where all the alarm/notification and fill-in functions are. Here you can set your coordinates, date and time if you fancy doing it manual (its easier to just upload on the RTC). You can also set the min/max of bot the temp and the UVI. The UV meter tends to be a bit unpredictable so use this with caution, it is far from prefect and even when 100% corretly implemented it still iffy because of the way the sensor works. It works with a fotosnesitive element, i used the ML8511, like a Light Depend Resistor (LDR) but for uv. So it will never be as accurate as a silicium based one like the solarmeter has. But when zeroed when you changed a uv bulb, it can measure the decline which is helpfull for you to know when to switch it out. But this sensor has a lot of trouble in bigger systems like this one since it reactes to the fluctuation currents. So using this will allways be and indicater, no perfect measurement! The system page has a calibration value for this sensor. I did the most i could to make it less iffy and normalised the values with some integrals, of which this calibration value is the result. I cannot go above 1 and should be lower than 0.5. In most cases it tends to be aroun 0.91 to 0.935. But i also had one that neede to go as low as 0.8776. Calibration works best when you ut the sensor in absolute darkness and after putting in the calibration value checking if the input says its 0. I calibrated well, it will say someting like 0.09 or even -0.09. UVI cant be negative but this is an artifact of how the sensor works. The closer to 0 the better the values. Here you can also manually set summer and wintertime. By default the system runs in summmer time and should automatically go to wintertime. But for some costum use you can also do it manual. When temp or UV go beyond the set min/max values, the numbers on the homescreen go red, and when added a buzzer, a buzzer will go beeping. I wanted both a visual and audible alarm function because of extra safety. When a value is changed, press the save button in the top right corner to save it to the EEPROM, if you dont save, the value will not change when you leave the system page!
Control: The whole system is controlled by an arduino mega 2560 and uses a Nextion 4024T032 touch display. I had a lot of debate with some other about a manual/physical control instead of wifi via app/browser which is easier and less coding. This is because i know a lot of keepers keep animals in basements and general out of reach or more isolated places/rooms where the wifi doenst reach. Also safety. If the wifi fails either because your isp has malfunction or the systems wifi itself fails, you cant control anything anymore and have to take the system off. Now you can always go to the console itself and adjust settings etc. but we live in 2020, so its a touch display and no ohysical buttons ( although i prefer actual buttons). The home screen shows all the basic things, temp, time (actual time aswel as dusk and dawn) date and all the pages for the settings named: LIGHT, MISTER, LED, FAN, FOGGER, SYSTEM. If pressed you go to the named functions as explained above.
Libraries used: Dusk2dawn.h TimeLib.h DS3132.h EEPROM.h DHT.h
This system is made to greatly improve the overal animal health but also to trigger the enduser to educate themself. To abstain from feedbackloops the enduser is forced to find more information about lighting and temperature and overal setup of the enclusore for the animal the keep. Every animal has its own specific habitat, and specially foe reptiles and amfibians who tend to be very specificly adapted to certain envoiromental aspects, its very important to know what you are doing. But some things like seasonal shift are just very hard to create, so i hope this system will take that weight of your shoulders! I would love to get feedback and see extra's added. Im not a programmer and this system has been in the works for at least 3 years now and i have had some great help from people in the community but it is far from perfect. But this was the best i could do so far. Things to be added are: datalogging: Since im a biologist i can only dream to get daily data of all aspects of my chameleons's enclosures to even further improve upon thier wellbeing! app/wifi control: this i simply have no clue of. costum functions: like a rainfunction (so lights dim a bit to simulate cloudcover, fogger goes aon for a bit because just before rain the air gets more humid etc.) more sensors!: soil, ph, pressure, lumen/lux, waterlevel for the pumps etc.
I hope to make this the best all-in-one system out there for exotic animal keepers! Sincere, T.