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.