Skip to main content
Visitor II
September 27, 2024
Question

SoftwareSerial doesn't work on Nucleo-32L031K6

  • September 27, 2024
  • 2 replies
  • 623 views

I use Arduino IDE and "STM32 MCU based boards" library to program Nucleo32. Here are the settings:

Screenshot 2024-09-26 213842.png

I connect it directly using USB to computer.

Here is my code:

 

#include <SoftwareSerial.h>
SoftwareSerial mySerial(PB6, PB1); // RX, TX

void setup() {
 Serial.begin(115200);
 Serial.println("Hi");

 mySerial.begin(115200); // When I add this line, nothing works anymore
}
void loop() {
 if (Serial.available()) {
 String command = Serial.readStringUntil('\n');
 Serial.print("Just received a Serial from PC: ");
 Serial.println(command);
 }
}

 

I reset it and it writes "Hi" in the Serial monitor, but when I begin() the software serial (line 8), nothing works anymore. Unable to toggle pins, no output appears in the Serial monitor and everything gets stuck.

When I remove line 8, it works without any problems.

    This topic has been closed for replies.

    2 replies

    Graduate II
    September 27, 2024

    Sounds like it faults the MCU.

    Debug it, or engage with the Arduino developers.

    Can you use a regular UART based serial port.

    Check mySerial is not NULL.

    Graduate II
    September 27, 2024

    Since you're using Arduino IDE with an Arduino type library, you should be asking for help in the Arduino forum.