delayed startup for mysens-features



  • hi,

    i want to build an mqtt controlled led dimmer (4 cannel).
    so i have an mysens mqtt gateway which is 24/7 running.

    now i build an actor node wich controls the led´s and has an mysens connection.
    (in my case an arduino-nano with an nrf24 & pca9685)

    BUT...
    the actor will only be powered if the light is switched on.

    • lightswitch -> ac power to powersupply -> dc power to arduino -> arduino boots up...

    so i cant wait till mysens is registered to the gateay till the led´s will be powered.
    (in my cas this is an delay about 4s)

    i will flash the arduino without bootloader and an feature that i can register the node at the gateway delayed. after the led are up-dimming after power on.

    the connetion to mqtt (over mysens) will only be used to dimm the led´s not for switching on or off.

    so i need an bit to start the init procedure for the mysens features.

    thanks
    easy


  • Mod

    @easy welcome to the MySensors community!

    I think you can use the same strategy as the Rotary coder dimmer example. It stores the last dimmer value in eeprom, and reads the value at startup.

    Edit: I noticed that the example does not set the dimming level at startup though. You'll need to modify setup() to set the LED dimmer to the right value after the value has been fetched from EEPROM.



  • thanks, but sorry that is not what i want...

    in my light controlers the led´s will fade to the ON value. (for examble 0-60% in 0,7 seconds)
    (..or fade to any new changed value..)
    for this fading i need time. at start i need loop for ca. 0,7s.

    actualy i found an dity way...

    in the lib-file "MySensorsCore.cpp" i found this:

    // Call sketch setup() (if defined)
    if (setup) {
    	CORE_DEBUG(PSTR("MCO:BGN:STP\n"));	// setup callback
    	setup();
    }
    

    and changed to this:

    // Call sketch setup() (if defined)
    //if (setup) {
    	CORE_DEBUG(PSTR("MCO:BGN:STP\n"));	// setup callback
    	setup();
    //}
    

    aditional i put the fade on for the led´s to the setup() void.
    into an while-loop wich is controlled by the millis() value.
    after an time 1,5s i set an variable and the setup() will be jumped over for next call.

    after this the mysensors can connect.
    and then the leds can be controlled over mqtt.

    can some one tell me an clean way, without changing the lib´s ?

    thanks
    easy


  • Mod

    @easy I see. I think putting your code in before() will do what you want.



  • great, this it was where i looking for.
    thanks


 

255
Online

7.8k
Users

8.7k
Topics

93.0k
Posts