RAK4631 - GPS Tracker Example

I have a hopefully a quick question with regards to the RAK4631->Solutions->GPS_Tracker example. The example has an RAK1906 3-axis acceleration sensor. This code works well, but I was wanting to add and additional I2C sensor RAK16000 to add voltage and current date to the LoRa packet. Unfortuntly, I ran into an issue when trying to integrate the example code for the RAK16000 into the GPS_Tracker code i.e. when I entered the following code info the “void tx_lora_periodic_handler(void)” function, the program papered to hang went trying to execute serial print with sensor value.

Serial.print("Shunt Voltage [mV]: "); Serial.println(shuntVoltage_mV);
Serial.print("Bus Voltage [V]: "); Serial.println(busVoltage_V);
Serial.print("Load Voltage [V]: "); Serial.println(loadVoltage_V);
Serial.print("Current[mA]: "); Serial.println(current_mA);
Serial.print("Bus Power [mW]: "); Serial.println(power_mW);

if I delete all serial print sensor value commands and convert values to string and then perform serial print (see code below) code works fine.

data = “shuntVoltage_mV = " + String(shuntVoltage_mV) + “mV”
+ " loadVoltage_V = " + String(loadVoltage_V) + “V”
+ " busVoltage_V =” + String(busVoltage_V) + “V”
+ " current_mA =" + String(current_mA) + “mA”
+ " power_mW =" + String(power_mW) + “mW”;

I also tried to create my own function to read in the sensor values and call this within the “void tx_lora_periodic_handler(void)” function, but the call to my function didn’t work. I have a similar issue if I try to call my function within the “void loop()” function.

Is anyone able to explain why I cannot perform serial print sensor value command and/or create and call a function from within “void tx_lora_periodic_handler(void)” function?

If required I can provide the full code.

Any help would be appreciated.

Kind Regards

Hi Greg,

The examples codes are kept as simple as possible and have their flaws when you try to extend them.

Most likely what is happening here is the same as what happened to Charles => RAK4630 LoRa halts on LoRa TX when more than 12 bytes in packet - #9

The reading from the RAK1910 is done from the timer interrupt routine. That works fine as long as the code is not getting to lengthy.
You can try the changes I proposed there (use a flag and process the data from the loop() instead.

Or you can have a look into the LPWAN-Tracker-Solution which is a complete event and interrupt driven tracker solution that is better for battery consumption, as the MCU is kept in low power mode unless it is necessary to do something.

Thank you for you suggestions Beegee. I will have a look at the LPWAN tracker and topic referred to in you comment.

Kind regards