"Why the heck is there water dripping into my basement", I thought as I ran on the treadmill. Definitely not a good sign in the middle of the winter.
It must be a plumbing problem in the kitchen or one of the upstairs bathrooms. No, I checked and that's not it.
Oh no! It's coming down inside a wall. This isn't good!
I open the small door leading to the attic and immediately see it. Condensation on the underneath side of my roof. Condensation that is dripping onto the wall, then down through the walls through the second floor, then the first floor and finally dripping out of the ceiling right in front of my treadmill.
Water, wood, insulation - not a good mix. What's next? How about some mold?
Sad story cut short - after hiring a company to fix the problem, installing more vents in my soffits, and thousands of dollars later, I wondered whether I could create a device to alert me in the event condensation conditions ever occurred again.
The Bring Intelligence to the Real World competition on Hackster.io gave me the perfect chance.
HardwareThe Avnet SmartEdge Agile provides the temperature and humidity sensors required for this project. In a single package you get these sensors plus several others, a rechargeable battery and BLE to connect to a gateway. I used an Apple iPhone as my gateway device but it's also possible to set up a RasPi for this function.
The gateway communicates with a data portal provided by Brainium. On the portal you can set up a new project to collect the needed information from the Agile device.
In this case, the Brainium project is ultra-simple. We are gathering temperature and humidity at as slow of an update rate as possible. This data is collected at the portal and then made available to the monitoring server via MQTT and the API provided by Brainium.
Finally, I used an older Raspberry Pi as my monitoring server. It already had Python installed and a couple choices for the IDE. I picked Thonny and it turned out to be very user friendly and even though it's not overly-featured, it worked fine for my purposes.
SoftwareLet me start off by saying I am not a software developer by any stretch of the imagination! So, the code here is hacked together from sample code and with assistance from a more expert coder than me (thanks Will M.!)
I used Python to communicate with the Brainium portal using its MQTT API for access to updating data values. I used Twilio for SMS messaging. I used the very simple approximation for dewpoint calculation I found on this great Wikipedia article.
The main idea is to periodically compare the current temperature with the dew point temperature. In the situation where the ambient air temperature is the same or lower than the dew point, the conditions for condensation exist. This situation is alerted with an SMS message. After a predetermined number of samples without condensation, an "OK" message is also sent via SMS.
The dew point is the temperature to which air must be cooled to become saturated with water vapor.
My next design decision was where to host my monitoring application. I considered a variety of cloud services but ultimately decided to use a Raspberry Pi. The main reason - it was the easy answer. I already owned the hardware and realized quickly I could prototype the code and avoid some network communication challenges by just running this on my own hardware in my own network. (see more in What Could Be Improved
)
- The SmartEdge Agile device worked great as a prototyping platform for this project. I struggled at the beginning with a firmware update problem, but the technical support people at Brainium resolved the issue and I never had any more communication problems with the device.
- I learned a lot about Python! This project was great because it forced me to learn some new things that I have always wanted to learn.
- Twilio is very cool. Once I figured out the nuances of phone number registration, it worked exactly as advertised.
- I question the basic physics of the project - and this is a big one! My operating theory is that when the temperature is lower than the dew point, condensation will occur. However, there are a couple problems here. 1. The SmartEdge Agile device provides the temperature internal to the device. We really need the dry bulb temperature. 2. I am using an approximation of dewpoint that only works for relative humidity greater than 50%. 3. When you examine the simplified dew point formula you will see that the temperature can never be less than the calculated dew point. Even if relative humidity is 100%, the dew point and air temperature are the same. So then, perhaps just monitoring relative humidity is sufficient? However this is not a very satisfying answer because the cold underside of the roof is where the water actually condenses. So, I think using a temperature and humidity sensor for the dew point calculation and a second temperature sensor at the coldest possible surface in the attic might be a better way to go at this. I'd welcome comments and suggestions from someone more skilled in this art.
- The battery life of the SmartEdge Agile would be a problem if this solution was used long term. This is a device that should be thrown into the attic and essentially forgotten. If you replaced the device or at least the battery once a year, that would be acceptable. For the low data rate required this battery life could be achievable but you'd need a different sensor platform.
- The sensor-gateway architecture is great in some ways (easy to set up, easy to troubleshoot) but not great in others (requires a spare device laying around to be used for this purpose).
- As a further learning opportunity and to make this more resilient and scalable, I would next move the monitoring application to a cloud service. Take your pick of which one - since this is a simple application any one will do.
- The whole point of the Bring Intelligence to the Real World competition was to integrate AI at the edge. My application was so simple that no AI is needed - it's just a simple calculation. Could AI be implemented? Possibly so but it was beyond the scope of what I wanted to accomplish.
- The Brainium portal provides some nice alerting capabilities, however it does not support any calculations on the incoming sensor data. This capability would make this project extremely simple by eliminating the need for a separate monitoring server. I have submitted this feature request to customer support at Brainium.
Comments