RAK5010 custom code examples not working

Issue: Examples for the WisTrio Cellular RAK5010 Board not working

Setup: Arduino with RUI3 v4.0.0.0

Details: I compiled the various examples for the WisTrio Cellular RAK5010 Board, then flashed the resulting image to the RAK5010 and couldn’t get any serial communication with the board. I could then re-flash the latest firmware, and the module worked again. Something is wrong with the examples or the board definition.

Hi @antoine ,

Can you share what example sketch you are trying to run so I can help you check?

Sure. Lets start with the simplest of all.


#ifndef rak5010
#error "Please select WisTrio Cellular RAK5010 Board and compile again"
#endif

int get_sensor(SERIAL_PORT port, char *cmd, stParam * param)
{
   // SHTC3
    if (sensor.shtc3.update()) {
        Serial.println("SHTC3:");
        Serial.printf("Temperature = %.2f。C\r\n", sensor.shtc3.temperature());
        Serial.printf("Humidity = %.2f%%\r\n", sensor.shtc3.humidity());
        Serial.println("---------------------------------------------------");
    } else {
        Serial.println("SHTC3 update fail!");
    }

    // LPS22HB
    Serial.println("LPS2X:");
    Serial.printf("Pressure = %.2f hPa\r\n", sensor.lps22hb.pressure()); 
    Serial.println("---------------------------------------------------");

    // OPT3001
    if (sensor.opt3001.update()) {
        Serial.println("OPT3001:");
        Serial.printf("Light = %.2f lux\r\n", sensor.opt3001.lux());
        Serial.println("---------------------------------------------------");
    } else {
        Serial.println("OPT3001 update fail!");
    }

    // LIS2DH
    if (sensor.lis3dh.update()) {
        Serial.println("LIS3DH:");
        Serial.printf("The X  acceleration = %.2f\r\n", sensor.lis3dh.x());
        Serial.printf("The Y  acceleration = %.2f\r\n", sensor.lis3dh.y());
        Serial.printf("The Z  acceleration = %.2f\r\n", sensor.lis3dh.z());
        Serial.println("===================================================");
    } else {
        Serial.println("LIS3DH update fail!");
    }
  return AT_OK;
}

void setup()
{
    Serial.begin(115200);

    Serial.println("RAKwireless RAK5010 Example");
    Serial.println("------------------------------------------------------");

    // begin for I2C
    Wire.begin();

    api.system.atMode.add("SENSOR", "This get sensor data.",
      "SENSOR", get_sensor);
}

void loop()
{
}

I have another observation. I am working on windows with Arduino 1.8.19.

I decided to give it a try on my Linux machine, and the RAK5010 board is not available in the board manager. I also checked the RAK3172 which I also use, and its also not available on Linux.

Maybe Arduino is not the preferred way to develop custom code for these boards?

Hi @antoine ,

I suggest to try first the basic sensor example.


#ifndef rak5010
#error "Please select WisTrio Cellular RAK5010 Board and compile again"
#endif


void setup()
{
    Serial.begin(115200);

    Serial.println("RAKwireless RAK5010 Example");
    Serial.println("------------------------------------------------------");

    // begin for I2C
    Wire.begin();

    Serial.printf("SHTC3 init %s\r\n", sensor.shtc3.init() ? "Success" : "Fail");
    Serial.printf("LPS22HB init %s\r\n", sensor.lps22hb.init() ? "Success" : "Fail");
    Serial.printf("OPT3001 init %s\r\n", sensor.opt3001.init() ? "Success" : "Fail");
    Serial.printf("LIS3DH init %s\r\n", sensor.lis3dh.init() ? "Success" : "Fail");
}

void loop()
{
    // SHTC3
    if (sensor.shtc3.update()) {
        Serial.println("SHTC3:");
        Serial.printf("Temperature = %.2f。C\r\n", sensor.shtc3.temperature());
        Serial.printf("Humidity = %.2f%%\r\n", sensor.shtc3.humidity());
        Serial.println("---------------------------------------------------");
    } else {
        Serial.println("SHTC3 update fail!");
    }

    // LPS22HB
    Serial.println("LPS2X:");
    Serial.printf("Pressure = %.2f hPa\r\n", sensor.lps22hb.pressure()); 
    Serial.println("---------------------------------------------------");

    // OPT3001
    if (sensor.opt3001.update()) {
        Serial.println("OPT3001:");
        Serial.printf("Light = %.2f lux\r\n", sensor.opt3001.lux());
        Serial.println("---------------------------------------------------");
    } else {
        Serial.println("OPT3001 update fail!");
    }

    // LIS2DH
    if (sensor.lis3dh.update()) {
        Serial.println("LIS3DH:");
        Serial.printf("The X  acceleration = %.2f\r\n", sensor.lis3dh.x());
        Serial.printf("The Y  acceleration = %.2f\r\n", sensor.lis3dh.y());
        Serial.printf("The Z  acceleration = %.2f\r\n", sensor.lis3dh.z());
        Serial.println("===================================================");
    } else {
        Serial.println("LIS3DH update fail!");
    }

    delay(5000);
}

This should be able to show you the readings of the sensor like this:

Then as I look on your code, it seems you want to add it as custom AT command. Is that the outcome you need?

Regarding the Arduino on Linux, there could be some issues that is exclusive to that specific distro.

I have limited experience on using Arduino on linux but it works well on windows and macos.

Btw, I avoid the Arduino IDE 2.0.x (at the moment) since it is not as stable/reliable than the legacy 1.8.x yet.

Thanks for the reply. Concerning the example, can you tell me how you compile the hex?

On my side, I am using Arduino 1.8.19 on windows, with the “RAKwireless RUI nRF Boards” v4.0.0. I compile the program, and the move the hex to my Raspberry Pi and program it using OpenOCD (same way I program the latest firmware earlier). Once this is done, the RAK5010 does not have a COM port and I can’t see any serial output.

If you tell me exactly how you proceed and which versions of the tools you run, I’ll try following your steps. There is probably something wrong in the Arduino board definition?

Thanks.

Hi @antoine ,

Thanks for providing the details. On creating the custom firmware using RUI3 API with Arduino IDE, you must use the uploader provided by the BSP. This will use the .bin file and not the .hex. I haven’t tried uploading generated firmware via OpenOCD. I strongly suggest to use Arduino IDE on uploading the custom firmware.

I am using Windows 11, Arduino 1.8.19 and RUI3 BSP version 4.0.0 on my previous test above.

Maybe I am missing something here. When I try to upload the custom firmware using Arduino, I get errors: "Serial: Device is either not in bootloader mode, or using an unsupported bootloader.
" followed by many “Serial: No Response: 0x45”.

I am using windows 11, Ardfuino 1.8.19, with the RAKwireless RUI nRF Boards version 4.0.1.

I selected the board “WisTrio Cellular RAK5010”, and then press “Upload” in Arduino.

Am I missing any step?

Hi @antoine ,

I am not sure if you already uploaded this HEX firmware for rak5010 using openOCD. Can you confirm? This should allow you to send AT commands to RAK5010. If AT commands are successful, you should now be able to send custom firmware via Arduino.

Thanks. That worked.

It seems the problem is that I had the wrong firmware. I was using the one referenced in the main documentation: https://downloads.rakwireless.com/en/Cellular/RAK5010/Firmware/RAK5010-M_Latest_Firmware.zip (RAK5010M_20210225020725.hex)

I am now able to program the device with Arduino.

Thanks for the help.

Hi Carlrowan,
I have a RAK5010 and trying to do some customisation.
I just follow the steps provided here and end up getting the following errors.

2023-09-15 13:00:43,010 Serial: No ping response
Traceback (most recent call last):
File “nordicsemi/main.py”, line 1545, in
File “click/core.py”, line 1137, in call
File “click/core.py”, line 1062, in main
File “click/core.py”, line 1668, in invoke
File “click/core.py”, line 1668, in invoke
File “click/core.py”, line 1404, in invoke
File “click/core.py”, line 763, in invoke
File “nordicsemi/main.py”, line 1063, in serial
File “nordicsemi/main.py”, line 980, in do_serial
File “nordicsemi/dfu/dfu.py”, line 127, in dfu_send_images
File “nordicsemi/dfu/dfu.py”, line 88, in dfu_send_image
File “nordicsemi/dfu/dfu_transport_serial.py”, line 214, in open
pc_ble_driver_py.exceptions.NordicSemiException: No ping response after opening COM port
[44142] Failed to execute script ‘main’ due to unhandled exception!
CompletedProcess(args=[’/Users/aruns/Library/Arduino15/packages/rak_rui/tools/pc-nrfutil/v6.1.3/nrfutil’, ‘-v’, ‘-v’, ‘-v’, ‘dfu’, ‘serial’, ‘–package’, '/var/folders/z
/bk_vrvw939j2wp4g4fpfkcjr0000gn/T/arduino_build_685304/sketch_sep15b.ino.zip’, ‘-p’, ‘/dev/cu.Bluetooth-Incoming-Port’, ‘-b’, ‘115200’], returncode=1)

Is there anything I am missing out.

Thanks in Advance. :slight_smile:

Hi @SArun ,

Can you confirm if you can send at commands to RAK5010? If not, maybe something got wrong on uploading the RUI3 hex firmware?

Hi Carlrowan,
I am having RAK5010, hence I flashed the device with RAK5010_dfu_20210223065027.zip using nRF workflow Upgrading Firmware through DFU using BLE
Then, tried with at commands and it worked fine.
But Arduino code change couldn’t be pushed.
Do we need JTAG to be connected with the device for DFU to happen?
Thanks.

Hi @SArun ,

If you want to use Arduino IDE for RAK5010, you can use RUI3 or Adafruit’s BSP.

I shared here the RUI3 firmware that Antoine use. Please upload this one.