# Device resending activation and reset of counter problem

**URL:** <https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280>\
**Category:** LMIC\
**Created:** [November 12, 2020, 9:49am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280 "2020-11-12T09:49:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhvds](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jhvds/32/35697_2.png) [@jhvds](https://www.thethingsnetwork.org/forum/u/jhvds)\
**Post date:** [November 12, 2020, 9:49am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/1 "2020-11-12T09:49:04Z")

</div>

Can anybody explain what happens in the device communication depicted in the picture below?  
 ![device_2020-11-11c](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/f/6/f62214332af86bc3167dcf2bbe3a10c110313392.png)  
What causes this activation resending and resetting of the counter?  
The device (Arduino Pro-mini and RFM95) is using the LMIC library and LowPower sleep.  
The gateway (RAK831) data is depicted below:  
 ![gateway_2020-11-11](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/0/9/09583ec78d3d110b4d0da9e5e826ae33e82cc581.png)  
All tips are welcome to get me on the right track 🤔

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [November 12, 2020, 10:34am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/2 "2020-11-12T10:34:25Z")

</div>

The counter is reset on all OTAA joins.

Which LMIC library?  
Is there any chance your device is resetting when it sleeps?  
How close is it to your gateway?

---

<div class="post-metadata">

**Author:** ![jhvds](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jhvds/32/35697_2.png) [@jhvds](https://www.thethingsnetwork.org/forum/u/jhvds)\
**Post date:** [November 12, 2020, 10:40am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/3 "2020-11-12T10:40:28Z")

</div>

> [@descartes](#):
>
> Which LMIC library?  
> Is there any chance your device is resetting when it sleeps?  
> How close is it to your gateway?

MCCI LoRaWAN LMIC version 3.2.0.

Distance of device to gateway is more than 4 metres.

I will check if the device resets the counter while sleeping.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [November 12, 2020, 10:43am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/4 "2020-11-12T10:43:54Z")

</div>

> [@jhvds](#):
>
> I will check if the device resets the counter while sleeping.

The join resets the counter.

It’s if the sleep is so sleepy it loses the join info - usually discovered by watching the serial port.

---

<div class="post-metadata">

**Author:** ![jhvds](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jhvds/32/35697_2.png) [@jhvds](https://www.thethingsnetwork.org/forum/u/jhvds)\
**Post date:** [November 12, 2020, 10:58am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/5 "2020-11-12T10:58:43Z")

</div>

> [@descartes](#):
>
> The join resets the counter.
> 
> It’s if the sleep is so sleepy it loses the join info - usually discovered by watching the serial port.

```
> 11:41:10.878 -> Starting
> 11:41:10.947 -> In do_send with bLED is 0
> 11:41:10.947 -> Packet queued
> 11:41:10.947 -> 2834: EV_JOINING
> 11:41:14.655 -> 235996: EV_TXSTART
> 11:41:19.849 -> 557947: EV_JOINED
> 11:41:19.849 -> netid: 19
> 11:41:19.849 -> devaddr: 26012689
> 11:41:19.849 -> AppSKey: 81-XXXX
> 11:41:19.849 -> NwkSKey: 13-XXXX
> 11:41:19.849 -> 559923: EV_TXSTART
> 11:41:21.998 -> 694629: EV_TXCOMPLETE (includes waiting for RX windows)
> 11:41:22.303 -> Going to sleep...

```

What would you suggest to debug the problem situation according to the displayed serial port logging above?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [November 12, 2020, 11:03am UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/6 "2020-11-12T11:03:21Z")

</div>

Nothing, because there’s only one cycle and I’d want to see what happens after it wakes up …

Electrons are free, please post as a block quote as I’ve altered the above, a longer log.

---

<div class="post-metadata">

**Author:** ![jhvds](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jhvds/32/35697_2.png) [@jhvds](https://www.thethingsnetwork.org/forum/u/jhvds)\
**Post date:** [November 12, 2020, 2:11pm UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/7 "2020-11-12T14:11:37Z")

</div>

> 15:00:30.402 → Starting  
> 15:00:30.469 → Packet queued  
> 15:00:30.469 → 2833: EV\_JOINING  
> 15:00:30.469 → LMIC.seqnoUp: 0  
> 15:00:31.759 → 83270: EV\_TXSTART  
> 15:00:36.913 → 405215: EV\_JOINED  
> 15:00:36.913 → netid: 19  
> 15:00:36.913 → devaddr: 26015ACF  
> 15:00:36.913 → AppSKey: B9-XXXXX  
> 15:00:36.913 → NwkSKey: D3-XXXXX  
> 15:00:36.913 → LMIC.seqnoUp: 0  
> 15:00:36.947 → 407224: EV\_TXSTART  
> 15:00:39.092 → 541929: EV\_TXCOMPLETE (includes waiting for RX windows)  
> 15:00:39.400 → Going to sleep…  
> 15:02:05.483 → Awake again…  
> 15:02:05.788 → LMIC.seqnoUp: 1  
> 15:03:04.692 → 4293438: EV\_TXSTART  
> 15:03:04.692 → Packet queued  
> 15:03:06.834 → 4428153: EV\_TXCOMPLETE (includes waiting for RX windows)  
> 15:03:07.139 → Going to sleep…  
> 15:04:33.219 → Awake again…  
> 15:04:33.493 → LMIC.seqnoUp: 2  
> 15:05:32.421 → 8179671: EV\_TXSTART  
> 15:05:32.421 → Packet queued  
> 15:05:34.565 → 8314550: EV\_TXCOMPLETE (includes waiting for RX windows)  
> 15:05:34.872 → Going to sleep…  
> 15:07:00.924 → Awake again…  
> 15:07:01.194 → LMIC.seqnoUp: 3

It seems that the counter is not reset by the device during sleep.  
Might the problem be a timing issue?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [November 12, 2020, 2:43pm UTC](https://www.thethingsnetwork.org/forum/t/device-resending-activation-and-reset-of-counter-problem/41280/8 "2020-11-12T14:43:58Z")

</div>

> [@jhvds](#):
>
> It seems that the counter is not reset by the device during sleep.

That was never a question I asked, I said it was reset by the Join.

What was/is of interest is why it was rejoining. But it appears not to be in this transcript. Did anything else change?

For testing, can you reduce the size of the payload and send less often. A six byte payload can be sent every 149 seconds to stay within fair use policy. see [https://avbentem.github.io/airtime-calculator/ttn/eu868/2](https://avbentem.github.io/airtime-calculator/ttn/eu868/2) For testing, I have a push button so I can watch everything happening and not accidentally leave the thing banging away overnight (or a weekend)
