Wifi MQTT Data Logging via an esp8266 for the Ikea VINDRIKTNING PM2.5 air quality sensor

Overview

MQTT connectivity for the Ikea VINDRIKTNING

This repository contains an ESP8266 firmware, which adds MQTT to the Ikea VINDRIKTNING PM2.5 air quality sensor. The modification doesn't interfere with normal operation of the device in any way. The ESP8266 just adds another data sink beside the colored LEDs.

half_assembled

Home Assistant Autodiscovery is supported. Furthermore, the WifiManager library is used for on-the-fly configuration. Also, ArduinoOTA is used, so that firmware updates are possible even with a reassembled device.

As the ESP8266 is 5V-tolerant, this should there shouldn't be any issues, however I haven't had time to test this for longer periods of time. Therefore, if the ESP burns out after a while, just add a voltage divider or something.

Prerequisites

To extend your air quality sensor, you will need

  • An ESP8266 with a 5v voltage regulator (e.g. a Wemos D1 Mini)
  • Some short dupont cables
  • A soldering iron
  • A long PH0 Screwdriver (e.g. Wera 118022)

Fortunately, there is a lot of unused space in the enclosure, which is perfect for our ESP8266. Also, everything we need is accessible via easy to solder testpoints.

Hardware

To install the ESP8266, you need to unscrew the four visible screws in the back of the enclosure.

Then, there are also three screws holding the tiny PCB in place. These aren't necessary to remove since you can solder in-place, however personally, I'd recommend taking the board out of there since it will be easier to solder without fear of accidentally melting some plastic.

board

As you can see in this image, you'll need to solder wires to GND, 5V and the Testpoint that is connected to TX of the Particle Sensor.

Then just connect these Wires to GND, VIN (5V) and D2 (if you're using a Wemos D1 Mini).

Done.

Software

The firmware can be built and flashed using the Arduino IDE.

For this, you will need to add ESP8266 support to it by using the Boards Manager.

Furthermore, you will also need to install the following libraries using the Library Manager:

  • ArduinoOTA 1.0.3
  • ArduinoJSON 6.10.1
  • PubSubClient 2.8.0
  • WiFiManager 0.15.0

Just build, flash, and you're done.

When connecting everything up, you should see an open Wi-Fi Access Point to configure your Wi-Fi and MQTT credentials.

Low-Noise Mod

As you might've noticed, there's a fan in there, which is audible even multiple meters away.

For some reason, the Ikea uC firmware decides to toggle the fan on and off every minute or so causing the noise it makes to change and therefore it constantly stays noticeable.

Good thing is that the Fan does spin up fine with just 3.3V, which means that we can run it constantly from the voltage regulator of the D1 Mini.

At 3.3V its noise is barely noticeable from 50 cm away.

3.3v

Having the Fan not connected at all was also tried but proved to mess up all readings completely.

This is of course a more invasive modification than just adding Wi-Fi data logging. Though, given that it is just a €10 device, I'm fine with that.

To make soldering a bit easier, note that the whole outer metal part of the Micro USB connector of the D1 Mini is connected to GND.

Misc

The VINDRIKTNING consists of a custom(?) Cubic PM1006-like Sensor + another uC that does all that LED stuff, which talk via UART. The uC simply regularly polls the sensor and displays the results.

Therefore, to add Wi-Fi connectivity, we just need to also listen to the TX of the Sensor and decode those messages. The Ikea uC will do all that polling stuff for us.

ToDo

Reconfiguration of a provisioned device without having to OTAU a firmware that clears the settings would be nice.

References and sources

Comments
  • reading calculation appears to be wrong

    reading calculation appears to be wrong

    https://github.com/Hypfer/esp8266-vindriktning-particle-sensor/blob/master/src/serialCommunication.ino#L2 says

    serialRxBuf[3] * 256 ^ 3 + serialRxBuf[4] * 256 ^ 2 + serialRxBuf[5] * 256 ^ 1 + serialRxBuf[6];
    

    which I believe is equivalent to

    serialRxBuf[3] * 256 ^ (3 + serialRxBuf[4]) * 256 ^ (2 + serialRxBuf[5]) * 256 ^ (1 + serialRxBuf[6]);
    

    The code is most certainly not multiplying [3] by '256 to the power of 3', etc.

    I think the right code would be

    serialRxBuf[5] * 256 + serialRxBuf[6];
    

    based on page 7 of http://www.jdscompany.co.kr/download.asp?gubun=07&filename=PM1006_LED_PARTICLE_SENSOR_MODULE_SPECIFICATIONS.pdf

    opened by Habbie 12
  • UART levels 5V / 3.3V

    UART levels 5V / 3.3V

    You write in your readme "ESP8266 is 5V-tolerant, this should there shouldn't be any issues". This is not true of course. Anything aboce 3.6V can damage the pins.

    Since the UART level of an PM1006 is I do expect issues with burning pins on the ESP8266.

    Maybe the IKEA board has a level shifter? Did you find one?

    opened by bertmelis 9
  • Temperature and Humidity

    Temperature and Humidity

    Hello,

    First of all, awesome project. I didn’t even know that IKEA has an Air Quality sensor. Some might would think that they would fit inside their Air purifier first a sensor like this...

    Anyhow, have you thought of adding a Temperature and Humidity sensor into the device to give a full range of environmental details? Like a DTH22 or AM2302. Is there enough space to fir that as well?

    Best Regards,

    Gábor

    opened by GSzabados 8
  • Crash after first reading is received

    Crash after first reading is received

    Thanks for this excellent work!

    I tried to replicate but after receiving the first reading, the system crashes. A side-effect of this is that the Wifi Config is lost and you have to reconfigure it, making debugging a bit of a pain :)

    The serial log looks like this:

    IP: 192.168.1.239
    -- Current GPIO Configuration --
    PIN_UART_RX: 4
    Receiving:................................................................Receiving:....................Done.
    Received PM 2.5 reading: 6
    
    --------------- CUT HERE FOR EXCEPTION DECODER ---------------
    
    Exception (0):
    epc1=0x40201673 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
    
    >>>stack>>>
    
    ctx: cont
    sp: 3ffffdc0 end: 3fffffc0 offset: 0190
    3fffff50:  3ffef6a8 3ffef9a4 00000004 40201673  
    3fffff60:  40217c3d 0000000f 00000000 00000000  
    3fffff70:  3ffef6a8 3ffef720 3ffef1c0 402037cc  
    3fffff80:  00000000 00000000 00000001 3ffefb34  
    3fffff90:  3fffdad0 00000000 3ffefb20 40203800  
    3fffffa0:  3fffdad0 00000000 3ffefb20 40217640  
    3fffffb0:  feefeffe feefeffe 3ffe862c 4010156d  
    <<<stack<<<
    
    --------------- CUT HERE FOR EXCEPTION DECODER ---------------
    

    I've decoded the exception to be

    Exception 0: Illegal instruction
    PC: 0x40201673
    EXCVADDR: 0x00000000
    
    Decoding stack results
    0x40217c3d: __delay(unsigned long) at /Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.1/cores/esp8266/core_esp8266_wiring.cpp line 55
    0x402037cc: handleUart() at /Users/user/Downloads/esp8266-vindriktning-particle-sensor-master/src/esp8266-vindriktning-particle-sensor/serialCommunication.ino line 81
    0x40203800: loop() at /Users/user/Downloads/esp8266-vindriktning-particle-sensor-master/src/esp8266-vindriktning-particle-sensor/esp8266-vindriktning-particle-sensor.ino line 142
    0x40217640: loop_wrapper() at /Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.1/cores/esp8266/core_esp8266_main.cpp line 201
    

    (using a D1 Mini Pro) Any ideas what's going wrong?

    opened by joelhaasnoot 7
  • Many readings of zero, leading to few messages

    Many readings of zero, leading to few messages

    Great work on this mod, thanks @Hypfer!

    I've now tried it with two sensors. One works flawlessly, reporting regularly over MQTT. The other is quiet for long periods of time, only occasionally reporting a reading. Over serial, I see that many of the measurements are zero (and the code won't publish unless the average reading is greater than zero).

    At first I thought it was either a dead sensor, or a hardware issue with my mod. But if I hold a match next to the sensor, the light changes to yellow and red, and the reported numbers increase. MQTT messages are then sent until the smoke dissipates, the sensor returns to green, and the numbers reduce to zero again.

    So what's going wrong? Bad sensor? Acceptable calibration differences between sensors, which need to be handled differently in the code? With a sample size of 2, I don't have enough to go on.

    For now, I'm going to remove the "don't publish if zero" line in the code, set the two devices next to each other, and set-up logging of the MQTT messages to see if this sheds any light on the behavior.

    opened by brev-dev 5
  • get no values from sensor

    get no values from sensor

    Hi all,

    after install and successful upload to wemos i can see messages in MQTT Explorer but no values ... i just see:

    {
      "device": {
        "identifiers": [
          "VINDRIKTNING-49ED42"
        ],
        "manufacturer": "Ikea",
        "model": "VINDRIKTNING",
        "name": "VINDRIKTNING-49ED42",
        "sw_version": "2021.08.0"
      },
      "availability_topic": "esp8266-vindriktning-particle-sensor/VINDRIKTNING-49ED42/status",
      "state_topic": "esp8266-vindriktning-particle-sensor/VINDRIKTNING-49ED42/state",
      "name": "VINDRIKTNING-49ED42 PM 2.5",
      "unit_of_measurement": "μg/m³",
      "value_template": "{{value_json.pm25}}",
      "unique_id": "VINDRIKTNING-49ED42_pm25",
      "icon": "mdi:air-filter"
    }
    

    i would expect to see some values in "value_template" and not "{{value_json.pm25}}"... i would say i solder correctly on the board ... also i tested with PIN_UART_RX = 5 in SerialCom.h but the same output ... is my wemos maybe brocken ? any ideea?

    Thanks .... GREAT IDEEA :-)

    opened by caveman2003 4
  • Potential problem with running the fan at 3.3V?

    Potential problem with running the fan at 3.3V?

    I think there may be an issue with running the fan at 3.3V. At 5V the fan will push a certain CFM for certain amount of time. At 3.3V the fan will push much less CFM for that time. The sensor unit counts the number of particles that are pushed though it in that time. Net result, the sensor will see many less particles (due to less volume of air passing through it) and will under report the air quality.

    opened by Leeev 4
  • Cleanup and restructure code and fix bug

    Cleanup and restructure code and fix bug

    This also fixes a lot of compiler errors I got when trying to compile with visual studio code and Arduino plugin.

    For me these code changes also have the following effect on binary sizes: Before:

    Executable segment sizes:
    ICACHE : 32768           - flash instruction cache 
    IROM   : 364784          - code in flash         (default or ICACHE_FLASH_ATTR) 
    IRAM   : 29373   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 
    DATA   : 1580  )         - initialized variables (global, static) in RAM/HEAP 
    RODATA : 2736  ) / 81920 - constants             (global, static) in RAM/HEAP 
    BSS    : 31944 )         - zeroed variables      (global, static) in RAM/HEAP 
    

    After refactoring:

    Executable segment sizes:
    ICACHE : 32768           - flash instruction cache
    IROM   : 364832          - code in flash         (default or ICACHE_FLASH_ATTR)
    IRAM   : 29373   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...)
    DATA   : 1580  )         - initialized variables (global, static) in RAM/HEAP
    RODATA : 2824  ) / 81920 - constants             (global, static) in RAM/HEAP
    BSS    : 31936 )         - zeroed variables      (global, static) in RAM/HEAP
    
    opened by enwi 3
  • Not an issue but a suggestion: Merge into Esphome?

    Not an issue but a suggestion: Merge into Esphome?

    Hi, would it be possible to get this device supported into esphome? I think it would fit quite good as a supported sensor and you would get all the other stuff esphome supports as a bonus.

    opened by oopsitsaflame 3
  • Possible improvement: sample size of 7

    Possible improvement: sample size of 7

    My sensor works in bursts of 7 samples with +/- 2 seconds in between, followed by a 10 seconds pause.

    does this differ from yours? is there a reason you use an average of 5 samples?

    opened by bertmelis 2
  • Question about wiring points

    Question about wiring points

    The photo you have of the wired up test points, you seem to have the data wire connected to the test point labelled 'REST'. Just confirming that this is correct. Isn't REST a reset line of some kind, and the far left test point labelled ISPDA the data test point? Or is the board labelling incorrect. Don't have a scope so can't really check myself...

    opened by wizbowes 2
  • Include details on building the firmware with ESPHome

    Include details on building the firmware with ESPHome

    a pull request was made to esphome to simplify building the firmware for a device like this (reading the sensor data as it comes in). Making use of this is pretty simple to do as well, so why not include an example in the readme on making use of that feature.

    opened by AeroSteveO 0
  • Embarrasingly stuck

    Embarrasingly stuck

    So I set up an MQTT broker and linked it to Home Assistant, and I soldered the board in and flashed it, and ran the config from its ad-hoc network... now what? I'm seeing the device on my router but I don't know what to do next, none of the guides on MQTT broker stuff seem to explain what to do, if I should just expect it to work? I tried inputting the address of my MQTT broke both with and without port number and I don't really know what the heck to do. Do i need to broadcast a topic? What even is a topic? Should I have set something in the code before flashing it?

    My apologies for ranting but this is has turned out to be a really poor example of a first time MQTT project 😅

    opened by Nukle0n 3
  • Web interface problem

    Web interface problem

    hello, first of all thanks for your development. the installation went smoothly, the sensor works fine, but the web interface is not available, when I want to change the setting, I cannot reach anywhere. I completely deleted the esp card, I reinstalled it many times, but the problem was not solved, what can I do?

    opened by burakcankose 1
  • The value does not fall below 200

    The value does not fall below 200

    Not sure how to fix incorrect display values? He's been showing me 200-260 for some time. And it will never go down. I also tried to vacuum and it didn't help.

    opened by tiimsvk 4
Owner
Sören Beye
Views, opinions, conclusions and other information should be understood as neither given nor endorsed by this person.
Sören Beye
RPI Pico WIFI via ESP-01S, LWESP, FreeRTOS, and MQTT example

RPIPicoRTOSMQTT RPI Pico WIFI via ESP-01S, LWESP, FreeRTOS, and MQTT example Demo code for RPI Pico using ESP-01S for wifi connection over uart. With

Dr Jon Durrant 2 Dec 2, 2021
WiFi Attack + Recon Suite for the ESP8266 WiFi Nugget

Nugget-Invader Welcome to the Nugget Invader repository! The Invader is a WiFi attack suite developed for the WiFi Nugget, an ESP8266 based platform d

HakCat 33 Sep 27, 2022
A project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server.

PS4 Server 9.00 This is a project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server. this is fo

null 13 Sep 7, 2022
WiFi/MQTT Code For the ThingPulse ESPGateway

ESP32-Paxcounter with ThingPulse ESPGateway This project lets you run the ESP32-Paxcounter project on the ThingPulse ESPGateway. The ESPGateway has tw

Daniel Eichhorn 6 Aug 13, 2022
An MQTT-based Virtual Wall for ESP8266 Devices and Gerber files to make the IR hat; this code and board can easily be adapted to be ANY infrared controller/remote!

Roomba-Virtual-Wall-ESP8266-MQTT An MQTT-based Virtual Wall for ESP8266 Devices I made this based off of the IRSend, IRremoteESP8266, and EspMQTTClien

null 8 Sep 20, 2021
Alternative firmware for IKEA ORSALA lamp

orsala_hack Alternative firmware for IKEA ORSALA lamp (https://www.ikea.com/de/de/p/orsala-arbeitsleuchte-led-dimmbar-weiss-00482904/) but why? The OR

null 51 Jun 5, 2022
ESPHome component for Ikea Idasen desk control

This component creates a bluetooth bridge for an Ikea Idasen desk that uses a Linak controller with ESPHome and an ESP32 device. Cover integration Lin

Julien 121 Sep 15, 2022
Control Hörmann doors drives directly via MQTT from Home Assistant

hoermann_door Control Hörmann doors drives directly via MQTT from Home Assistant

null 59 Sep 21, 2022
ESP8266 WiFi Connection manager with fallback web configuration portal

ESP8266 WiFi Connection manager with fallback web configuration portal

null 5.4k Sep 30, 2022
A simple and easy WiFi-enabled ESP8266-powered WSPR and FT8 beacon which uses NTP + DS3231 RTC for timing.

Easy-Digital-Beacons-v1 A simple and easy WiFi-enabled ESP8266-powered WSPR and FT8 beacon which uses NTP + DS3231 RTC for timing. The whole design is

Dhiru Kholia 31 Sep 22, 2022
ESP8266 powered Xilinx Virtual Cable - Xilinx WiFi JTAG!

Xilinx Virtual Cable Server for ESP8266 Overview ESP8266 implementation of XVC (Xilinx Virtual Cable) protocol based on xvcd

Dhiru Kholia 7 Sep 30, 2022
Гирлянда на адресных светодидоах и esp8266, управление по WiFi

GyverTwink Гирлянда на адресных светодидоах и esp8266, управление по WiFi Обновления Прошивка 1.1 – исправлена калибровка больше 255 светодиодов 1.2 –

Alex 44 Aug 19, 2022
Wifi hacking tool using ESP8266 ( Evil-Twin method )

ZiFi Wifi hacking tool using ESP8266 ( Evil-Twin method ) FEATURES : [+] Deauth [+] Evil-Twin [+] User Interface TESTED ON : Nodemcu Probably will wor

Z4N 51 Sep 26, 2022
WiFi-enabled soil moisture sensor

w-parasite w-parasite is an open source, WiFi-enabled soil moisture sensor for house plants. This repo contains all the hardware design files (schemat

null 126 Sep 26, 2022
Decode SA air msg with openairinterface and lmssdr

openairinterface_lmssdr Decode SA air msg with openairinterface and lmssdr Openairinterface_lmssdr is a free and open-source project for SA cell air m

null 3 Mar 30, 2022
Upload arbitrary data via Apple's Find My network.

Send My allows you to to upload abritrary data from devices without an internet connection by (ab)using Apple's Find My network. The data is broadcasted via Bluetooth Low Energy and forwarded by nearby Apple devices.

Positive Security 1.5k Sep 27, 2022
Redirect esp-idf logging to the network

esp-idf-net-logging Redirect esp-idf logging to the network. esp-idf has a Logging library. The Logging library contains the "esp_log_set_vprintf" fun

null 9 Aug 30, 2022
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Cesanta Software 8.8k Sep 28, 2022
A portable MQTT C client for embedded systems and PCs alike.

MQTT-C is an MQTT v3.1.1 client written in C. MQTT is a lightweight publisher-subscriber-based messaging protocol that is commonly used in IoT and net

Liam Bindle 540 Sep 30, 2022