Can't upload without errors RAK4631

It worked for a few uploads, then it would only upload if it was in DFU mode, and now I cant even upload the blinking LED light example script. I read the errors but I don’t understand what it means. For example: Undefined reference to a package. - Well the package is installed and you didn’t have a problem with it before…

Undefined reference to serial. - That’s not helpful…

Can’t communicate to COM port. - Why not? Nothing else is using it?

I don’t want to spam this post with errors. What can I do to solve this mess?

RAK 4631, Windows 10, Using Arduno Wisblock 4631 board.

Welcome to the forum @Turbow5

If you plug in the RAK4631 to the USB port, does it give you a sound and does it assign a COM port to it?
You can check in the Device Manager if a new COM port is showing up.

Do you see the COM port in ArduinoIDE and did you select that COM port before downloading?

If you double push the reset button while the board is plugged in, do you get a new drive called RAK4631

image

Did you change USB cables?
Did you try different USB ports?

It is assigned a COM port. In fact I’ve changed it as a test to it saying the port was busy. I currently have it on 8. If it DFU mode is COM5. When it DFU mode, file explorer does pop up with those 3 files as shown in your screenshot.

I have tried different USB cables and USB ports. From the motherboard to a USB hub that plugs into a pcie. I’ve even given the hail-Mary full PC restart.

The device behaves as expected.

At this point, with all the weird errors you are getting, I can only guess that something is messed up with the Arduino installation.
Try to uninstall everything install from scratch.

So I uninstalled it, deleted the libraries, then installed the portable version, and I’m back to this (screenshot). Where it says upload successful, but at the same time says cant access the COM port. And the board isn’t blinking at all.

Edit: I just noticed the screenshot says it uploaded to com6 and not 8, so I plugged the 4631 back in, and now it’s not even showing up under device manager (but does have a solid red light) . But now it’s making a sound of… a high pitch then low pitch, repeating. So I double tap the button, goes into DFU mode, I see it on COM5, try to upload a different script, thinking maybe what I posted was wrong. Still got that error of failed to open COM.

Wrong board selection:

image

The correct board to be used with RAK4631:

image

Requires to install the correct BSP, as shown in our guide

I have no explanation for the serial port error message.

so I’ve used the Adafruit and Wisblock for testing, and it doesn’t get rid of any error. I’ve changed the code, used the simple examples that come with Arduino, but it’s stuck. Is there a way to tell if the board is faulty/locked up?

Double push reset button to get into UF2 bootloader mode.
Copy the UF2 file from the attached ZIP file into the new external drive RAK4631
Check USB log output after reset of the device.

WB_HW_Test_V1.1.9_H.zip (282.9 KB)

The app is a hardware tester application. It will show on the USB log output information if any major problems were found.

Copy the UF2 file from the ZIP? There’s a .dat, .bin, and a JSON. but no UF2?.. Please explain.

Sorry wrong ZIP file. Use this
WB_HW_Test_V1.1.9_H.uf2.zip (186.5 KB)

I can’t even get it on there. It tries to copy over but the RAK goes out of bootlaoder mode and then the boards flashing green and blue lights. Almost like a siren.

Perfect!
You flashed the firmware successfully.

Now check the output on USB

Ok I can see it getting a GPS fix and TX over LoRa. Cool. So I tried to upload my own script and it said upload successful, but then got that message of “was unable to get success message from com”. Maybe it’s the code I’m uploading?

Maybe you can share your code here as “text”.
I am too lazy to type everything from your screenshot to try it.

I’d love to but txt is not an option, and new users can’t upload docx, and there’s no option for ZIP…So…I’ll paste it here. (this pasted really clean. if I knew this I would have pasted here sooner)

#include <LoRaWan-RAK4630.h>
#include <SPI.h>

#define RF_FREQUENCY            915000000  // 915 MHz
#define TX_OUTPUT_POWER         14         // dBm
#define LORA_BANDWIDTH          4          // 500 kHz
#define LORA_SPREADING_FACTOR   7
#define LORA_CODINGRATE         1          // 4/5
#define LORA_PREAMBLE_LENGTH    8
#define LORA_SYMBOL_TIMEOUT     0
#define LORA_FIX_LENGTH_PAYLOAD_ON false

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

  Serial.println("Starting LoRa P2P GPS Simulation...");

  if (lora_rak4630_init() != 0) {
    Serial.println("LoRa init failed!");
    while (1);
  }

  Serial.println("LoRa init successful.");

  Radio.SetTxConfig(
    MODEM_LORA,
    TX_OUTPUT_POWER,
    0,
    LORA_BANDWIDTH,
    LORA_SPREADING_FACTOR,
    LORA_CODINGRATE,
    LORA_PREAMBLE_LENGTH,
    LORA_FIX_LENGTH_PAYLOAD_ON,
    true, 0, 0, 0, 3000
  );

  Radio.SetChannel(RF_FREQUENCY);
  Serial.println("LoRa TX configured.");
}

void loop() {
  const char* fixedPayload = "id=dog1&lat=47.000000&lon=-101.000000";

  uint8_t buffer[64];
  size_t len = strlen(fixedPayload);
  if (len > sizeof(buffer)) len = sizeof(buffer);
  memcpy(buffer, fixedPayload, len);

  Serial.print("Sending: ");
  Serial.println(fixedPayload);

  Radio.Send(buffer, len);

  delay(200);    // Allow time for TX to complete
  delay(5000);   // 5 second interval
}

You are missing a few essential things in your code.

(1) No event callbacks, they are needed to handle RX/TX/CAD/… events of the LoRa transceiver
(2) You skipped the radio initialization

Here is a working version of your code:

#include <LoRaWan-RAK4630.h>
#include <SPI.h>

// Structure for RadioEvents
static RadioEvents_t RadioEvents;

// Function declarations
void OnTxDone(void);
void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr);
void OnTxTimeout(void);
void OnRxTimeout(void);
void OnRxError(void);
void OnCadDone(bool cadResult);

#define RF_FREQUENCY 915000000 // 915 MHz
#define TX_OUTPUT_POWER 14	   // dBm
#define LORA_BANDWIDTH 4	   // 500 kHz
#define LORA_SPREADING_FACTOR 7
#define LORA_CODINGRATE 1 // 4/5
#define LORA_PREAMBLE_LENGTH 8
#define LORA_SYMBOL_TIMEOUT 0
#define LORA_FIX_LENGTH_PAYLOAD_ON false

void setup()
{
	pinMode(LED_GREEN, OUTPUT);
	digitalWrite(LED_GREEN, LOW);

	Serial.begin(115200);
	time_t serial_timeout = millis();
	// On nRF52840 the USB serial is not available immediately
	while (!Serial)
	{
		if ((millis() - serial_timeout) < 5000)
		{
			delay(100);
			digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
		}
		else
		{
			break;
		}
	}

	Serial.println("Starting LoRa P2P GPS Simulation...");

	if (lora_rak4630_init() != 0)
	{
		Serial.println("LoRa init failed!");
		while (1)
			;
	}

	Serial.println("LoRa init successful.");

	// Initialize the Radio callbacks
	RadioEvents.TxDone = OnTxDone;
	RadioEvents.RxDone = OnRxDone;
	RadioEvents.TxTimeout = OnTxTimeout;
	RadioEvents.RxTimeout = OnRxTimeout;
	RadioEvents.RxError = OnRxError;
	RadioEvents.CadDone = OnCadDone;

	// Initialize the Radio
	Radio.Init(&RadioEvents);

	// Set radio to sleep for next setup
	Radio.Sleep();

	Radio.SetTxConfig(
		MODEM_LORA,
		TX_OUTPUT_POWER,
		0,
		LORA_BANDWIDTH,
		LORA_SPREADING_FACTOR,
		LORA_CODINGRATE,
		LORA_PREAMBLE_LENGTH,
		LORA_FIX_LENGTH_PAYLOAD_ON,
		true, 0, 0, 0, 3000);

	Radio.SetChannel(RF_FREQUENCY);
	Serial.println("LoRa TX configured.");
}

void loop()
{
	const char *fixedPayload = "id=dog1&lat=47.000000&lon=-101.000000";

	uint8_t buffer[64];
	size_t len = strlen(fixedPayload);
	if (len > sizeof(buffer))
		len = sizeof(buffer);
	memcpy(buffer, fixedPayload, len);

	Serial.print("Sending: ");
	Serial.println(fixedPayload);

	Radio.Send(buffer, len);

	delay(200);	 // Allow time for TX to complete
	delay(5000); // 5 second interval
}

/**@brief Function to be executed on Radio Tx Done event
 */
void OnTxDone(void)
{
	Serial.println("OnTxDone CB");
}

/**@brief Function to be executed on Radio Rx Done event
 */
void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{
	Serial.println("OnRxDone CB");
}

/**@brief Function to be executed on Radio Tx Timeout event
 */
void OnTxTimeout(void)
{
	Serial.println("OnTxTimeout CB");
}

/**@brief Function to be executed on Radio Rx Timeout event
 */
void OnRxTimeout(void)
{
	Serial.println("OnRxTimeout CB");
}

/**@brief Function to be executed on Radio Rx Error event
 */
void OnRxError(void)
{
	Serial.println("OnRxError CB");
}

/**@brief Function to be executed on CAD Done event
 */
void OnCadDone(bool cadResult)
{
	Serial.println("OnCadDone CB");
}

So great news, After flashing it, and trying your code, I’ve been able to upload to the 4631 flawlessly. And I’ve been trying my own scripts with it and it continues to work flawlessly. As far as what was causing the COM/serial output issues, I don’t know. But I’m glad it works now!

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