21 August 2021

DIY: Use an IKEA VINDRIKTNING air quality sensor in Home Assistant with ESPHome

Learn how to mod a €10 air quality sensor into a smart sensor with a cheap ESP8266 board

By In Make 13 min read

IKEA has released some interesting new products lately, focused on air quality. In this product line, one unit that stands out is the VINDRIKTNING air quality sensor. This cheap (just €9,99) sensor measures the air quality in your home, using a simple traffic light scheme to alert you. Green means the air is fine, orange means okay-ish, and red means it’s bad. Cheap, simple, what’s not to love? Well – it is a dumb sensor. And if you’re into smart homes like me, you want a smart sensor. But you’re in luck. Some people in the Home Assistant community have figured out how to modify the IKEA VINDRIKTNING so it can talk to Home Assistant via ESPHome! In this guide, I’ll explain how you can modify your own.

Particulate Matter

Particulate matter comparison from the EPA
Particulate matter comparison (source: EPA)

So, why do we even care? Well, air quality matters. You’ve seen the pictures of smog-filled cities, a haze of pollution covering the streets, and you instinctively know you don’t want to get that into your lungs. This pollution consists of what is called ‘particulate matter’ (PM). The American Environmental Protection Agency (EPA) has the following to say on the subject:

“Particulate matter contains microscopic solids or liquid droplets that are so small that they can be inhaled and cause serious health problems. Some particles less than 10 micrometers in diameter can get deep into your lungs and some may even get into your bloodstream. Of these, particles less than 2.5 micrometers in diameter, also known as fine particles or PM2.5, pose the greatest risk to health.”

Enviromental protection agency

So it turns out, it’s not just the visible smog you should be worried about. Tiny particles that you can’t see can still be drifting through the air – and they’re bad for you too. If particles less than 10 µm in size pose a risk to your health, it makes sense that you want to measure how much is in the air. That’s exactly what the IKEA VINDRIKTNING does – it has a Cubic PM1006 sensor module that uses infrared light to measure particles in the air. When the infrared light shines on particles, those particles will reflect light back towards the sensor. The sensor measures the intensity of the reflected light to calculate how much particulate matter is drifting through your air.

Cubic PM1006 LED Particle Sensor
Cubic PM1006 LED Particle Sensor (source: Cubic)

Now, there is a bit of a snag between IKEA’s product description and the actual sensor used in the VINDRIKTNING. The PM1006 is designed to detect particles ranging from 0.3 µm to 10 µm – which means it can detect PM2.5, as that falls in the range, but the actual range is that of a PM10 sensor. But both Cubic and IKEA market this as a PM2.5 sensor, which would indicate it only detects fine particles of 2.5 µm and smaller. It doesn’t seem to quite add up. Now, either way, particles between 0.3 µm and 10 µm particles are bad for you. For an affordable €10 you can know how much of it is in the air. I figure it’s still worth it. But I just want to make clear, at the onset, that I think this sensor might not be quite as specific as IKEA says it is.

Anyway, the VINDRIKTNING lights up like a traffic light to indicate the current air quality status. If there’s 0 to 35 µg/m3 PM10 in the air, the traffic light is green. For 36 to 85 µg/m3 the traffic light becomes a warning orange. And at 86 µg/m3 and over, the traffic light becomes a please-open-a-window red. Now – how can we go beyond the traffic light and get the actual numbers into Home Assistant?

Connecting the IKEA VINDRIKTNING to Home Assistant

IKEA VINDRIKTNING sensor
IKEA VINDRIKTNING (Source: IKEA)

The base work to getting this sensor talking to Home Assistant was done by Hypfer, who developed this ESP mod and wrote the first code for this purpose. It was a stand-alone version that used the MQTT protocol to communicate, but Habbie then took the idea and adapted it for ESPHome. Since we can run ESPHome as an add-on in Home Assistant, this is the perfect way to mod this sensor for our use! A recent post on the Home Assistant forum sums up the current state of the project.

The mod itself is quite elegant: instead of hacking the insides of the VINDRIKTNING apart, we just add a tiny ESP8266 board. This board taps into the signal sent by the sensor module and sends it to Home Assistant over WiFi. This way we don’t actually control the VINDRIKTNING itself, but whenever the sensor normally takes a reading we’ll receive that same number in Home Assistant.

That also means this modification is the simplest ESPHome project I’ve ever done. You only need an IKEA VINDRIKTNING, an ESP8266 board, and 3 wires to connect the two. To fit into the VINDRIKTNING case I would recommend the WeMos D1 Mini board, which is tiny enough to fit without modification. You can also get (cheaper) D1 Mini boards from other producers, but I’ve had connectivity issues with off-brand Minis before. So far, the ‘official’ Lolin D1 Mini boards have been the best in my experience. You’ll also need some cables to solder – I cannibalized some cheap 10cm breadboard jumper cables I got in an electronics starter kit. You can also buy proper DuPont cables or any other suitably short electronics cables.

ProductSource
IKEA VINDRIKTNINGIKEA
Lolin / WeMos D1 MiniAmazon
10cm DuPont cablesAmazon

VINDRIKTNING configuration in ESPHome

For this post, I won’t go over the installation of ESPHome in your Home Assistant setup. ESPHome has an excellent guide on their website that takes you through all the basics, and there’s plenty of YouTube tutorials on the subject.

Create a new sensor in ESPHome by hitting the big + in the bottom right. You’ll be asked to name your sensor and fill in your WiFi SSID and password. In the next screen, you have to select your boards. In our case, this is a WeMos D1 Mini, but you may be using another board. Once you’ve selected your board, ESPHome will generate a basic template for your configuration with some default settings set up.

Now we just have to add a little bit of code to load support for the PM1006 sensor, tell ESPHome which pin we’ll solder the VINDRIKTNING to, and register this output as a sensor in Home Assistant. That bit of code looks like this:


# Ikea Vindriktning PM2.5 sensor
uart:
  rx_pin: D2
  baud_rate: 9600

sensor:
  - platform: pm1006
    pm_2_5:
      name: "Ikea Vindriktning PM25"

Note: The code above assumes you’re on version 2021.8.0 or higher of ESPHome. From this version onwards it contains the code for the VINDRIKTNING sensor. If you have not updated to this version of the add-on yet, you can still load the necessary code as an external component by also adding:


# External component until final merge
external_components:
  - source: github://sermayoral/esphome@pm1006
    components: [ pm1006 ]

Copy the code you require and paste it into your template – you’re done. Because we’re using a WeMos D1 Mini, we use the D1 Mini’s markings in our code here, specifically: rx_pin: D2. If you’re not using a D1 Mini, the pin you’re going to use may have another name on your board. Replace D2 with whatever GPIO on your board you’re going to use.

In the end, your configuration file should look something like this, except with your own wifi details and passwords in the various fields:

esphome:
name: vindriktning
platform: ESP8266
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "OTAPASSWORD"
wifi:
ssid: "SSID"
password: "SSIDPASSWORD"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Vindriktning Fallback Hotspot"
password: "APPASSWORD"
captive_portal:
# Ikea Vindriktning PM2.5 sensor
uart:
rx_pin: D2
baud_rate: 9600
sensor:
– platform: pm1006
pm_2_5:
name: "Ikea Vindriktning PM25"

Save your code, then hit the Install button on this project’s card in ESPHome. Now, pick an installation method and just follow the instructions to get your board ready for use. I usually pick connecting the board to my Home Assistant server via USB cable, which is the most stable option. Once ESPHome has uploaded the binary to your board you can build it into the VINDRIKTNING.

IKEA VINDRIKTNING modification guide

Time to get hacking! First, we open up the IKEA sensor. It’s pretty easy: There are just 4 screws holding the front on. Use a long electronics Philips head screwdriver to open it up.

Unscrewing the IKEA VINDRIKTNING case

With the sensor opened up, the inner workings of the VINDRIKTNING are revealed. There’s a small PCB board screwed into the front panel, with wires leading to a small fan (2 wires, one red, leading to it) and to the actual sensor module (4 black wires leading to it).

Opening the IKEA VINDRIKTNING case

Unscrew the 3 screws from the PCB to pop it loose from the front panel for easier access.

Unscrewing the IKEA VINDRIKTNING PCB from the case

With the PCB free, you’re ready to start doing some soldering. If you want even easier access, you can also disconnect the wires leading from the other components to the PCB. But I kept the wires connected, as they weren’t really in the way.

Holding the IKEA VINDRIKTNING PCB

There are 5 round, copper, test pads at the top of the PCB. These are normally used to test and diagnose problems with the PCB, but we’re going to use them to connect our Wemos D1 Mini board. We need to solder 3 wires to the PCB: 5-volt power, ground, and the sensor signal. These go to the test pads marked +5V, GND and REST on the PCB respectively.

Identifying the test pads on the IKEA VINDRIKTNING PCB

These wires will lead to the Wemos D1 Mini board as follows:

  1. The wire from the VINDRIKTNING’s +5V pad goes to the D1 mini’s 5V pin.
  2. The wire from the VINDRIKTNING’s GND pad goes to the D1 mini’s GND pin.
  3. The wire from the VINDRIKTNING’s REST pad goes to the D1 mini’s D2 pin.

If you’re not using a Wemos D1 mini the markings on your board will be different, but you can use any GPIO (General Purpose Input/Output) pin available on your board. Just go back and modify the ESPHome code to match the name of your pin. The choice for the D2 pin is also arbitrary – as long as you program it right in ESPHome, you can use any GPIO.

Identifying the pins on the WeMos Lolin D1 Mini

It’s a pretty doable job, you just need to solder 6 points in total. I removed one end of a 10cm jumper cable to solder the wire directly to the PCB test pads, and then inserted the remaining pin end of the wire into the Wemos D1 Mini to solder into the hole. Once soldered I clipped the pins on the other side of the board. Once you’re done the result should look like this:

Honestly, I apologize for my shitty soldering job, but I think this proves that if I can do it, so can you 🙂

So let’s take a look at the spot where we’re going to fit the WeMos board. There’s just enough room between the fan and the USB-C port for it to squeeze in. If you’re worried about the screws on the fan shorting your board, cover them with a bit of electrical tape to isolate them. In this build, I taped the front screw but figured nothing important on the WeMos would touch the rear screw. Drop the Wemos into the gap and it should look a bit like this:

We’re in the home stretch now. You could physically hot-glue the WeMos to the case at this point, but I’m still in the experimentation phase and may have to disassemble this build repeatedly. So instead, the WeMos gets to rattle around inside the case. With the WeMos board in place, we start putting it all back together. The 3 screws reattach the PCB to the front panel.

Reattaching the IKEA VINDRIKTNING PCB to the case

And then the 4 screws put the front panel back onto the case. Make sure you screw these in tight and the panel sits flush against the case. If it’s loose, you’ll find your USB cable won’t fit snugly and the sensor will be prone to rebooting randomly as the cable wiggles.

Assembling the IKEA VINDRIKTNING case

Hook it up to USB power. If you’ve done everything correctly, you’ll see the LEDs on the front start to pulse between the three colors for 10 seconds. After that, the sensor is booted up and it will settle into the color matching your air quality.

Using the modified IKEA VINDRIKTNING sensor on our cabinet

Log back into your Home Assistant installation. From the Configuration menu, you should now be able to go into Integrations to discover and add your new VINDRIKTING sensor. It’ll show up as a device and entity underneath the ESPHome card. Add the new entity to your Lovelace UI via your favorite sensor chart (I’m a fan of mini-graph-card).

Congratulations! You’re done!

Our experience using the IKEA VINDRIKTNING

IKEA VINDRIKTNING air quality chart in Home Assistant
Our VINDRIKTNING chart after normal cooking

The sensor has been running steady for two weeks now and it’s quite interesting to see the data for our apartment. So far, we’ve mostly been in the green area of the range. The air quality seems to be pretty okay here in the Netherlands. The only time the VINDRIKTNING is put to the test is when we’re cooking. Frying things in a pan releases a lot of particles, and they spread through the room fast. That’s logical, it’s why your house smells so good when you’re cooking something yummy. But it also means a lot of particulate matter is filling up that air you breathe and we should open up a window.

Usually, these aren’t bad peaks – the light might go red and our sensor will say we’re at about 100 µg/m3. But we had one ‘incident’ when we were going to sear a carefully prepared piece of sous-vide steak. Sous-vide meat needs to be seared as fast as possible, on the hottest temperature you can manage. So, we made a cast-iron frying pan as hot as possible on our furnace and seared the steak on it for 1 minute total. The VINDRIKTNING threw a fit: we weren’t just in red territory, we hit the peak value of 1000 µg/m3 – the sensor can’t go any higher than that. It wasn’t wrong either – there was definitely a smoky haze in our apartment.

Automating the IKEA VINDRIKTNING

We haven’t really started using the sensor in any automation yet, but the possibilities are definitely there. If you have an air purifier in your home, you could start it automatically if the VINDRIKTNING senses a lot of particulate matter in the air (in fact, people have already done this with an IKEA air purifier). Or, you could compare the current air quality in your house with the current air quality outside, and send you a notification to open the window when the air outside is better. Even better, if you have automated ventilation, you could start actively pumping outside air into your house. If you have any more ideas on how we could automate this, don’t hesitate to leave a comment!

What do you think?