cancel
Showing results for 
Search instead for 
Did you mean: 

SoftwareSerial doesn't work on Nucleo-32L031K6

mhd75
Associate

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.

2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Karl Yamashita
Lead III

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

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.