What is the good wait() time ?
-
when it's for presentation, it's not really a big deal to add such wait time. note for a a coincell batt powered node it would be better to use sleep..
But in others application with some "critical" timing in user tasks, you could get some troubles like missing state changes, slower polling etc. as it doesn't make your sketch asynchronous..
For longterm, I think it's not ideal to use such hack when getting comm issues. and also makes nodes slower (and perhaps jamming's easier too ?).
-
Hello,
i have a node with 3 push-button in loop().
without wait() , i don't receive messages from gateway.
With wait(50) i receive message (but not all).
with wait(500) i receive nothing.
Is it normal ? I thought that wait() was for spending time for receive message. larger time should be larger time for receiving messages ?
what is the ideal waiting time ?
THnaks@tommies You could give message queueing a try:
- Connect the nRF24 IRQ pin to pin 2 on your Arduino
- add #define MY_RF24_IRQ_PIN (2)
- add #define MY_RX_MESSAGE_BUFFER_FEATURE
- add #define MY_RX_MESSAGE_BUFFER_SIZE (10)
- that last value may be lower (e.g. 5) when running out of memory
This will listen to the interrupt from the nRF24 when a message comes in and immediately pause the running code to retrieve the message.
Then your code continues and any messages stored will be processed outside the loop() function automatically.
The wait() call(s) can be removed from your code.
It might interfere with your NeoPixel update though, but there's only one way to find out ;-)Refer to e.g. https://forum.mysensors.org/topic/7190/irq-pin-for-nrf24l01 for a discussion on message queueing.
-
@scalz I add the wait to make sure the radio has enough power without having to resort to adding a capacitor.
-
@scalz I add the wait to make sure the radio has enough power without having to resort to adding a capacitor.
@alowhum said in What is the good wait() time ?:
@scalz I add the wait to make sure the radio has enough power without having to resort to adding a capacitor.
I already got it. But it seems you have a "design flaw", it's treating symptoms instead of root.. So it's not a great tip.
For very simple case like a temperature sensor, it might seem handy and work, but not for all usercases, like I said, you add latency to your nodes.I prefer Yveaux advice. And if it's not enough:
- hardware flaws
- library bug..
I also agree with mfalkvidd. If you don't want to tweak/solder stuff on any hw, then you might get troubles, or poor range when using different power supplies sources (noisy, etc) and wait() will be ineffective.
-
@tommies You could give message queueing a try:
- Connect the nRF24 IRQ pin to pin 2 on your Arduino
- add #define MY_RF24_IRQ_PIN (2)
- add #define MY_RX_MESSAGE_BUFFER_FEATURE
- add #define MY_RX_MESSAGE_BUFFER_SIZE (10)
- that last value may be lower (e.g. 5) when running out of memory
This will listen to the interrupt from the nRF24 when a message comes in and immediately pause the running code to retrieve the message.
Then your code continues and any messages stored will be processed outside the loop() function automatically.
The wait() call(s) can be removed from your code.
It might interfere with your NeoPixel update though, but there's only one way to find out ;-)Refer to e.g. https://forum.mysensors.org/topic/7190/irq-pin-for-nrf24l01 for a discussion on message queueing.
-
I already use PIN2 and/or PIN3 as wake up interrupt to wake up node in sleeping sensors.
Is there any way to use interrupt in non sleeping node ?
By the way, it would avoid to use loop fonction to detect push button change state. -
@scalz Interesting. But in reality I do see that adding a delay results in fewer NACK issues. What could that be?
I also always place my radios in the Nano Wireless Board, which solves pretty much all the issues with power and wiring I had before.