I’m at the blinky stage of working with the RAK modules in PlatformIO.
I got the LED going and was looking to provide debug output over USB serial.
Looking at the documentation, it does seem to indicate that is possible.
I added the Serial init code from the GPS example in the blink sketch and after adding some libraries in (adafruit/Adafruit TinyUSB Library, adafruit/Adafruit BusIO, Wire) it compiles and uploads OK.
But the PC does not show a serial port at all. Only when I double press the reset button I get the COM port to show (and can push code to it).
The blue LED is happily blinking away (as expected, so I think it runs OK)
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include <Arduino.h>
// https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Quickstart/#hardware-setup
// Pin names WB_*
// LED_*
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BLUE, OUTPUT);
// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BLUE, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BLUE, LOW);
// wait for a second
delay(1000);
Serial.print(".");
}
Some more progress Installed and configured Arduino IDE following this.
Picked the RAK 4361 example Read_Battery_level
Needed to install the Adafruit TinyUSB library (in the battery level sketch that uses no Serial)
Compile then fails because TinyUSB relies on Wire. Noticed in a comment that it recommended to install the nRF52_OLED library
Sketch now compiles and uploads (after double click puts it in upload mode)
On reboot the normal comport shows up!
Copied my code linked above into the Arduino IDE (replacing the battery code) and upload
On reboot the comport is still there! My code plots the expect dot every second
Go back to PlatformIO, try to replace the Wire library with beegee-tokyo/nRF52_OLED
Compile fails with
Compiling .pio\build\wiscore_rak4631\FrameworkArduino\HardwarePWM.cpp.o
In file included from .pio\libdeps\wiscore_rak4631\Adafruit BusIO/Adafruit_BusIO_Register.h:9:0,
from .pio\libdeps\wiscore_rak4631\Adafruit BusIO\Adafruit_BusIO_Register.cpp:1:
.pio\libdeps\wiscore_rak4631\Adafruit BusIO/Adafruit_I2CDevice.h:5:10: fatal error: Wire.h: No such file or directory
No real understanding of what is happening. But I can reproduce it. Does it have to do with the included Wire library being different between PlatformIO and the Arduino IDE?
Sort off, some files/directories might have been locked. The python script completed OK, but the files were never copied. I manually copied it and things are compiling again.
However, nothing has changed. Sketch runs fine (blinky), but no COM port shows up.
Go back to Arduino IDE, upload same sketch. Com port is back
I had the same problem compiling a “new project” or Blink example.
For reference, i am using the Arduino IDE 2.2.1
Admittedly, i was very perplexed and frustrated not being able to compile either of these projects!
Strangely, all the sensor examples and 4631 LORAWAN examples compiled.
I decided to add the includes the the working 4631 LORAWAN examples.
Their installation procedure has a few weaknesses in my eyes, in particular it blindly patches (read: copies their variant folder for the RAK4631) the framework-arduinoadafruitnrf52 package. However when looking at GitHub - RAKWireless/RAK-nRF52-Arduino at v1.3.3, they base their Arduino core off of the Adafruit nRF52 1.3.0 core with some patches. The latest nordicnrf52 platform installs the Adafruit core in version 1.5.0. So right there you’re getting a mismatch in intended base core version. In addition to that , the patches they make in their 1.3.3 version are not only adding their own variant folder, but modifying a few core files as well, and adding new libraires (like for I2S). Their patch file does not add that at all. So you end up with a weird frankenstein monster that’s not quite their core version but also not the Adafruit one.
By manually including some of the libraries, he provided a build that does lead to the serial port showing up (for the same code).
It might be worth reading the full thread and maybe even opening a thread on how to improve the RAK board patch for PlatformIO
I USE PlatformIO almost exclusively as well. Its an older somewhat hacked up install, not using the lastest integration.
I’ve seen the disappearing com port a number of times on Ubuntu as well. Usually im not changing any USB/serial code. Generally it resolves itself by uploading a new program via Arduiono IDE.
Sometimes it has taken multiple uploads to get it back. Sometimes I’ve needed to erase memory via Segger j-link and reinstall bootloader. A mystery.
Generally I’ve seen this right after uploading a new sketch, not after just doing a reset or power on.
There is/was a difference in the upload process between the two IDE’s but I have not fully investigated the differences. Perhaps something gets trashed in the bootloader/softdevice memory area, don’t know.
I’ve seen this with the Wisblock as well as the Seeed Xiao BLE (also nRF52840 based), both using the same runtime, different board support files of course.