Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a different baud rate #59

Open
shtarbanov opened this issue Mar 20, 2020 · 2 comments
Open

Using a different baud rate #59

shtarbanov opened this issue Mar 20, 2020 · 2 comments

Comments

@shtarbanov
Copy link

shtarbanov commented Mar 20, 2020

Everything works fine at 9600 baud, but if I change the baud rate to some higher value in both my js script and on the micrcontroller, the communication does not work. The problem appears to be that the server automatically is configured to use 9600 baud. How can I change this on the server?

@DottyJS
Copy link

DottyJS commented Apr 19, 2020

Hello,

Arduino :
Serial.begin(115200) (115200 for example)

In sketch :
let portName = 'COM6'; (if COM6 is the port of Arduino connected)
let options = {baudRate: 115200};
...
serial.open(portName,options);

I hope that's helpul

@Moosdijk
Copy link

Moosdijk commented May 8, 2020

I'm running into a problem. Whenever the baudrate of the arduino and p5serialport is set to 9600, everything works fine. I'm sending 32 0's or 1's terminated with a newline ('\n').
However, when I set both to 115200, serial communication is seen, but it's all empty.
Nothing in either files has changed except for the baudrate.
I'm running a slightly edited version of the basics example.
I've tried the way that @DottyJS mentioned, as well as serial.open(portName, {baudrate: 115200}, onOpen as mentioned as being a valid example in p5.serialport.js.

What's wrong?

Edit:
After some digging, I think it's to do with the fact that I'm using the GUI app for p5 serialcontrol, in which I can't specify the baud rate. I'll have a look if I can change and compile a better version.

Edit2:
As a workaround, you can change the baudrate at which the p5.serialcontrol app interfaces with the arduino.
I found out how to change the baudrate, which is hardcoded. Granted I'm on a mac, here's what you do:

-Go to your applications folder and look for p5.serialcontrol.app
-Right click, show package contents
-Navigate to /Contents/Resources/app/node_modules/@serialport/stream
-Open stream.js with a text exitor of your choice
-Change the baudrate from 9600 to one of your choice (I chose 115200).
-Save and close
-Open p5.serialcontrol as usual
-Of course, your arduino or similar should also communicate at the baudrate that you set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants