Serial Monitor not reporting with platformio or arduino IDE

Win10, VSC, Platform IO, and Serial monitor extensions installed. I do not see any activity in the Serial Monitor (platformio:serial monitor or VSC Serial Monitor). However I CAN see the data being published to notehub.

I can flash the Swan using Stlink or DFU no problem.

Using Zadig installed USB drivers, The Window USB drivers seem to be fine and recognized. I have uninstalled/reinstalled platform IO. Tried using different baud rates. Tried using Arduino IDE still no reporting on the Serial Monitor. What am I missing?..It must be something simple.

Setup is USB to swan on the carrier-F with notecard and USB serial connection STLink.
image

void setup()
{
// put your setup code here, to run once:
delay(2500);
usbSerial.begin(115200);
usbSerial.println(“Starting up…”);
notecard.begin();
notecard.setDebugOutputStream(usbSerial);

J *req = notecard.newRequest(“hub.set”);
JAddStringToObject(req, “product”, productUID);
JAddStringToObject(req, “mode”, “continuous”); // set to periodic if running on battery
JAddBoolToObject(req, “sync”, true); // sync to notehub.io sync env variable immediately if it changes. set to false if running on battery
notecard.sendRequest(req);
}

void loop()
{
// put your main code here, to run repeatedly:
float temperature = sensor.temp();
float humidity = sensor.humidity();

usbSerial.print(“Temperature = “);
usbSerial.print(temperature);
usbSerial.println(” *C”);
usbSerial.print(“Humidity = “);
usbSerial.print(humidity);
usbSerial.println(” %”);

J *req = notecard.newRequest(“note.add”);
if (req != NULL)
{
JAddStringToObject(req, “file”, “sensors.qo”);
JAddBoolToObject(req, “sync”, true); // delete if running on battery or se to false
J *body = JAddObjectToObject(req, “body”);
if (body)
{
JAddNumberToObject(body, “temp”, temperature);
JAddNumberToObject(body, “humidity”, humidity);
}
notecard.sendRequest(req);
}

// delay(15000); replaced with getSensorInterval() instead of hardcoding 15 seconds
int sensorIntervalSeconds = getSensorInterval(); // getSensorInterval() returns an integer
usbSerial.print(“Delaying “);
usbSerial.print(sensorIntervalSeconds);
usbSerial.println(” seconds”);
delay(sensorIntervalSeconds * 1000); // delay for sensorIntervalSeconds * 1000
}

// This function assumes you’ll set the reading_interval environment variable to
// a positive integer. If the variable is not set, set to 0, or set to an invalid
// type, this function returns a default value of 60.
int getSensorInterval()
{
int sensorIntervalSeconds = 60;
J *req = notecard.newRequest(“env.get”); // environment variable get
if (req != NULL)
{
JAddStringToObject(req, “name”, “reading_interval”); // reading_interval is the name of the environment variable I creaated in notehub.io for 30 seconds. key value pair
// can push out changes over cell. dont need to update code on every device.
J *rsp = notecard.requestAndResponse(req); // request and response
int readingIntervalEnvVar = atoi(JGetString(rsp, “text”)); // converts string to integer
if (readingIntervalEnvVar > 0) // if readingIntervalEnvVar is greater than 0
{
sensorIntervalSeconds = readingIntervalEnvVar; // set sensorIntervalSeconds to readingIntervalEnvVar
}
notecard.deleteResponse(rsp); // delete response
}
return sensorIntervalSeconds; // return sensorIntervalSeconds
}

Hi - It looks like from your screenshots that you have an STLink plugged in as well as the Swan, is this correct?

If so you need to select a different COM port in the Serial Monitor - as it is showing the STLink, not the Swan. The dropdown selector on Port in the Serial Monitor extension should give you some more options.

I hope this helps.

Kimball

:arrow_up:

One other sanity check: make sure the USB cable you’re using to connect the Swan to your computer is not power only. It must also be able to transmit data.

And if for whatever reason you still end up stuck, you actually can get the serial logs from the STLINK directly. Here’s some code you can try if you want to take that approach: main.cpp · GitHub.

Let us know how it goes.

TJ

To see the devices and their serial ports, you can run pio device list from within the terminal in VSCode which will list the serial devices and their ports.

Sometimes the PlatformIO serial port monitor doesn’t always find the right port when it’s not specified.

@drrk Yes, both STLink and Swan USBs plugged in. The only Com port I get is the STMicroelectronics STLink Virtual COM Port. I have never seen the Com port as the SWAN only as a USB device device. That would explain it. How would I force the SWAN USB connection to a COM port? if that is what the issue is?

The Drop down in the VSC Serial Monitor only shows the STLink Virtual COM port.

Attached device manager drivers. Note I move the USB around so now shows COM11… vice COM9 above. the default port setting is 9600. I have changed this to 115200, but doesn’t seem to change any results. My Code is using 115200 (main.ccp and platformio.ini)

I have confirmed USB cable are data not just power.

image
image

@matt Pio device list (as Well as VSC Serial Monitor) show the below as the Com Port

image

I’ll try the code and see if I can see the logs.

1 Like

TJ, tired your code. Still not getting anything reporting out to VSC serial monitor or platformio:serial .
image



image
image
image
image
image

I installed VSC and platformIO and VSC/Serial Monitor on another Win10 laptop and the data is reporting with no issues. Both stlink and swan are showing as selectable Com ports. This issue is resolved.

3 Likes