Announcement

Collapse
No announcement yet.

Flashing LED Counter

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Flashing LED Counter

    Looking for some help. I have a Qooker tap which occasionally requires resetting. When this happens the LED flashes about 45 times in 60 seconds. I want to use a TSL2561 light sensor to read the flashes and reset the tap using a zwave wall plug. My issue is, using an NodeMCU, I can read the changes in the light values, but can anyone help with the code to count the flashes in 60 seconds? Is there a better way?

    Cheers
    Scott

  • #2
    Cracked it - Using Arduino plugin in API mode and getting all the heavy lifting done on the NodeMCU, I now have an LED monitor working. I can say now that I really hate Arduino and C/C++ code

    Comment


    • #3
      Dude it would be really really cool of you to share the sketch.......

      Comment


      • #4
        OK. The script here samples the light level every second (1000ms) and reports the low to high transitions each time round the loop. Every 5 minutes (300 seconds) the code sends the transition counts to HS3

        I'm looking for a flashing LED which changes flash rate and 1 second sampling works for me, you may need to change the sampling rate and maybe the reporting interval. I also have the code update HS3 with the lux level each time round the loop just for temporary monitoring to get a feel for the reported light levels - I will remove this once I'm happy with the details. I don't know what effect reporting data to a virtual device in more than 1 second intervals would have on the efficient working of HS3 itself!

        Attached are the three parts you need in the Arduino API. I have left in my debugging Serial,print code in but rem'd out.

        You can change the sampling time at "unsigned long interval=1000;"

        Change the reporting time at "(lapcount == 300){"

        Change the "high" value at

        if (lux > 300)
        {state = "high";}
        else
        {state = "low";}


        Plan will be to replace these values with vars to make it simple to manage.

        The code is cut down from the SparkFun TSL2561 Example which you will get when you install the lib

        If anyone uses this, let me know how you get on!


        Cheers
        Scott
        Attached Files

        Comment

        Working...
        X