Posts tagged #HomeKit

1 post

It's been on my mind since we moved into our new home that I wanted to somehow add our pool's temperature to HomeKit. Just being able to see if the pool is warm enough for swimming would be worth it alone, but a ton of other automations could follow.

After searching for existing products, for which there were none, I had to fall back to crafting my own solution. Other than woodworking, I really didn't have the means to create something that I felt was both safe and didn't look like total garbage.

Enter 3d printing...

A close friend of ours, who is really into 3d printing, knew we were interested in getting a 3d printer at some point and was keeping an eye on deals for us. A good price on a Sovol SV-01 popped up one day and we jumped on it.

I've had several ideas about how to do this, including inserting a temperature probe in our post-pump piping, inserting one in the strainer basket, and creating a floating temperature probe. The first option scared me since it required drilling a hole into our piping. The second and third options both seemed viable but I preferred the float approach.

Design

After getting the 3d printer dialed in and learning the basics of Meshmixer and Cura, I set about creating some prototypes. I eventually landed on a conical shape with the probe sticking out of the tip of the cone. This way, it would float due to the ballast at the top and the temperature probe would always be in the water since the battery weight would be in the cone. The electronics would sit at the top, above the battery and temperature probe. A screw cap would be sealed to the top to keep water out.

The temperature probe 1

The temperature probe 2

The temperature probe 3

As you can see in the pictures, the probe sticks out of the tip and the wire runs inside the cavity past the NiMh battery to where the circuit board will be mounted to a mounting plate. After testing whether it would actually float the way I wanted it to (it did), I started working on the electronics

Electronics

I needed this project to be super low-power, so I opted to use a variant of the ESP8266 that is designed with low power applications in mind: the ESP-01. This version of the ESP8266 does not have UART, so you will need a USB to Serial adapter and a way of regulating the voltage down from the 5 volts USB provides to the 3.3 volts the ESP-01 requires. Some people say you can use 5 volts and get away with it, but I'd rather not risk it.

I also needed a power source. I considered using solar to charge a battery, but decided to keep version one simple. Besides, if I can get the battery usage low enough it can run for months and in some cases years on a single charge, battery characteristics being the major wildcard in that calculus. I decided to go with a 6V 2400 mAh NiMh battery since it's safer to use in the water as opposed to lithium ion. It too would need its voltage regulated down to a safe 3.3 volts, which I did with a MCP1700 voltage regulator.

The temperature probe 4

The temperature probe 5



In order to measure temperature, I used a simple water-proof version of the DS18B20 temperature sensor. As opposed to the bare DS18B20 that can be mounted direcetly to a PCB, the water-proof version comes within a sealed steel sleeve that fits nicely at the end of the probe. I used a small amount of sealant around the probe, but it was mostly sealed due to the tolerances between the probe and the float.

The temperature probe
I am a novice when it comes to creating electronics so there was a bit of a learning curve here with regards to how to wire everything together, but I figured it all out pretty quick. Here is the first version of the PCB finished. I added some pins for easy programming in case I needed to reflash the firmware. I also added some comformal coating to the PCB just in case moisture gets in.

The temperature probe 6

The temperature probe 7

And here is the final product, sans lid.



The temperature probe 8

One problem with the ESP-01 is that it doesn't natively support deep sleep. This is a mode you can put the ESP-01 into where it uses an extremely low amount of power, wakes itself up periodically to perform a task, and goes back to sleep. You can get literal years out of these on a single charge if your battery will allow for it and its done right. However, like I said, it isn't supported natively out of the box. In order to enable it, you have to do some extrenely precise soldering between a pin on one of the ICs and the reset pin of the board. I followed this Instructables guide in order to make sure I got it right. It took several attempts before I got it, but eventually I was successful. It was extremely tedious...

The temperature probe 9

Software

Updating the firmware on an ESP-01 is done using the Arduino IDE. I would share the code, but it's fairly custom to my set up. I have the ESP-01 turning on, connecting to WiFi, reading the temperature, and logging the temperature value to an instance of Homebridge's HTTP Temperature sensor library and an InfluxDb instance I run on my server for historical data as well as Grafana graphs. After that, I tell the ESP-01 to sleep for 10 minutes and repeat.

After doing that, I can perform automations in HomeKit as well as render some pretty sweet graphs of the temperature changes throughout the day. As you can see, I've put these in a few places around the house to model how the temperature changes throughout the day. Needless to say, attics in Florida get extremely hot, and its not even summer yet!



Grafana!

Final Thoughts

This project is definitely still in progress and I have some thoughts on improvements for the next version. Some things I would do differently would be to not use a screw-top to seal the lid. The threads never really worked very well, making it nearly impossible to get it on very far. I'd also probably use a different shape as this took forever to print and could probably be made a lot simpler. Another change will be to switch out the batteries for LiPo after a while. Lastly, I wouldn't print it in PLA. From what I've read, it's not the best to use in water and may eventually fail. Luckily, it's not a hard project to recreate so we'll see how version one does.

In the end though, it's working well and I'm pretty proud of it. Battery life seems promising and if my current calcuations are correct, it should last for at least a year on one charge. Even if it only lasts a few months, that would be totally fine by me since charging doesn't take long. Updates forthcoming!

First voyage! 1

First voyage! 2

    James Miller