Serial2Excel is a CLI for capturing data from a serial connection (e.g. Arduino) and exporting it to an Excel spreadsheet, a CSV or JSON file.
If this package is helping you, maybe consider to
- Capture data from a serial device.
- Process incoming data in real-time.
- Generate Excel, CSV or JSON files containing the processed data.
Use at least Node v16+, however serial2excel
has not been tested on every singe NodeJS version. For best results you may stick to LTS versions. Issue reports related are highly appreciated.
Install serial2excel
globally using npm:
npm install -g serial2excel
or run
npx serial2excel [port] [options]
- Ensure that no other devices or programs are utilizing the serial connection before running the command.
- If you don't include file extensions in your output file path, the CLI will add them based on the chosen file type (see first example).
- If you have any occuring issues, email me or create a Github issue.
- If you are using Windows PowerShell make sure two wrap your columns in quotation marks
-c 'Column1,Column2,Column3'
. Otherwise PowerShell parses the commas wrong, resulting in an error. - Use -h or --help to display information about the available options.
Once installed, you can use the serial2excel command to capture data from a serial device and export it to Excel, CSV or JSON format.
Ensure that no other devices or programs are utilizing the serial connection before running the command.
serial2excel [port] [options]
- Ensure that the serial device is configured to send data in a seperated format, such as
data1;data2;...
. You can define a custom seperator setting the-s
flag. Your serial monitor must be set to useNR & CR
.
-
Start Serial2Excel by running it in your terminal or command prompt. Define the columns so they fit to the data your sending.
-
The CLI will capture data from the serial device automatically as it's sent.
-
When you're done sending data, send the command
stop
via the serial device. This signals to the CLI that data transmission is complete. -
Once the data processing is complete the output file will be generated (Excel spreadsheet / CSV / JSON).
If you have any occuring issues, do not hesitate to email me or create a Github issue.
-V, --version output the version number
-br, --baud-rate <number> set baud rate for serial communication (default: 9600)
-t, --type <filetype> set expected file type (choices: "xlsx", "csv", "json", default: "xlsx")
-s, --seperator <separator> set custom seperator - this will only effect the data your sending, not the columns specified in the cli (default: ";")
-o, --output <filepath> define the output file path and filename. (e.g. '/path/to/file/filename')
-c, --columns <col1,col2,...> define the columns of the table (e.g. 'Song,Musician,Album')
-h, --help display help for command
- You have an Arduino running on port 'com4', which sends weather data including Temperatur, Humidity and Pressure formatted as
Temperatur;Humidity;Pressure
. You want to export the data as CSV. Your command prompt might look like this:
serial2excel com4 -t csv -o ./data -c 'Temperature,Humidity,Pressure'
- Your serial device runs on port '/dev/ttyUSB0' and sends data about a hardware device your testing and debugging. The device operates at 115200 baud and the data is formatted as
Acceleration|Speed|Timestamp
.
serial2excel /dev/ttyUSB0 -o ./data.xlsx -br 115200 -s '|' -c 'Acceleration,Speed,Timestamp'
Note: Changing the seperator only applies to the data your sending from your serial device. In the CLI itself, use the comma.
101
: Invalid Port. Make sure you choose the right port, where the serial connection is running on.
301
: Column mismatch. The provided data has more columns than the table. Make sure every data row has the exact same columns. However you can bypass this, by adding more columns to the-c
flag than actually needed (e.g.-c 'Temperatur,Humidity,Pressure,-,-,...'
), though this is not recommended.
501
: Error writing to file. Try again later.