Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Detecting a sudden change

Detecting a sudden change

Scheduled Pinned Locked Moved Development
4 Posts 3 Posters 59 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ร Offline
    ร Offline
    รอเรือ
    wrote on last edited by
    #1

    Hello all!

    I'm building a PM2.5 particle matter sensor and I'm trying to figure out how I would go about to detect sudden changes of measured particles occurs.

    I expect that there is a background level of particle matters that vary very slowly maybe between 0 and 20 µg/m3. I'd want to be alerted if that level rises all off a sudden. That happens frequently here when the flue gases from my neighbors chimney flows towards the ground level and enters my mechanical ventilation intake. I'd like the alert to be active until "normal" levels have been reached and a new alert if it happens again after that.

    I'm putting my question here in hope that you might happen to know a "software design pattern" some reusable solution for a similar problem. I have seen a Lua Script for Humidity control that does a similar thing but a c++ code snippet to be inspired by would make things easier.

    Do you have any idea about how this should be done clean and beautifully?

    Thanks in advance. Cheers!

    skywatchS YveauxY 2 Replies Last reply
    0
    • ร รอเรือ

      Hello all!

      I'm building a PM2.5 particle matter sensor and I'm trying to figure out how I would go about to detect sudden changes of measured particles occurs.

      I expect that there is a background level of particle matters that vary very slowly maybe between 0 and 20 µg/m3. I'd want to be alerted if that level rises all off a sudden. That happens frequently here when the flue gases from my neighbors chimney flows towards the ground level and enters my mechanical ventilation intake. I'd like the alert to be active until "normal" levels have been reached and a new alert if it happens again after that.

      I'm putting my question here in hope that you might happen to know a "software design pattern" some reusable solution for a similar problem. I have seen a Lua Script for Humidity control that does a similar thing but a c++ code snippet to be inspired by would make things easier.

      Do you have any idea about how this should be done clean and beautifully?

      Thanks in advance. Cheers!

      skywatchS Offline
      skywatchS Offline
      skywatch
      wrote on last edited by skywatch
      #2

      @รอเร-อ It all depends on what sensor you are using.

      I am using 2 different sensors and I can tell you that there is a wide variation throught the day. If I shower in the en-suite shower the bedroom sensor shows this. If I use a wok to stir fry then all the 'dust' sensors pick up the tine droplets of hot oil that circulate in the air.

      Background levels here are under 60uG/m3 on the first floor, about 90ug/M3 on ground floor and 0-9 ppm of ppm25 and 0-6ppm of ppm10.

      For your use a better suited sensor would be worth finding as optical sensors will react to moisture as well as dust. Perhaps in the end you will need a combination of sensors? I hope this helps you think of a solution.

      As for detecting a sudden change then you just need to remember the last reading and compare it to the new reading. If the difference is more than your chosen value then you have an alert state!

      1 Reply Last reply
      1
      • ร รอเรือ

        Hello all!

        I'm building a PM2.5 particle matter sensor and I'm trying to figure out how I would go about to detect sudden changes of measured particles occurs.

        I expect that there is a background level of particle matters that vary very slowly maybe between 0 and 20 µg/m3. I'd want to be alerted if that level rises all off a sudden. That happens frequently here when the flue gases from my neighbors chimney flows towards the ground level and enters my mechanical ventilation intake. I'd like the alert to be active until "normal" levels have been reached and a new alert if it happens again after that.

        I'm putting my question here in hope that you might happen to know a "software design pattern" some reusable solution for a similar problem. I have seen a Lua Script for Humidity control that does a similar thing but a c++ code snippet to be inspired by would make things easier.

        Do you have any idea about how this should be done clean and beautifully?

        Thanks in advance. Cheers!

        YveauxY Offline
        YveauxY Offline
        Yveaux
        Mod
        wrote on last edited by
        #3

        @รอเร-อ you probably want to filter spikes in the sensor readings to prevent reacting on outliers.
        I understand your sensor is located outside. Here is an example over 2 days from my pm sensor also located outside:
        Screenshot_20210524-091925_Chrome.jpg
        I would try a long, slow filter window to establish a baseline value, and a short, fast filter window to react on changes relatively quickly. Then when the slow filtered value differs more than x from the fast filtered value you need to stop the intake of fresh air.
        Search for "exponential moving average" to implement such filters.

        Btw. I only read a pm value once a minute or so. If filtering using a few values the response will be in the order of a few minutes at best.

        http://yveaux.blogspot.nl

        ร 1 Reply Last reply
        1
        • YveauxY Yveaux

          @รอเร-อ you probably want to filter spikes in the sensor readings to prevent reacting on outliers.
          I understand your sensor is located outside. Here is an example over 2 days from my pm sensor also located outside:
          Screenshot_20210524-091925_Chrome.jpg
          I would try a long, slow filter window to establish a baseline value, and a short, fast filter window to react on changes relatively quickly. Then when the slow filtered value differs more than x from the fast filtered value you need to stop the intake of fresh air.
          Search for "exponential moving average" to implement such filters.

          Btw. I only read a pm value once a minute or so. If filtering using a few values the response will be in the order of a few minutes at best.

          ร Offline
          ร Offline
          รอเรือ
          wrote on last edited by
          #4

          @Yveaux Thanks!

          Nice graph. I will do something similar in Grafana. I think my MySensors device should also report every minute, perhaps using the highest sampled value. All values are sent to MQTT by my gateway and my Home Automation will store the time value pairs in influxdb. Right now I'm waiting for the hardware to arrive... :grinning:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          12

          Online

          11.7k

          Users

          11.2k

          Topics

          113.0k

          Posts


          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular