Weather and air quality monitoring station with ESP8266 and Home Assistant

I’ve always wanted a weather/air quality station. So I built one. Here it is.

The weather/air quality station laid out before connections. Rain sensor not pictured.

I’ll basically detect whatever I can get. Here’s the parts list so far (expected to expand):

  • PIR Motion sensor because maybe I want to know when people walk by the sensor box
  • Si1145 Sunlight sensor for Infrared, Visible, and Ultraviolet light. Conveniently using this Grove library to interface.
  • LIS3DHTR 3-axis accelerometer. I read that this one might have the noise and sensitivity characteristics needed to try to measure some seismic activity (I live in Seattle, after all)! Notably I did not research this very seriously so we will see. Note: this chip has three analog-to-digital inputs but they are not available in the Grove package that I got. Prefer Adafruit)!
  • BME680 gas sensor for Temperature, Humidity, Air Pressure and Volatile Organic Compounds (a rough measure of air quality)
  • HM3301 Laser PM 2.5 Air quality sensor for measuring particulates in the air at sizes PM1, PM2.5, and PM10. This will be really useful to have one outside and one inside during fire season so I can see how dangerous the air is outside and how well my air filters are doing inside.
  • Grove Loudness Sensor for keeping up with traffic noise, fireworks, landscaping, air traffic, etc.
  • The ESP8266 Microcontroller. I absolutely love the ESP8266 for being the brains of things like this. I had used one for my doorbell sensor, my mom’s boiler controller, and various other things. Programming this to read all these sensors is a major part of this project.
  • MH-Z14A NDIR carbon dioxide sensor (up to 5000 ppm). This is more interesting on the indoor unit than the outdoor unit, but fun nonetheless
  • Geiger Counter with USB interface. I had to reverse engineer the protocol coming out of this USB port and was able to do it using pyusb but that’s another post in itself. Unfortunately, I don’t think I can actually read this USB port too easily on the ESP8266 so I might have to slap a Raspberry Pi in here, or some other USB interface. This is a big TBD.
  • (Not pictured, see below or rain sensor post): Infrared rain sensor from Hydreon in MN. This is actually a sweet sensor. It shoots IR light around the dome and when water hits it, refraction of IR changes and the response at the receiver can pick up even a single raindrop. Garsh-darned epic!

As you can maybe see, I got most of these sensors with I2C interfaces from Grove, which has a really nice ecosystem with easily-interconnectable sensors. This is my first experience with the Grove ecosystem, and I love it. Very clean. Note, however, that I2C is not good for off-board sensors (so maybe not a great choice for the sunlight sensor which should be placed higher up).

Continue reading Weather and air quality monitoring station with ESP8266 and Home Assistant

Reading a TUF-2000M Ultrasonic Flow Meter with an Arduino or ESP8266

I had a flood in the garage the other day and realized how great of an investment my flood sensor had been, saving me literally weeks of time and thousands of dollars in repairs. As I considered buying more flood sensors to cover more parts of the house, the thought to put a flow meter on the main water inlet to the house popped into my mind. It’s not quite as clear of a signal as a flood sensor, but if I detect flow when everyone is asleep or when on vacation, I can be sure that something is going wrong and have Home Assistant give me an alert.

I didn’t want to cut into my water main and put a in-line flow meter in, so when I saw a reasonably priced clamp-on ultrasonic flow meter called the TUF-2000M, I had to bite.

The TUF-2000M Ultrasonic Clamp-on Flow meter
Continue reading Reading a TUF-2000M Ultrasonic Flow Meter with an Arduino or ESP8266

Connecting a Hydreon Infrared Rain Sensor to a ESP8266 (or Arduino or Raspberry Pi)

I’ve been working on a home-brew weather station and was looking into rain sensors when I discovered that you can get infrared (IR) rain detectors. A company in Minnesota sells one called the Hydreon RG-11. They shoot pulses of IR light around a plastic dome and monitor them on the other end. When rain hits the dome, the refraction changes and the pulses received are perturbed. This is nice because it’s very simple and has no moving parts. I figured I’d be able to find a way to read it into my weather station.

The RG-11 rain sensor with a NodeMCU for scale. (It’s actually bigger than I thought)
Continue reading Connecting a Hydreon Infrared Rain Sensor to a ESP8266 (or Arduino or Raspberry Pi)

Don’t use push-to-connect (“sharkbite-style”) fittings on high-temperature hydronic heating systems

I had a bad experience with push-to-connect pipe fittings between my hot water heater and my hydronic heating system and wanted to share with you what happened.

On Saturday morning at 4:19 am I was fast asleep. But then I jolted awake as the bedroom lights flashed on and a slightly robotic voice proclaimed:

“FLOOD ALERT! FLOOD ALERT. IN THE GARAGE! FLOOD!”

“Huh!”, I thought. “I wonder why that thing is going off?”

Continue reading Don’t use push-to-connect (“sharkbite-style”) fittings on high-temperature hydronic heating systems

Video showing the clear fluid rise in a Galileo thermometer

Some friend of a friend was over a few months ago (before the quarantine) and saw my Galileo Thermometer and explained to everyone how he thought it worked. He was wrong. So I figured, ok the world needs a better explanation of how these these things work. So I made this video.

The force balance on each float is gravity down, buoyancy up. The mass and volume (and therefore the density) of each float does not change as a function of temperature. The density of the clear surrounding fluid does go down with temperature. Because of this, the mass of clear fluid displaced does go down with temperature, and so the buoyant force does decrease as it heats up. When the upward force decreases, the floats drop down as gravity takes over.

To prove it, I made this video where you can clearly see the clear fluid rising as the thermometer heats up.

A live polar sun path chart (plus Moon and some planets)

I happened upon a polar sun path chart a while back and really thought it was a great graphic. It shows where the sun goes each day as a function of the seasons. Behold:

The polar Sun path chart for Seattle, WA

For Seattle, you can see at the top that the sun rises in the SE, peaks at 20° above the horizon, and then sets at 4:30pm on the winter solstice. Ugh. But in the summer, it’s up from before 4am to after 8pm, and peaks above 60° . You can make one of these plots for your area over at the University of Oregon’s Solar Radiation Monitoring Lab.

I liked this plot so much that I wanted to take it to the next level and see where the sun is live. In my experience with Python, I’ve grown to expect there to be sweet libraries that can compute stuff like that. Sure enough, there are a few. First, I found pysolar, which is really straightforward, fast, and simple. A few lines of code and I was up and running.

My first polar solar plot
Continue reading A live polar sun path chart (plus Moon and some planets)

Adding temperature sensors to a hot water heater

A igniter with a layer of white oxide powder all over it.
The bad igniter

I’ve got one of those hydronic home heating systems where hot water from the hot water heater gets pumped to radiators around the house in addition to heating up water for faucets. A few days ago it died on me and threw an error code indicating something was wrong with ignition. I took a look at the igniter and found that it was full of an oxide layer.

After sandpapering it, it worked great, but I ordered a spare for when this inevitably happens again. Along the way, it occurred to me that it’d be kind of fun to have instrumentation on my hot water heater. I just got it up and running.

Way back in my first post about hot tubs, I used OneWire sensors called Dallas 18B20s (datasheet) with an Arduino 2009. They worked great at hot water temperature, so I decided to try them out again. This time, rather than using an Arduino, I’m using a ESP8266 microcontroller. These are cheap and have Wi-Fi, so I can easily get the data into my home assistant setup, just like I did with my mom’s furnace, my doorbell, and other stuff.

Step one is to solder a bunch of sensors together. I wanted to get readings on all the different pipes going into and out of my hot water heater. I went down there and measured how much space I’d need between each sensor. Then I soldered them up. Notably 18B20s can work in “parasite mode” with just two wires, but there are problems with parasite mode on ESP8266’s, and in prototype testing I was unable to get that mode to work. So I just wired them up to 3 wires. This tutorial is a good one for wiring up these sensors.

A sensor with three wires soldered to it.
One Dallas18B20 soldered into my wire-o-sensors. Black goes to GND on the ESP, red goes to +5V on the ESP, and clear goes to GPIO 2, which is also jumpered to +5V with a 4.7 kOhm resistor
Continue reading Adding temperature sensors to a hot water heater

Making my analog doorbell smart by simply attaching a $7 sensor to it

My doorbell, which I want to make smarter

I live in tall and skinny house with a loft on the upper floor. I can’t hear the doorbell going off when I’m up there, especially if I have music playing. This post is about how I extended the range of my doorbell by hooking a sensor up to it that communicates over Wifi to my smart-home, which then plays a doorbell tone over my speakers throughout the house.

I already have a reasonably capable smart home based on Home Assistant, so I challenged myself to do this in the cheapest, least intrusive way possible. In the end, I did this with a $7 part and without changing any of the wiring in my existing doorbell (I just had to connect 2 extra wires to the existing transformer).

Here’s a preview of it working:

Here’s the demo of it working. The 2nd ring is through the stereo.
Continue reading Making my analog doorbell smart by simply attaching a $7 sensor to it

My book showcasing some open-source tools is now available

A teaching fellow at the University of Michigan once asked me if I could provide some career advice to her nuclear engineering students. I started off with basic industry knowledge but soon came upon computers. When hiring people onto a computational physics team, I always expect a certain level of computer-savvy. But it occurred to me that it’s probably challenging for a young student to catch up on all the classic computer goodies. So I wrote a book about them.

My book's cover, made with Inkscape
The book cover

Digital Superpowers hit the shelves of Amazon as an e-book tonight. It covers a bunch of open-source tools in an informal and broad tour, starting simple and building from there. It covers a few computer basics and introduces you to package managers before delving into short and sweet hands-on follow-alongs (and sometimes just drive-bys) with virtual machines, regular expressions, pdf toolkit, TOR, GnuPG encryption, LaTeX, Sphinx, pandoc, graphviz, Imagemagick, GIMP, Inkscape, darktable, Blender, Openshot, Audacity, LMMS, Hydrogen, Mixxx, git, Python, Django, Home Assistant, ESP8266s, Raspberry Pis, and self-hosting (among others).

Try it out and let me know what you think.

Reading “The Rise and Fall of the Third Reich” by William L. Shirer

While traveling this year I ended up visiting a Gestapo museum in Cologne as well as the Holocaust museum in DC. Wanting to learn more, I recalled my college years when my history-major friend Kris was lugging around this immense book with a swastika on the cover. I procured the (much lighter) Kindle version of it and went to work. Well, months later, I have finished it. It was an incredible experience to read: artfully written and absolutely dense with fascinating information. Terrifying but exciting. Gruesome but essential.

Hitler and the Nazis are quasi-taboo today in that while they’re brought up in every internet argument, such comparisons are dismissed as unattainable. They were so evil, people say, that it’s offensive to even begin comparing anything modern to them. But 1933 wasn’t all that long ago from civilization’s perspective, not to mention evolution’s. Human brains today are nearly identical to the brains of that time.

I totally reject the idea that Germans are some how pre-dispositioned as a people to have been the spawning ground of Nazism (aka Sonderweg). This book goes there a little and has been criticized for doing so. It’s clear that what happened there could have happened anywhere given the circumstances, and so we must be wary of it happening again in the future given any similar circumstances. Desperate, beaten, embarrassed people were conned by their own cognitive dissonance and one truly charismatic (yet crazed) leader into thinking it was some outsider’s fault, and that eliminating the outsiders would solve all the painful problems. The results were catastrophic.

But anyway let’s get to the book. Here are some notable things that I really had no idea about. I’m obviously no student of history so excuse me if this is all common knowledge.

Continue reading Reading “The Rise and Fall of the Third Reich” by William L. Shirer

Some fun or spooky Halloween automations with Home Assistant

It’s that spooky time of year again, but this time it can be extra spooky with the help of home automation.

Motion-activated jumpscare on TV

One classic spooky thing to do is have a TV do something scary when people walk by. This is easier than ever on any TV now that everyone has Raspberry Pi with HDMI output and z-wave (or other) motion sensors everywhere. Check this out:

Continue reading Some fun or spooky Halloween automations with Home Assistant

Authenticating and populating users in Django using a Windows Active Directory and SASL

I’ve been trying to get some Django stuff running that can securely authenticate users against Windows Active Directory and also populate some info (first/last name, email address, maybe groups etc.). There are lots of resources out there but nothing was fully complete or modern and it took me some figuring/hacking to get it done.

Resources I found include:

  • django-auth-ldap — the normal LDAP plugin. Problem: It does not natively support SASL and simple binds would send clear-text passwords. I think normal people would just activate TLS in this case but I didn’t want to do that
  • A relevant SO post — with an answer linking to a useful snippet that no longer works on recent django versions.
  • django-auth-ldap-ad — Someone’s entire different ldap plugin made specifically for this purpose. But it isn’t being maintained, is GPL-2, and doesn’t work directly in Python 3 or recent django.

Continue reading Authenticating and populating users in Django using a Windows Active Directory and SASL

I think my new motorcycle gloves “melted” my Oxford Heater grips

This may be a coincidence but about a week after I got new motorcycle gloves, my Oxford Heater grips started like, deteriorating away. Check this out:

They’re like melting

It has been hot recently, but this is still very odd. I got these Street & Steel V-74 gloves from RevZilla. Maybe it’s the Gel Palm leaking out and reacting with the grips? Who knows. Anyway it’s sticky and gross and annoying. Poor Oxford Heaters, I love those things.

Gloves that melt

Has this happened to anyone else!?

Multi-room audio over Wi-Fi with PulseAudio and Raspberry Pi(s)

NOTE/UPDATE: After an update this kind of stopped working and I struggled with it a lot. Now I actually recommend using snapcast instead of this solution. It works better!

I moved to a new place and it has more than one room. Naturally, I hooked up the stereo in the living room and tested it like my dad taught me: by playing “Money For Nothing” really loudly. It worked. But wait a minute, there’s an upstairs now… how will I get it playing up there? I could always use the wifi network and raspberry pis to beam audio around. Yeah, let’s do that!

Continue reading Multi-room audio over Wi-Fi with PulseAudio and Raspberry Pi(s)

The Hero Jr. personal robot from HeathKit: a 1984 product way ahead of its time

One of my first memories is a vision of lying near my dad in the basement in the mid-1980s while he endlessly soldered away at some big project. Later, I spent a lot of my childhood messing around with the product he was assembling: a Hero Jr. robot. This was a educational personal robot, intended to be your “friend, companion, and security guard.” Here he is:

Hero Jr. from 3 sides
My family’s Hero Jr.

Hero Jr. has a sonar, infrared motion sensor, light sensor, sound sensor, radio-frequency remote, drive motor, obstruction sensor, and a RS-232 serial port. His out-of-the-box features included a security guard mode, alarm clock, poetry, singing, and (my favorite) the ability to explore around the house, often while singing America, Daisy Bell, or Little Miss Muffet.

Continue reading The Hero Jr. personal robot from HeathKit: a 1984 product way ahead of its time

Idea: Communal voice assistant that chimes in during fact-based discussions

With all the AI voice assistants around today there are lots of interesting applications people are dreaming up. Here’s another one.

You could set your voice assistant on the table and start having a discussion or debate that inevitably involves bringing up facts about news or history or how something works. A lot of times when someone doubts what was said a phone will come out to do some fast wikipediaing or other searching. If a AI could somehow either know or be triggered to check something, that’d be an interesting new dynamic to the conversation. It could do things like:

  • Correct misquotes and other slight error in the discussion, e.g. “Actually, the NOAA temperature data were corrected in 1950 because the volunteer network switched from morning readings to afternoon readings.”
  • Fill in details about a headline someone read (person: “Didn’t I read a headline about radiation dose in beagles?”, AI: “The recent UC Davis study shows a correlation between dose rate and lifespan.”)
  • Look up details and say them when they’d help

It’d have to be a really smart AI to know when its utterances would be useful in a dynamic conversation. It could start by just lighting up when it thinks it has something to contribute and people could allow it to chime in, rather than having it chime in only when someone wakes it. Then eventually once it’s smart enough it could chime in on its own. The future is fun.

Secure remote access to a camera DVR with VPN and VLANs on an OpenWRT router

If you have a digital video recorder (DVR) hooked up to some cameras and you want to access it remotely when something happens, you can set up remote access to review things from wherever. Here’s how to do it.

Continue reading Secure remote access to a camera DVR with VPN and VLANs on an OpenWRT router

Helping an artist with a Morse code protest chant installation in Denmark

A few months ago, I got an email from a Sweden-based artist and teacher named MC Coble asking if my Morse code laser post could be helpful for an art installation they were working on. MC used Morse code in previous installations like one in Toronto where they sent coded light from a giant dome to people below who then relayed signals with flashlights. As a part of a new project, MC wanted people to be able to enter protest chants into a website and then have a system convert the message to code and flash a light in a gallery window. Did I want to help? You bet I did!

I got super excited about the prospect of helping with this and knew that with a combination of things I’ve used before it would be really doable. The plan was to have a webserver accept messages from a form and transmit them to a Raspberry Pi (cheap mini-computer), which would then flip pins on a relay to blink the light, like this:

A diagram showing the flow from user input through a webserver through MQTT to a raspberry pi and into a relay connected to a light.
The parts of the planned system working together

After many emails and some ups and downs, everything worked! This really feels like how the internet is supposed to work.

Continue reading Helping an artist with a Morse code protest chant installation in Denmark

A (medium-length) primer on energy, greenhouse gas, intermittency, and nuclear

Thanks entirely to the efforts of local climate-related organizations in Seattle, I’ve now spoken at a handful of book stores, breweries, universities, and even Town Hall on climate and energy. Last week, I was honored to be on one such panel at a brewery in Ballard alongside Univ. of Washington oceanographer LuAnne Thompson and Governor Inslee’s senior climate policy advisor, Reed Schuler. My role was to provide background information on the human relationship with energy: what we’ve used in the past, what we’re using today, and what our low-carbon options are moving forward.  I touched on progress and challenges with intermittency, hydro, and nuclear. This post summarizes and expands upon these topics.

Energy is a replacement for the labor of human beings

The first part of my talk was easy. I threw up my favorite slides demonstrating how energy improves quality of life by replacing human labor. Between construction, farming, heating, water, laundry, and travel it’s a pretty easy case to make.

Picture of guy on oregon trail vs. jet flying over mt. rainier
Traveling with and without a lot of energy

Continue reading A (medium-length) primer on energy, greenhouse gas, intermittency, and nuclear