Combine actuator sketch with a sensor sketch (controlling blinds + reporting light level)



  • Hi all

    What is the best way to combine an actuator sketch with an sensor when I want the sensor to report only occasionally and not in every loop? 🙂

    I've built a servo actuator (modified sketch due to an override button), and I want to add a light-sensor (BHI750) to make my blinds report the lux from the outside so that my controller can decide whether to open or close the blinds.


  • Hardware Contributor

    One simple way is just to check millis() versus the last time you sent sensor data. If it's greater than the time you want to report, then read the sensor and send the information.



  • ah, thanks 🙂
    But now I've got a new challenge:
    I've made my sensor/actuator listen for commands (dimmer->servoposition) and send a light-level value every X seconds.

    However, the lux value is now received as subtype DIMMMER, even if the sketch declares a presentation for subtype LIGHT_LEVEL at startup.
    My sketch also contains a button for servo control (if i press it shortly, it'll toggle 0/100 and if i hold it, it'll "dim" the servo until i release the button).
    Any ideas on how to separate these two childs? - I've ofcourse defined one child value each for the servo and the light-sensor.



  • Figured it out! 🙂
    Note to self: remember to make sure that each child has its own msg() 🔤 🙂



  • Been trying to combine servo and light sensor, but running into a few kinks with the sketch. Any chance you could post your finished work? Thanks in advance.
    -Patrick


Log in to reply
 

Suggested Topics

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts