Repeater node crashes
-
@rejoe2 Thank you for your reply.
I seemed to have read that for a repeater it was necessary to replace delay () by wait (). . .
I will adapt my program according to your recommendations and keep you informed.@mimaret could you post the debug output from before and during the crash?
What you're doing should work. The debug output usually gives useful info on why things don't work the way they are supposed to.Also, check the power problem flowchart on the page @rejoe2 linked earlier. PA_MAX puts very high stress on the power supply. My guess is that this is related to insufficient power stability.
-
@mfalkvidd Thank you for your reply.
I do not think about power problem. The power supply can deliver 1A and I mounted a capacitor of 470 uF on the 3.3v and a 47 uF close to the radio module. I had doubts about hardware and I set up a second repeater.
On the first repeater, radio module nrf24L01 + PA + LNA. On the second repeater, radio module nrf24L01 +. Same problem.
When the repeater crashes, the interrupt is executed again. The led pin 13 that I do not manage is ON during normal operation and goes OFF when the repeater crashes.
I noticed that by disabling the interrupt (// attachInterrupt (....), the repeater does not crash.
I will look how to check the state of memory, stack, etc.
I also include the debug output and I do not see anything particular. -
OOPS :
19820560 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 19820560 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 19825700 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 19826745 !TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=NACK:0 ------> Door 19826745 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=OK:0 19826747 TSF:MSG:READ,255-255-255,s=255,c=7,t=255,pt=7,l=25,sg=1: 0 19826755 !TSF:MSG:LEN,7!=32 ------> readDHT 20105310 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:42.4 H: 42.40 ------> read1Wire 20105426 ------> readDHT 20405309 TSF:MSG:SEND,111-111-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:21.8 T: 21.80 20405323 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:42.1 H: 42.10 ------> read1Wire 20405440 20700045 TSF:SAN:OK ------> readDHT 20705310 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:41.9 H: 41.90 ------> read1Wire 20705427 ------> Door 20707352 !TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=NACK:1 ------> Door 20707352 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=OK:0 ------> Door 20723965 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 20725862 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 20725862 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 <------------------------------------CRASH----------------- ------> Door 20729143 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 20730232 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 20730232 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 -
OOPS :
19820560 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 19820560 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 19825700 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 19826745 !TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=NACK:0 ------> Door 19826745 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=OK:0 19826747 TSF:MSG:READ,255-255-255,s=255,c=7,t=255,pt=7,l=25,sg=1: 0 19826755 !TSF:MSG:LEN,7!=32 ------> readDHT 20105310 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:42.4 H: 42.40 ------> read1Wire 20105426 ------> readDHT 20405309 TSF:MSG:SEND,111-111-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:21.8 T: 21.80 20405323 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:42.1 H: 42.10 ------> read1Wire 20405440 20700045 TSF:SAN:OK ------> readDHT 20705310 TSF:MSG:SEND,111-111-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:41.9 H: 41.90 ------> read1Wire 20705427 ------> Door 20707352 !TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=NACK:1 ------> Door 20707352 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=OK:0 ------> Door 20723965 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 20725862 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 20725862 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 <------------------------------------CRASH----------------- ------> Door 20729143 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1 ------> Door 20730232 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 ------> Door 20730232 TSF:MSG:SEND,111-111-0-0,s=2,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0 -
In fact, the node no longer executes the program and the only solution is to restart it with a reset or switch off the power supply.
-
There is no restart. Only the interrupt executes when I open the door contact. The Loop () does not continue. I did not cut anything, I just added the crash line as soon as the program stopped.
@mimaret thanks for explaining.
I think the problem lies in calling send from within the interrupt handler. Interrupt handlers are supposed to execute very quickly. Usually they just set a flag that there is work to be done, and return.
From https://learn.adafruit.com/multi-tasking-the-arduino-part-2/interrupt-etiquette
Code in the ISR should not call anything that requires interrupts to be active (e.g. delay() or anything that uses the i2c bus). This will result in hanging your program.
From the debug output, send fails. That means the node must have tried to send, waited for acknowledgement until timeout, tried to send again and waited and so on until the max number of attempts is reached. That's way too much time to spend inside an interrupt handler. And the radio use
Try to only set a variable inside the interrupt handler, and perform the send from inside loop instead.
-
A big thank you for your contribution. I modified the program according to your proposals. Everything is working. I am attaching you the pieces of code relating to the door contact.
My problem is solved.. . . attachInterrupt(digitalPinToInterrupt(DOOR_PIN), DoorMoving, CHANGE); DoorChange = 1; LastDoor = 0; } void DoorMoving() { DoorChange = 1; } void readDoor() { if (DoorChange) { boolean Door = (digitalRead(DOOR_PIN)); if (Door != LastDoor) { send(msgDoor.set((Door) == HIGH ? 1 : 0)); LastDoor = Door; DoorChange = 0; } } } . . . void loop() { unsigned long currentMillis = millis(); readDoor(); if (currentMillis - previousMillis >= UPDATE_INTERVAL) { previousMillis = currentMillis; readDHT(); read1Wire(); } } -
A big thank you for your contribution. I modified the program according to your proposals. Everything is working. I am attaching you the pieces of code relating to the door contact.
My problem is solved.. . . attachInterrupt(digitalPinToInterrupt(DOOR_PIN), DoorMoving, CHANGE); DoorChange = 1; LastDoor = 0; } void DoorMoving() { DoorChange = 1; } void readDoor() { if (DoorChange) { boolean Door = (digitalRead(DOOR_PIN)); if (Door != LastDoor) { send(msgDoor.set((Door) == HIGH ? 1 : 0)); LastDoor = Door; DoorChange = 0; } } } . . . void loop() { unsigned long currentMillis = millis(); readDoor(); if (currentMillis - previousMillis >= UPDATE_INTERVAL) { previousMillis = currentMillis; readDHT(); read1Wire(); } }