Problem
I'm the owner of a pet snake, a ball python called Celeste. These reptiles are fairly sensitive beings to their environment. And considering they come from Southern Africa, having them in other parts of the globe with a different climate means you need to take measures to ensure their terrarium is appropriately prepared; especially with temperature, humidity and light.
Last year, in winter, my snake stopped eating for over 3 months. Worried, I took her to the vet, and they said the cause for this "fasting" was likely due to an issue with ambient temperature. Portuguese homes in winter tend to be really cold inside, due to the lack of central heating. There's often a joke country-wide that in winter, it's warmer to be outside than inside.
We installed air conditioners a couple of years back, and I was regularly using them during winter in the room I work in, which is also the room my snake's terrarium is in. So it never crossed my mind that the ambient temperature for the snake could be cold, and yet it was. So I took some measures to put the heating pad inside the terrarium for more effective warmth.
However with fleeting temperatures between seasons, one is never really sure (or remembers to check) how the temperature and humidity in the terrarium are doing.
Solution
I decided to create a little notification and logging system, with some minimal electronics, and a temperature and humidity sensor. I used an ESP8266 D1-Mini for the Wi-Fi board, and the DHT11 sensor for readings.
To speed up the software side of the application, I used NodeScript to create my Email notifications and logging integrations.
Main parts of the solution:
- Electronic WiFi board and sensor
- NodeScript platform for integrations
- Google Cloud Logs
- Brevo for transactional emails
- Sleepy pet snake (important)
Every 30 minutes the electronics would take a temperature and humidity reading, and call two NodeScript APIs:
Here's the flow:
1. Google Cloud Logs API:
I used Google Cloud Logging to keep track of the temperature and humidity over time, so that I can also analyse it later.
2. Email notifier API:
I used Brevo's transactional email API to help notify myself. If the temperature and/or humidity inside the terrarium were not in appropriate ranges for ball pythons, it would send me a simple email like this:
How the hardware works
The hardware is super simple, and here's how it looks in real life:
I've just powered it to the socket next to the terrarium. Here's the code I used to run it. Suggestions welcome, as I'm still a newbie in the world of embedded software :D
NodeScript API Integration Magic
Let's explore a bit behind the scenes
NodeScript really facilitated this project, by allowing me to have logging and email notifications being sent in a matter of 10 minutes. Here's the 2 graphs I used for this project:
1. Email notifications: Using Brevo API
NodeScript supports Brevo's third party library, and has an already pre-made module to facilitate sending transactional emails, all I had to give was the Brevo API key, and the email information (sender, recipients, subject, etc).
For example, here's some of the supported Brevo libraries we can choose from:
In the graph above, I handle the logic of checking if the temperature and humidity are within their respective ranges, and if they are, I create a text and add it to an array, which is included as a div in the email body.
Only if the messages array length is larger or equal to 1, the email gets sent.
I then "Publish" the graph and create an Endpoint so that I can use it with the embedded software code:
2. Logging: Using Google Cloud Logging API
NodeScript at the time of writing does not yet support Google Logging API out of the box, but we are able to get around this by creating a POST HTTP web request ourselves to the logging URL.
The graph above, takes the timestamp, temperature and humidity as inputs and creates a JSON object to send to Google Logs API.
I again publish the graph above, and create a POST endpoint to be used within the embedded software.
Here's a snippet of the .ino code:
// Send POST request to both endpoints
sendTemperatureData(TEMP_LOGS_ENDPOINT, temperature, humidity, timestamp); // Send to logs endpoint
sendTemperatureData(TEMP_NOTIFIER_ENDPOINT, temperature, humidity, timestamp); // Send to notifier endpoint
Terrarium Integrations
Last and most important step was placing the sensor inside the terrarium whilst the snake was not active. This meant waiting until daylight, when she was asleep. And also not placing the sensor anywhere near her water bowl to avoid bad user experience:
Disclaimer: No snakes were harmed in this project.
Here's the real setup:
Summary
We used NodeScript platform to create email notifications, and a logging system together with electronics WiFi board and temperature and humidity sensor to notify us of insufficient reptile living conditions inside Portuguese non-centralised heated homes.
Overall this project took about 12 hours:
- 6 hours learning basic
.inoprogramming with the aid of AI - 5.86 hours not realising the cables were switched, and that's why
NaNreadings were occurring - 10 minutes integrating email notifications and logging system with NodeScript.
All in all, a great Saturday spent.
Next steps:
There are many improvements that could be made to this project. A few ideas would be:
- Experimenting with more sensitive sensors
- Integrating an "action" part, where if the humidity is too low, then increase the water vapour inside the terrarium
- Adding a light sensor
Written by: Christelle Van Sebroeck, Software Engineer at UBIO