How can I program the rak 4631 to reboot every 4 hours?

I have had connectivity issues with helium and I have found that I can solve this issue by restarting the rak every so many hours. How can I set the 4631 to loop a reboot every 4 hours in my code?

Rebooting every 4 hours is a temporary fix and might not be good for the network since you always have to rejoin. Regarding your concern, you can have a variable that tracks time then issue a software reset NVIC_SystemReset();.

It is still best to know why you suddenly cant uplink data to the Helium network. Are you far from the Helium hotspot? Is the hotspot always online?

Not sure. Here locally can only get a few packets before it fails. Up in a different city it works for a day or so and then fails to connect and never is able to rejoin and this area has great coverage. If there a way I can debug why this is happening or something I can print for more info to figure out why this happens?

Hmm. If I am in your case, I will probably scan first the area for the health of network/connectivity. Like monitor/log the RSSI and SNR your device each time it sends data to the network. You can do this by integrating Helium to some platform like Datacake, Ubidots, etc. You can have a graph/plot and if your RSSI/SNR levels are steady, changing a lot or already marginal. You can also do this manual by writing down the readings you see in Helium Console.

If you are still testing your device, you can setup your gateway there in your place and forget the Helium at the moment. But if your device is good now, the next step is to ensure that you have good network coverage like I said above. The helium explorer might be a good indicator for coverage but these hotspots are not really optimized for witnessing devices but witnessing other hotspots because they are rewarded that way. So it is still better to get data on your own.

I have the gateway in my place ttn for testing works great. But ultimately this is getting sent up to somewhere else and is meant to be ran on the helium network and will be next to a strong node connection up there. But even up there after a day it disconnects so idk what’s going on. My helium node is in my apartment. I’m like 15-40 feet from it when im testing and it fails after a few packets every time. It’s the only near node in my area tho but where im sending it there are nodes even multiple at every hex and it still loses connection after a day

Is the ADR on your WisBlock code enabled?

You can check the ADR setting on this line:


If it is on, you will see LORAWAN_ADR_ON. Let’s have an experiment and turn if off via changing it to LORAWAN_ADR_OFF in your code.

Then, also change the DR to DR1. The line of code that sets your DR is here.


Make the DR_3 to DR_1.

Run again your device and see if we will have improvement.

Still ended up disconnecting after a few hours unfortunately. So they system reset function is built in already and I just need to to import a time library at the end on a loop to make that work?

Remove reset. It should be NVIC_SystemReset();

I implemented a separate loop that resets, this appears to be resetting the lcd on my code but isn’t resetting the device to join the network

  m_lora_app_data.buffer[i++] = (uint8_t)t;
  m_lora_app_data.buffer[i++] = (uint8_t)(h >> 8);
  m_lora_app_data.buffer[i++] = (uint8_t)h;
  m_lora_app_data.buffer[i++] = (uint8_t)((pre & 0xFF000000) >> 24);
  m_lora_app_data.buffer[i++] = (uint8_t)((pre & 0x00FF0000) >> 16);
  m_lora_app_data.buffer[i++] = (uint8_t)((pre & 0x0000FF00) >> 8);
  m_lora_app_data.buffer[i++] = (uint8_t)(pre & 0x000000FF);
  m_lora_app_data.buffer[i++] = (uint8_t)((gas & 0xFF000000) >> 24);
  m_lora_app_data.buffer[i++] = (uint8_t)((gas & 0x00FF0000) >> 16);
  m_lora_app_data.buffer[i++] = (uint8_t)((gas & 0x0000FF00) >> 8);
  m_lora_app_data.buffer[i++] = (uint8_t)(gas & 0x000000FF);
  m_lora_app_data.buffer[i++] = (mph100 >> 8) & 0xFF;
  m_lora_app_data.buffer[i++] = mph100 & 0x00FF;
  m_lora_app_data.buffsize = i;

void yo()

Where do you call the yo() function? You said that the LCD resets. Do you mean it starts again on the very beginning of the execution but didn’t rejoin(or fail to rejoin)?

Right I have an lcd attached and that seems to be resetting every so many seconds but it doesn’t seem to be making the device rejoin the network and send packets it just keeps sending packets. I need it to reset so that it makes it rejoin so when I set this thing up way out in the middle of no where it will auto reconnect when it messes up. I just have the function at the bottom of the script in that yo function

If the LCD routine resets and did not rejoin, I am not sure how can that be possible since there is only one MCU running and the LCD routine and LoRaWAN routine is running in a common core. Regardless if it is in an RTOS, if the device resets, it should reset complete the whole routine.

For anyone that’s reading this in the future. If you need a timer that can reset your rak automatically you can setup a variable using modulus math to count the loops timer

int iterations = 1; //loop iterations timer!!!
Put this outside of your void loop ^ Then put this code in your void loop

  iterations += 1;
if ( iterations % 9000 == 8999 ) { //Make the value to the right one less eg 10 == 9

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.