2

I just received a Nucleo F401RE and can't get my sketch to work on it because the compiler says Serial1 is not defined. My sketch uses multiple serials because I need to use the usb serial monitor while also communicating to another device on a different serial port.

Here is a screenshot of the flags I selected.

compiling flags

According to the F401 specs it has at least 6 different serials, so the real question is: is there an easy way to use Serial1 and so on straight out of the box in the Arduino IDE?

I'm quite new and unexperienced to this field, so please excuse me if this question is too trivial.

  • stm32duino.com – Juraj Feb 25 '19 at 18:50
  • could you elaborate more, please? I've looked for an answer on stm32duino.com forum before posting here, but couldn't find any. I also wanted to post my question there, but it seems like it's impossible to register as a new user, so I'm stranded at the moment – Iacopo Boccalari Feb 26 '19 at 10:42
  • the options from Tools menu are evaluated in WSerial.h. SerialUSB and/or Serial are defined. the way described in answer is the right one to create additional Serial interfaces – Juraj Feb 28 '19 at 19:31
1

Frederic Pillon on Github has been very helpful and suggested me the solution, which is to define the serial via:

HardwareSerial Serial1(PA10, PA9);

instead of just giving Serial1 for granted as you would do on a regular Arduino mega

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.