files/en-us/web/api/serialport/open/index.md
{{SecureContext_Header}}{{APIRef("Web Serial API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_dedicated")}}
The open() method of the {{domxref("SerialPort")}} interface returns a {{jsxref("Promise")}} that resolves when the port is opened. By default the port is opened with 8 data bits, 1 stop bit and no parity checking. The baudRate parameter is required.
open(options)
options
baudRate
bufferSize {{Optional_Inline}}
dataBits {{Optional_Inline}}
flowControl {{Optional_Inline}}
"none" or "hardware". The default value is "none".parity {{Optional_Inline}}
"none", "even", or "odd". The default value is "none".stopBits {{Optional_Inline}}
A {{jsxref("Promise")}}.
InvalidStateError {{domxref("DOMException")}}
NetworkError {{domxref("DOMException")}}
Before communicating on a serial port it must be opened. Opening the port allows the site to specify the necessary parameters that control how data is transmitted and received. Developers should check the documentation for the device they are connecting to for the appropriate parameters.
await port.open({ baudRate: 9600 /* pick your baud rate */ });
{{Specifications}}
{{Compat}}