Call a function on puck.light() change value

Posted on
  • Hello
    How would I go about calling a function when the level of ambient light changes?
    I want to predefine parameters and call a function if its within a certain range.
    Does it use much power to do puck.light() checks? If I just do setInterval to 1 second to check the value and if its outside a predefined level call a function - will it impact the battery much? Would prefer a neater way to do it if possible

  • Hi!

    I'm afraid you can't easily do the check 'in hardware' - it is possible to a very limited extent, but it's not very flexible.

    Checking Puck.light should be fine - every second it's not likely to have a massive effect on power consumption at all, although I wouldn't advise doing it much more often than that

  • thank you. I was going to use it as an alarm when someone opens my meterbox. But bluetooth advert will most likely be lost amongst other info that is sent

  • bluetooth advert will most likely be lost amongst other info that is sent

    What I usually suggest is you send a single byte that increments each time the event occurs - eg the box is opened. That way it doesn't matter if you miss a bunch of advertisements, you still know if that number has risen that something happened.

  • agree but dont want to be sending extra info. Like I don't really care in the evening that meterbox was opened some time during the day. Just means that I would have to add it to every advertisement
    Have to look at what happened to my puck - lost connectivity this morning. Only found out in the evening so don't know what happend

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Call a function on puck.light() change value

Posted by Avatar for user130485 @user130485

Actions