Startup time of arduino pro mini with mysensors 2.2 - took 10 sec (guess its the radio), can I execute some code immediately (<1sec)?
-
@rozpruwacz This is the way it was constructed. I plan to leave them on all time, maybe remove / replace them in the future - however if somebody uses the switches the lights should go on instantly, basically by set analogWrite( LED_PIN,255); like a normal switch.
Any way to do so?
@alterfritz
Try to add the "on" command not in setup() (this requires presetation() to be already passed) and use a before()-routine instead. -
So I would rather make it in hardware. pull-up resistor on the switching transistor will make it on at the powerup. and I would store the last dimm value into eeprom to not wait for the gateway response because you will not make it response in less that 1s - the protocol just not allow for that.
-
So I would rather make it in hardware. pull-up resistor on the switching transistor will make it on at the powerup. and I would store the last dimm value into eeprom to not wait for the gateway response because you will not make it response in less that 1s - the protocol just not allow for that.
@rozpruwacz Exactly. This is why the "on" should be issued in before() (or something like hwInit()).
"before()" is executed before any MySensors-specific communication.... -
In addition to the other advices you're already receiving, and following your suspicion that the delay might be related to the radio, you could try adding the following defines to your sketch:
#define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC #define MY_TRANSPORT_MAX_TX_FAILURES 3The first two avoid the node from having to search for it.
The last one might help you determine if the problem is the radio not starting correctly if the time is reduced after you add it.
Let us know how it goes.
-
yes, so in the before() function read the eeprom value and set it in analogWrite. hardware pull-up is optional because the delay between switching power on and before function call will be short enough, bit if You use the pull-up the delay will be even shorter.
-
@alterfritz
Try to add the "on" command not in setup() (this requires presetation() to be already passed) and use a before()-routine instead.@rejoe2 like this... btw - this forum is fanastic... responses more or less in real time... :-)
...
void presentation()
{
analogWrite( LED_PIN,255);}
.... -
@rejoe2 like this... btw - this forum is fanastic... responses more or less in real time... :-)
...
void presentation()
{
analogWrite( LED_PIN,255);}
....sorry ... mean before ...like this
void before()
{
analogWrite( LED_PIN,255);}
This seems to have done the trick... LED switch on immediately! Thanks!
Btw... I also try the mysbootloader. This wirless update is great, however - does this bootloader slows down bootup time?
-
yes, because the code that will run in the node must be first uploaded to it. the bootup time will be dependent on the code size.
-
@alterfritz Yes, update-bootloader tries to connect to GW for updates first seconds (around 20). So it is not dependend on code size...
Additional note: Waiting for RF connection to be established can also be prevented by using#define MY_TRANSPORT_WAIT_READY_MS ... -
@alterfritz Yes, update-bootloader tries to connect to GW for updates first seconds (around 20). So it is not dependend on code size...
Additional note: Waiting for RF connection to be established can also be prevented by using#define MY_TRANSPORT_WAIT_READY_MS ...So
#define MY_TRANSPORT_WAIT_READY_MS 1000
Will wait for 1 sec? -
So
#define MY_TRANSPORT_WAIT_READY_MS 1000
Will wait for 1 sec?@alterfritz Exactly. After trying to connect to the controller for 1 sec., the node will execute normal code like any other "just-arduino".
Pls note: as there is no connection to the controller, the node may miss relevant info typically provided by the controller. Things like myControllerConfig, last values for counters etc... If you use this, you should make sure, these are set correctly later on. -
So - thanks for all your help. Great forum. Let me summarize what I understand so far:
1.) by using the before() procedbure I can execute immediately. Quickly tested. Seems perfect for me... however... :-)
2.) I really like this mysbootloader. But by using this it always takes up around 20 sec to boot up. There is NO way to switch on my LED directly when I power it up...Correct?
-
So - thanks for all your help. Great forum. Let me summarize what I understand so far:
1.) by using the before() procedbure I can execute immediately. Quickly tested. Seems perfect for me... however... :-)
2.) I really like this mysbootloader. But by using this it always takes up around 20 sec to boot up. There is NO way to switch on my LED directly when I power it up...Correct?
@alterfritz Speaking about software: Not exactly, there is one thing you could still do: Compile the bootloader yourself with light switched on... :grinning:
-
@alterfritz Speaking about software: Not exactly, there is one thing you could still do: Compile the bootloader yourself with light switched on... :grinning:
@rejoe2 Right... :-) I may look into this. For now I will try to get a stable version and load it without bootloader directly via usbasp...