Error when using Arduino Out and Arduino In nodes trough node-red-node-arduino package
ViniciusLCLima opened this issue · 2 comments
Which node are you reporting an issue on?
Arduino Out
What are the steps to reproduce?
Install node.js 20.9.0 and Npm 10.1.0 with nvm.
install node-red through the command "npm install -g -unsafe-perm node-red"
install serialport package through the command "npm i --unsafe-perm serialport"
install node-red-node-arduino package with command "install i --unsafe-perm node-red-node-arduino"
Connect an arduino Uno loaded with the "Firmata Standard" example to the computer.
Execute node-red with the command "node-red"
Insert arduino out nodes in node-red.
Insert the following settings in arduino out node:
Arduino: the port in which node-red detects the Arduino Uno.
Type: Digital(0/1)
Pin: one of the Arduino Uno digital pins. In my case, it was 9.
Deploy the changes.
What happens?
The program throws an error after a few seconds.
Here's the log:
PS C:\Users\Leite Lima> node-red
15 Nov 10:43:25 - [info]
Welcome to Node-RED
===================
15 Nov 10:43:25 - [info] Node-RED version: v3.1.0
15 Nov 10:43:25 - [info] Node.js version: v20.9.0
15 Nov 10:43:25 - [info] Windows_NT 6.3.9600 x64 LE
15 Nov 10:43:27 - [info] Loading palette nodes
15 Nov 10:43:30 - [info] Settings file : C:\Users\Leite Lima\.node-red\settings.js
15 Nov 10:43:30 - [info] Context store : 'default' [module=memory]
15 Nov 10:43:30 - [info] User directory : \Users\Leite Lima\.node-red
15 Nov 10:43:30 - [warn] Projects disabled : editorTheme.projects.enabled=false
15 Nov 10:43:30 - [info] Flows file : \Users\Leite Lima\.node-red\flows.json
15 Nov 10:43:30 - [info] Server now running at http://127.0.0.1:1880/
15 Nov 10:43:30 - [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.
---------------------------------------------------------------------
15 Nov 10:43:30 - [info] Starting flows
15 Nov 10:43:30 - [info] Started flows
15 Nov 10:43:45 - [red] Uncaught Exception:
15 Nov 10:43:45 - [error] TypeError: Cannot set properties of undefined (setting 'mode')
at Firmata.pinMode (C:\Users\Leite Lima\.node-red\node_modules\firmata-io\lib\firmata.js:948:27)
at doit (C:\Users\Leite Lima\.node-red\node_modules\node-red-node-arduino\35-arduino.js:154:63)
at Firmata.<anonymous> (C:\Users\Leite Lima\.node-red\node_modules\node-red-node-arduino\35-arduino.js:194:62)
at Object.onceWrapper (node:events:628:28)
at Firmata.emit (node:events:526:35)
at Firmata.ready (C:\Users\Leite Lima\.node-red\node_modules\firmata-io\lib\firmata.js:734:13)
at Object.onceWrapper (node:events:628:28)
at Firmata.emit (node:events:514:28)
at 106 (C:\Users\Leite Lima\.node-red\node_modules\firmata-io\lib\firmata.js:294:11)
at SerialPort.<anonymous> (C:\Users\Leite Lima\.node-red\node_modules\firmata-io\lib\firmata.js:641:15)
What do you expect to happen?
The connection to the arduino pin to occur, and the messages sent to it to be received.
Please tell us about your environment:
- Node-RED version: 3.1.0
- node.js version: 20.9.0
- npm version: 10.1.0
- Platform/OS: Windows 10
- Browser: Google Chrome
Can you try uninstalling both the arduino node and the serialport node.... then reinstall only the arduino node.
I run this small flow OK - (pin 13 is the on board LED on my Arduino ) and it can be tuned on and off ok.
[{"id":"70a6d69fa539bf2d","type":"inject","z":"0f18bebd6957c8cc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":200,"wires":[["9ff77e87bc5733be","d7ecd7803a49f83d"]]},{"id":"85159fa1d0b42da1","type":"inject","z":"0f18bebd6957c8cc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":240,"wires":[["9ff77e87bc5733be","d7ecd7803a49f83d"]]},{"id":"d7ecd7803a49f83d","type":"arduino out","z":"0f18bebd6957c8cc","name":"","pin":"13","state":"OUTPUT","arduino":"1e096e53e4774a88","x":370,"y":240,"wires":[]},{"id":"1e096e53e4774a88","type":"arduino-board","device":"/dev/ttyUSB0"}]
The underlying firmata library has not been updated for 3 years and prereqs an older version of serialport that is not compatible with the latest version.
There may be a way to make this better in future - hold that thought.