Follow up: Temperature/Rain Sensor

Christian Kellner
3 min readMar 10, 2021

--

This is a follow up on this article: => Click.

A couple of weeks after I build the temperature and rain sensor, I’m now coming back to this with quite some improvements, which I’d like to share with you.

Problem I: Short lifetime of rain sensor

The rain sensor only worked for like 1 1/2 months. Due to the current flow and the contact with water, the rain sensor built rust from electrolysis that damages the sensor. There are a couple of things one could do about it. The best way probably would be to complete turn off the sensor while not measuring. However, this would mean a new hardware part. I’ve decided to try increasing the lifetime, by reducing the operating voltage from 5V to 3.3V. This should already help. I simply did that by using the 3.3v pin instead of the 5v pin.

Problem II Battery was draining fast

Probably the biggest mistake I did was using a powerbank and connecting it to the ESP via USB. USB is ok if you want to flash the ESP, but not a good choice if you want to power the ESP. Reason for that is it has to transform the 5v to 3.3v with an internal regulator which consumes power (and a lot of other reasons as well).
I’m now using 3 AA batteries (1,2V each => 3.6V which is perfect for the ESP) and connect them directly to the 3.3V and ground pin of the ESP. This way I get theoretically months of runtime with a single charge

I’ve also updated the code and make it way more efficient. See here. E.g. I’m now activating wifi only after measuring the sensor data…

Problem III external node service as backend

Let’s face it, writing a node service to have historic data is nice, but definitely an overkill. What if you want to show more data? What if you want to slice and dice the data differently? There are way better solutions out there. The one I’ve decided to use is InfluxDB.

Influx is an open source time series database. You can run it in their cloud (then you only have 30 days of data unless you pay for more) or you can install Influx on your server (which I did).
Your ESP can then send the data to Influx. You can build nice dashboards and visualize the data as you like.

Homebridge-Influx Plugin
In order to get the data into Homekit, I build a Homebridge plugin, called Homebridge-Influx.
This plugin connects to your Influx server and collect the latest value from the server, providing it to Homekit. This is neat, because you only have to do 1 network call instead of 2.

InfluxDB Dashboard
InfluxDB Dashboard

Problem IV too many wires

To be fair, this is more like an estetic problem, but none the less it always bothered me. I got rid of the wires and used a prototype board to place the ESP as well as the rain sensor control board onto it. The connection is now done using jumper instead of wires, which makes the whole design more clean and robust.

Some of the mistakes above were made solely because I was a noob when it comes to building such sensors, however by writing this, I hope I can save you some time :)

ESP Backside
Backside
ESP Frontside
Frontside

--

--