The Raspberry Pi-Powered WindowSense Talks to Nest, OpenWeatherMap, Tells You When to Crack a Window

Written in Python, WindowSense queries a Nest thermostat and OpenWeatherMap to let you know when you should open your window.

Brian Whippo has published the results of his first Raspberry Pi project, and it's an impressive one at that: WindowSense, a Python-based Internet of Things (IoT) project which ties into the Google Next and OpenWeatherMap ecosystems and advises you on when to open and close your windows via a Sense HAT display.

"Not long after COVID-19 began to reshape our lives I found myself with lots of time at home and an itch to start a new indoor hobby," Whippo explains. "Intrigued by a tech article about someone's Raspberry Pi project, I went down the rabbit hole and soon bought one of my own. Aside from one semester of C++ in college 15 years ago, however, I had minimal experience with computer programming, so I set out to learn on my own."

Built in Python, the WindowSense aims to let you know when the outside temperature matches your thermostat. (πŸ“Ή: Brian Whippo)

"This is my first original project creation after going through a Raspberry Pi tutorial book, completing the Python 3 course at Codecademy, much self-directed learning by Googling stuff, and learning how to design & print 3D models. The GitHub repo attempts to pay forward a small fraction of the help I have received from others by providing a collection of learning resources I've used along my journey."

The core concept behind the project: A system that pulls in temperature forecasts from OpenWeatherMap, compares it to the current temperature set on a Nest thermostat, and then suggests whether it's a good or a bad idea to crack open a window for some fresh air.

"WindowSense uses a stylized graph in a spectrum of colors to show when it will be cold, warm, or comfortable outside," says Whippo. "The 8x8 RGB LED matrix represents eight hours of forecasts, with now on the left and the next seven hours from left to right. The thermostat's comfort range, as defined by the heating and cooling setpoint, is represented bythe middle two rows in green. Outside temps closer to the top of the comfort range place the green square higher; cooler temps closer to the bottom of the comfort range place it lower."

"Each row of the graph represents steps of equal size, to give a relative impression of how much colder or hotter it is outside than you would want it to be in your home. If your comfort range is heat to 65F and cool to 75F, for example, then each block is 5 degrees. Additionally, if the forecast will be below freezing, the bottom row will turn white to indicate the possibility of snow and ice."

The system runs on a Raspberry Pi Zero WH with Sense HAT add-on, housed in a custom 3D-printed case. A Python script pulls thermostat data from the Google Device Access API, along with forecast from OpenWeatherMap β€” then calculates and draws the graph. The device is also capable of responding to button presses, displaying the ambient temperature and humidity as sensed by the Nest thermostat, print the current hot and cold points, adjust the LED brightness, manually refresh the graph and forecast data, and safely shut the system down.

"As this is a learning project for me," Whippo writes, "I am open to your feedback on all aspects of the project, from the Python script to the case design and everything in between. I expect I will learn a dozen things from your comments here! Some ideas I have for next steps are: Incorporating logging into the code to help with debugging as complexity increases; Graceful exception handling and recovery for internet outages, etc; Refining the code as my understanding of class/module design improves; A web interface or mobile app integration with notifications."

The WindowSense software has been released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License on GitHub, while the custom case can be found on Thingiverse under the same license. Additionally, a discussion on the project is ongoing over on Reddit.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles