[Closed]Serial only takes the last begin(baud rate)

Hi all,

I come here because I have a weird problem.
I'm working on a project since 2 weeks about RS485 communication. For that I'm using the RS485.h library
also on my pro laptop as personal laptop with no problem.

Yesterday, I trie to install Visual Studio Code (from Microsoft) and install its Arduino Plugin.
I used it for 1 hour to try it out but finally was not totally happy with it and return on my Arduino IDE. I uninstalled VS Code.

But when I tried to open the Serial monitor to follow the Serial.print of my program, I had weird message, and I found that the baud rate that worked for my Serial monitor was not the baud rate I wrote in Serial.begin() but in RS485.begin() !

Here is the beginning of my code and it's enough to produces the bug:

[b]#include <RS485.h>[/b]


void setup() {
// Begin serial port
#include <RS485.h>

void setup() {
// Begin serial port
Serial.begin(9600);
// Begin RS485 port
RS485.begin(19200);

Serial.println("Let's Go !");
delay(2000);
}

void loop() {
}

Instead of "Let's Go" I have ⸮?⸮o⸮⸮
But when I switch the Monitor from 9600 to 19200 there is Let's Go.

Another point is if I write RS485.begin(19200) then Serial.begin(9600), then the Monitor display Let's Go at 9600 baud rate.
My Serial Monitor takes account of the last line with begin and doesn't care about Serial or RS485 before the begin...
Do you have an idea to fix it ?

(I'm on Win 10 64bits with Arduino IDE 1.8.13 and I'm working with UNO copy)

Where did you get the RS485 library from ?

Is there an option to specify the pins to be used in the constructor and if not specified, does it default to using the hardware Serial pins ? Is the library intended to be used with a Uno ?

An Uno only has 1 Serial, that most probably is used for RS-485 as well unless you give it another Serial port. That's why you can have only one baudrate for this Serial.

Hello

Thank you to you two !

I totally forgot that first, the program was developped on an Industrial Shield Relay HF+ RS485
So the RS485 library comes from this Card config (I had to set an additionnal URL card manager). This card has special pins dedicated to RS485.

When I switched between my pro laptop with Industrial Shield and my personnal laptop with Industrial Shield then my Uno I mixed all those settings... I downloaded the ArduinoRS485 library that doesn't work like imbeded RS485 library.

Sooooooo, I think it's probably my bad, we can close this subject I think :confused:

Sorry for the inconvenience, the cons with working at home ^^'

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.