Using Raspberry Pi3’s serialport via an Electron app

I hit my head two times on this, getting serialdata via an Electron app, time to put the taken steps on paper.

Demo project

I found this demo project and used it aswell:

This was tested on a Pi2, on a Pi3 the serialport has a different name, i.e. serial0 or ttyS0

I implemented some changes to push the data to a table.
The project code can be found on my github page

Implementing serialport in an existing project

The installation is as easy as running the install command

[code]npm install –save-dev serialport[/code]

When trying to run electron I got:

On the raspberry pi the following error occured

According to the manual on github, it is needed to use electron-rebuild in order to solve this.

Installing electron-rebuild

[code]npm install –save-dev electron-rebuild[/code]

Change package.json under the scripts section

[code]’install’: ‘electron-rebuild'[/code]

run npm install, it will rebuild the serialport for us (takes a while on the Pi3)

A couple of weeks later I got this error ‘compiled against a different Node.js version’

Uncaught Error: The module 'xxx/serialport/build/Release/serialport.node' was compiled against a different Node.js version using

npm cache clear
rm -rf node_modules
npm install

12 thoughts on “Using Raspberry Pi3’s serialport via an Electron app”

  1. Hello,
    I’m trying to install the above application to my raspberry pi B3, but after running npm start command its opening electron and showing some blank page and after that nothing is happening, but the same application is working fine my desktop. I installed all the packages still its not working, please help me out with this. And please brief me about the hardware connection part aswell.
    Thanks in advance.

Comments are closed.