Unable to connect to arduino from serial

Hi.

I made a flow to get some data from an Arduino from serial communication (USB) but I can't get it working on my RPi Stretch.

pi@raspberrypi:~ $ node-red
2 Aug 16:37:29 - [info] 

Welcome to Node-RED
===================

2 Aug 16:37:29 - [info] Node-RED version: v0.18.5
2 Aug 16:37:29 - [info] Node.js  version: v9.11.2
2 Aug 16:37:29 - [info] Linux 4.14.56-v7+ arm LE
2 Aug 16:37:32 - [info] Loading palette nodes
2 Aug 16:37:41 - [info] Dashboard version 2.9.6 started at /ui
2 Aug 16:37:44 - [info] Settings file  : /home/pi/.node-red/settings.js
2 Aug 16:37:44 - [info] User directory : /home/pi/.node-red
2 Aug 16:37:44 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
2 Aug 16:37:44 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
2 Aug 16:37:44 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

2 Aug 16:37:44 - [info] Starting flows
2 Aug 16:37:44 - [info] Started flows
2 Aug 16:37:44 - [info] Server now running at http://127.0.0.1:1880/
2 Aug 16:37:44 - [error] serial port /dev/ttyUSB0 error: Error: Error Resource temporarily unavailable Cannot lock port

When I do :

screen /dev/ttyUSB0

I can see my data coming from the Arduino
Before I launch node-red, I make sure to kill the screen session, to have the USB port free for node-red use)
When I run the same flow on another PC, the flow works and the serial is connected to the Arduino correctly.
I've noticed the "serial in node" has changed on the RPi (from my other PC (Linux Fedora), there are more possible parameter to be changed so it might be a newer version. Could it be the reason it doesn't work ?

1 Like

You are using a newer version of Nodejs than is recommended (Nodejs LTS 8.x.)
If you can it would be worth to try again with Node.js LTS 8.x as per the docs

https://nodered.org/docs/getting-started/installation

As @ukmoose says, you are using an unsupported version of node.js. Since you are using raspbian you can revert to a good version by running the bash <(curl script as described in the node red pi docs.
https://nodered.org/docs/hardware/raspberrypi

Hello everyone! I'm having the same problem with Node.js version 8.11.3

Hello poyrazs

What u wanted to do exactly with the arduino board? Have you seen the arduino node + standard firmdata? If you plan to use the arduino just to handle I/O then this is the best choice, very easy and flexible and direct to go.

Regards

Sorry for the late response, but I was away from my Raspberry Pi machine for some time .

I ran the script you mentioned but still get node version 9 instead of 8 as you can see !

pi@raspberrypi:~ $ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

 
This script will remove versions of Node.js prior to version 6.x, and Node-RED and
if necessary replace them with Node.js 8.x LTS (carbon) and the latest Node-RED from Npm.
 
It also moves any Node-RED nodes that are globally installed into your user
~/.node-red/node_modules directory, and adds them to your package.json, so that
you can manage them with the palette manager.
 
It also tries to run 'npm rebuild' to refresh any extra nodes you have installed
that may have a native binary component. While this normally works ok, you need
to check that it succeeds for your combination of installed nodes.
 
To do all this it runs commands as root - please satisfy yourself that this will
not damage your Pi, or otherwise compromise your configuration.
If in doubt please backup your SD card first.
 
Are you really sure you want to do this ? [y/N] ? y


Running Node-RED update for user pi at /home/pi
[sudo] Mot de passe de pi : 

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       -
  Update Node.js LTS                  ✔   Node v9.11.2   Npm 5.6.0
  Clean npm cache                     ✔
  Install Node-RED core               ✔   0.19.1 
  Move global nodes to local          -
  Install extra Pi nodes              -
  Npm rebuild existing nodes          ✔
  Add menu shortcut                   ✔
  Update systemd script               ✔
                                           

Any errors will be logged to   /var/log/nodered-install.log

All done.
  You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
  Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started  vendredi 17 août 2018, 17:45:23 (UTC+0200)  -  Finished  vendredi 17 août 2018, 17:48:37 (UTC+0200)

pi@raspberrypi:~ $ node -v
v9.11.2

In case of need:
nodered-install.log.txt (31.6 KB)

That surprises me, I thought the script would remove node v9, but apparently not. @dceejay my wish to comment on that.
In the meantime I suggest removing the current version and running the script again, however I don't know how you installed v9 so I can't advise how to remove it. The default version on stretch is 8.11.1

HI - no it only "upgrades" to v8... anything beyond that we sort of assume the user may have a reason to be doing that (maybe testing new features in 9 or 10 for other reasons) - so we don't force them back.

If you remove /usr/bin/node and /etc/apt/sources.list.d/nodesource.list then re-run the script we then won't find node.js or it's installer and will re-install the 8.x version.

Ok, it has come back to node v8.11.4.
but instead of removing /etc/apt/sources/list.d/nodesource.list,
/etc/apt/sources.list.d/nodesource.list must be removed.
/etc/apt/sources/list.d/nodesource.list didn't exist on my raspbian raspberry pi

Thanks a lot for the assistance !

apologies for the typo - glad you worked out the "code".
(Edited the ticked answer above to be correct)