reset arduino pro mini and nrf24l01

Hi

In my project i am using nrf24l01 for communication between two Arduino.

Transmitter part will be placed in the enclosure along with battery,

my question is what if communication between receiver and transmitter is lost or if there is any problem with transmitter so that we have to reset the transmitter device.

Enclosure will be sealed so that we cannot open.

Someone please suggest me some idea to reset the transmitter

The only way to reset an nRF24 is to disconnect and reconnect its power. For example it will not reset when you press the Arduino reset button.

You could arrange for power for the nRF24 to be switched by a transistor or relay that is controlled by the Arduino and with suitable code in your setup() function to trigger the transistor or relay.

Then the problem becomes one of how do you cause the Arduino to reset. My guess is the simplest thing is to use the Watchdog Timer although I have not used it myself.

You will need to think carefully about how the Arduino might know that the nRF24 is misbehaving even if the Arduino is functioning properly. I guess one way to do that is to count how many failed attempts there are to communicate with the master.

...R
Simple nRF24L01+ Tutorial

But why would you ever need to reset it? Connection is only lost when the devices are out of range, you corrupted the setting of they get out of sync (which is a problem of you writing a terrible protocol).

septillion:
But why would you ever need to reset it?

I agree that the need to do so is unlikely but I would not be prepared to build something that could not be reset (or reset itself).

...R

Robin2:
The only way to reset an nRF24 is to disconnect and reconnect its power. For example it will not reset when you press the Arduino reset button.

You could arrange for power for the nRF24 to be switched by a transistor or relay that is controlled by the Arduino and with suitable code in your setup() function to trigger the transistor or relay.

Then the problem becomes one of how do you cause the Arduino to reset. My guess is the simplest thing is to use the Watchdog Timer although I have not used it myself.

You will need to think carefully about how the Arduino might know that the nRF24 is misbehaving even if the Arduino is functioning properly. I guess one way to do that is to count how many failed attempts there are to communicate with the master.

...R
Simple nRF24L01+ Tutorial

I have made watchdog reset every 8 seconds. but in my case i will be using two transmitter and one receiver. after few days one device lost its connection then i pressed the reset button of arduino then transmitter got connected to receiver.

Now my plan is to put one tilt sensor between arduino reset pin and ground when box is inverted tilt sensor get active and reset pin will be made ground. will this procedure works?

bmg1234:
Now my plan is to put one tilt sensor between arduino reset pin and ground when box is inverted tilt sensor get active and reset pin will be made ground. will this procedure works?

Why not try it and let us know what happens? (It can't do any harm).

Have you carefully read the content of my Reply #1 ?

...R

That's one way to work around it. But I would go for the route of fixing the real problem aka the bug in your code :wink:

septillion:
That's one way to work around it. But I would go for the route of fixing the real problem aka the bug in your code :wink:

I thought the same but i didn't find any bug in the code.

could you please check both the transmitter and receiver code once if there is any bug

Here are my transmitter and receiver code. please find the attachment

Receivertwofinaltested.ino (6.88 KB)

transmitterfinaltested.ino (8.99 KB)

After a quick look:

You never check if 'pipe_num' is in range. Very easy to overflow things now.

if (currentMillis > (lastMilis[0] + 30000)) {

Always check millis() with subtraction, that way roll over isn't an issue:

if (currentMillis - lastMillis >= 30000)) {

But besides that I don't see obvious errors but It would take considerable more time to check everything.

septillion:
After a quick look:

You never check if 'pipe_num' is in range. Very easy to overflow things now.

if (currentMillis > (lastMilis[0] + 30000)) {

Always check millis() with subtraction, that way roll over isn't an issue:

if (currentMillis - lastMillis >= 30000)) {

But besides that I don't see obvious errors but It would take considerable more time to check everything.

if (currentMillis > (lastMilis[0] + 30000)) {
if (currentMillis - lastMillis >= 30000)) {

transmitter will send every 24 seconds once one data about bandgap so this section is to check if there is no data in 30 seconds then device will make some alert that data from transmitter is not received or connection lost.

Okay, but you have trouble with roll over if you do it with addition :wink:

I do note now I accidentally removed the array index though.

septillion:
Okay, but you have trouble with roll over if you do it with addition :wink:

I do note now I accidentally removed the array index though.

Do need to enable autoACK?

radio.setAutoAck(true);

bmg1234:
Do need to enable autoACK?

It should be on by default. Have you looked at the code in my Tutorial?

...R

Robin2:
It should be on by default. Have you looked at the code in my Tutorial?

...R

yes i did and doing similar to your tutorial.

but i am not using radio.enableAckPayload();

is it necessary to use? i didn't understand what this does. could you please explain me

bmg1234:
is it necessary to use? i didn’t understand what this does. could you please explain me

No, it is not neccessary.
It can be handy, even essential in special cases (like Serial via NRF with a decent baud rate).

It’s just a simple way to send preloaded* information attached to the ACK back to the sender,
without explicitly switching to send mode, or having to know which pipe the sender normally listens to.

It’s the difference between saying “I got your message” and
“I got your message, and here is a list of phone calls you missed”.

* If you want to enforce fresh data, just ask twice (with a send to an AckPayload pipe).

bmg1234:
but i am not using radio.enableAckPayload();

autoAck() is different from ackPayload() although the two can be combined.

In normal use when a message is sent the receiver sends and acknowledgement (autoAck) which lets the sender know that the message was received. If the sender does not receive the ack then it will make a number of retries in an attempt to send the message.

When someone decides to use ackPayload then the ackPayload data is combined with the autoAck as a convenient way of having bi-directional communication.

If you disable autoAck the sender has no means to know if a message was received.

The most likely situation where it would make sense to disable autoAck is when the sender sends a message to several receivers that are all listening on the same address. In that case if autoAck was enabled all the receivers would send an ack at the same time and the ack-message would be corrupted leading the sender to think it had not been received.

...R

Robin2:
autoAck() is different from ackPayload() although the two can be combined.

No can please, ackPayload needs autoAck
(and dynamicPayloads, but that will be set implicly IIRC).

Whandall:
No can please, ackPayload needs autoAck

Yes, but not vice versa.

And I think the phrase "can be combined" is correct - ackPayload combines data with autoAck. The phrase does not imply that ackPayload can be implemented without autoAck.

...R

Robin2:
And I think the phrase "can be combined" is correct - ackPayload combines data with autoAck.

I see a big difference between "can be combined" and "combines data with autoAck",
you're changing the goalpost. :wink:

"Can be combined" does not make clear that ackPayload is an extension of autoAck,
so "autoAck can be extended with ackPayload to include data" would be clearer IMHO.

If you want ackPayloads, there is no can for autoAck, only a must.

But it does not really matter, the library enforces autoAck (and dynamicPayloads IIRC) on AckPayload.

If the ingredients on a pizza "can be combined",
don't you think the information that you can get onions only if you also take tuna would be interesting?