RAK4630 hanging after reading battery voltage

Hi,
I am trying to add the ability to get the battery voltage to the Tracker example. My intention is to add it to the radio payload so that I can monitor it at the ‘centre’.
To achieve this I have taken bits of the battery example and added them to my code.
At the moment I am just displaying the battery voltage in the serial monitor.

It initially appears to be working OK. Everything initialises and it starts the main loop - reads the accelerometer data and displays it; reads the voltage and displays it; reads the gps data and displays.
But it then just hangs.

If I comment out just the part that reads the voltage (below) it works normally.

// Get a raw ADC reading =======================================
// float vbat_mv = readVBAT();

// Serial.print(“LIPO = “);
// Serial.print(vbat_mv);
// Serial.println(” mV”);
//==============================================================

Thanks
Alan

Hi @Alangward ,

Can you share your could so we can have a look?

Sure, but is there a way I can send you a file rather than paste into here?

sure. you can send it to my email [email protected]

I got your code.

You just want the voltage values to show on the serial terminal right?

Put this code

float vbat_mv = readVBAT();

Serial.print(“LIPO = “);
Serial.print(vbat_mv);
Serial.println(” mV”);

in void loop() function instead on the tx handler.

You can add delay on your void loop() too so that you’ll not bombard your serial output.

Hi Carl,
My target is to include the battery voltage in the transmitted data.
I am just displaying it in the serial output as part of my testing.

Alan

BTW. I just noticed this:

Would I be better using this?
I’m new to the Arduino environment and I notice that the source files are .cpp rather than .ino.
Also that there several source files. Would I compile them separately? If so, how do I link them? Is there something I can read?

Thanks

Both example will work fine.

If you’ll proceed the default example, just make vbat_mv a global variable so you can access it to tx handler function then send it as LoRa packet.

You can use the LPWAN tracker of @beegee as well. The advantage of his code is the low power provision :wink:

I would like to try that example, but how do I compile it? And link it?

Thanks
Alan

Oh. You need to Platform IO on that.

OK.

Thanks for your help.

In case you need Platform IO guide - RAKwireless Documentation Center

Then you can build @beegee 's example and upload to wisblock board.

Sorry for jumping in here.
The RAK4631-LPWAN-Tracker can be compiled in Arduino IDE as well.

  1. from the project copy all files (*.cpp and *.h) from the folder src into a new folder, e.g. C:/LPWAN-Tracker
  2. goto the new folder
  3. rename main.cpp to LPWAN-Tracker.ino (name must be the same as folder name)
  4. open LPWAN-Tracker.ino with Arduino IDE.
  5. Choose RAK4631 board
  6. start compiling.
1 Like

Already found it and in the process of installing it.

Thanks again

Hi Carl
Sorry to be a pain. but I have hit a road-block.

This is from the install instructions:

Download the PlatformIO folder from:

Copy the file wiscore_rak4631.json to the boards folder of the nordicnrf52 platform folder.

The path should be similar to:

Windows: %USER%\.platformio\platforms\nordicnrf52\boards
Linux:    ~/.platformio/platforms/nordicnrf52/boards
Mac OS:  /Users/{Your_User_id}/.platformio/platforms/nordicnrf52/boards

Then, create a new project in PlatformIO:

I don’t understand how to do the copy above.

Alan

Sorry. Just understood it!!!

1 Like