mtdshare:
This delay is only for testing, it does work aswell without it (in the loop function).
I already tried to add a large delay (10 seconds) to the setup function but nothing changed.
Do you know if the call to radio.write() works the first time in loop()? Maybe it is only working because it is being called more than once.
Otherwise I can't see why it would work in loop() and not in setup(). Maybe you could put a short FOR loop inn setup() that calls radio.write() a few times. And why not check that it has actually transmitted properly?
Of course the problem might also lie in the receiver code which we have not seen.
I want to register to my receiver (sending an id) and I want to do this only once.
There are ways of doing this without putting it in setup().
Create a boolean variable and set it to false. Run the required code you want in loop() only when the variable is false. When you run the code set the boolean to true to prevent it running again.
Robin2:
Do you know if the call to radio.write() works the first time in loop()? Maybe it is only working because it is being called more than once.
Otherwise I can't see why it would work in loop() and not in setup(). Maybe you could put a short FOR loop inn setup() that calls radio.write() a few times. And why not check that it has actually transmitted properly?
Of course the problem might also lie in the receiver code which we have not seen.
...R
Thank you for your answer. I now put a for loop in the setup and it really sends all values except the first one.
In this case i received 4 values and not 5.
Do you got an idea why this happens?
UKHeliBob:
There are ways of doing this without putting it in setup().
Create a boolean variable and set it to false. Run the required code you want in loop() only when the variable is false. When you run the code set the boolean to true to prevent it running again.
I think this could be a workaround. I will try if this works stable.
But anyway it would be interesting why we could not send the first value in the setup function.
Robin2:
That is wrong. At the receiver end all you can do is check if they are received correctly.
I meant that you should have code in your Tx program to check if the Tx works.
Is the receiver powered up before the transmitter?
...R
The receiver is always powered up before the transmitter.
I tried a few things again and noticed that the first transmission only fails if i remove the power from the tx unit and give it back again. The rx unit stays powered on at this time.
If i restart the rx unit the first message is received normally again.
If i add "radio.setAutoAck(false);" all transmissions are working always properly.
But i need to use the autoAck feature.
If the first transmission is not reliable then just ignore it and always send the first message twice.
If that might cause confusion you could include a '1' in the first message sent and a '2' in the second message. That way the receiver can tell which one it has received even if they are otherwise the same.