Node-Red with Arduino Serial Input

1,964 views
Skip to first unread message

Kenneth Chia

unread,
Nov 11, 2016, 1:31:06 AM11/11/16
to Node-RED
Hi, 

I have an arduino and would like to send a string into the arduino, similar to the one I have stated below. I would like the code to work similarly like the arduino Send Input in the Serial Monitor in the arduino IDE. 

I have tried 2 methods, but both have failed. For method 1, I am not sure what I can put into the Pin in the Arduino node settings. This is so as I am not sending an input to a specific pin, I would like it to work like the Send Input in the Serial Monitor in the arduino IDE

Method 2, I am not sure why it is not working, I got "Serial port COM10 error: Error: Opening COM10: File not found". 

I have connected my arduino uno/mega to my computer via USB with the official cable that arduino provides. I have tried connecting a Prolific USB serial converter to my arduino and to my computer too. Both have failed.

Would appreciate the guidance as I am new to this. Thank you very much!


Regards,
Kenneth





[{"id":"a7e7d168.85b2d","type":"serial out","z":"19e9849.0a0487b","name":"","serial":"c8a413d3.c1233","x":691,"y":418,"wires":[]},{"id":"c8a413d3.c1233","type":"serial-port","z":"","serialport":"COM10","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false}]

Kenneth Chia

unread,
Nov 11, 2016, 1:35:50 AM11/11/16
to Node-RED


[{"id":"a5cc7d71.e2a99","type":"inject","z":"19e9849.0a0487b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":216,"y":150,"wires":[["ea2a7c52.bf78e"]]},{"id":"ea2a7c52.bf78e","type":"arduino out","z":"19e9849.0a0487b","name":"","pin":"","state":"","arduino":"aa12de95.ef329","x":733,"y":175,"wires":[]},{"id":"7aa7c4b8.a6e40c","type":"comment","z":"19e9849.0a0487b","name":"Method 1","info":"","x":471,"y":116,"wires":[]},{"id":"447516f1.5b55a8","type":"inject","z":"19e9849.0a0487b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":189,"y":403,"wires":[["a7e7d168.85b2d"]]},{"id":"a7e7d168.85b2d","type":"serial out","z":"19e9849.0a0487b","name":"","serial":"c8a413d3.c1233","x":691,"y":418,"wires":[]},{"id":"b868aaea.1ccc58","type":"comment","z":"19e9849.0a0487b","name":"Method 2","info":"","x":446,"y":365,"wires":[]},{"id":"aa12de95.ef329","type":"arduino-board","z":"","device":"COM10"},{"id":"c8a413d3.c1233","type":"serial-port","z":"","serialport":"COM10","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false}]


apologies, this is the correct code i used in node-red 

Mark Setrem

unread,
Nov 11, 2016, 2:56:05 AM11/11/16
to Node-RED
It might be useful if you tell us what operating system your computer is running. Also when you start node-red it prints out some details that lists the.versions you are running and any errors it finds, it would be useful if you could paste that here as well.

Kenneth Chia

unread,
Nov 11, 2016, 3:29:37 AM11/11/16
to Node-RED
Hi Mark,

Thank you for your reply! 

Am using Windows 7 Professional. 

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\student>node-red


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

11 Nov 16:24:09 - [info] Node-RED version: v0.15.1
11 Nov 16:24:09 - [info] Node.js  version: v4.6.1
11 Nov 16:24:09 - [info] Windows_NT 6.1.7601 x64 LE
11 Nov 16:24:13 - [info] Loading palette nodes
11 Nov 16:24:27 - [warn] ------------------------------------------------------
11 Nov 16:24:27 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
11 Nov 16:24:27 - [warn] [tail] Not currently supported on Windows.
11 Nov 16:24:27 - [warn] ------------------------------------------------------
11 Nov 16:24:27 - [info] Settings file  : C:\Users\student\AppData\Roaming\npm\n
ode_modules\node-red\settings.js
11 Nov 16:24:27 - [info] User directory : \Users\student\.node-red
11 Nov 16:24:27 - [info] Flows file     : \Users\student\.node-red\flows_t2m-pom
-oip2.json
11 Nov 16:24:27 - [info] Starting flows
11 Nov 16:24:27 - [info] Started flows
11 Nov 16:24:27 - [info] Server now running at http://127.0.0.1:1880/
11 Nov 16:26:13 - [info] Stopping flows
11 Nov 16:26:13 - [info] Stopped flows
11 Nov 16:26:13 - [info] Starting flows
11 Nov 16:26:13 - [info] Started flows
11 Nov 16:26:13 - [error] serial port COM8 error: Error: Opening COM8: Access de
nied
11 Nov 16:26:24 - [error] [serial out:36ec2627.9ab50a] Error: Port is not open

The error started when I ran the flow which I posted above. I deleted Method 1, I ran method 2. 

Kenneth Chia

unread,
Nov 11, 2016, 3:30:20 AM11/11/16
to Node-RED
COM 8 is connected to an arduino UNO.

Would appreciate your advice. Thanks!


Regards, 
Kenneth

Julian Knight

unread,
Nov 11, 2016, 3:46:26 AM11/11/16
to Node-RED
On Windows, the best thing to do is to install the Arduino IDE and check that you have the correct COM port. This is not always obvious and has a nasty tendency to change seemingly at random from time-to-time.

Next thing to check is the serial speed and settings that the Arduino has been set to. Again you can check this in the IDE if the Arduino is sending data or via whatever script you have loaded onto it.

Armed with that information, you need to close the IDE and then start up Node-RED and add a serial node with the same settings as in the IDE.


Now, having said that. I note that the error is "Access Denied" which implies that the user you are running Node-RED from does not have sufficient access to the COM port. Again, if you are using the IDE on the PC, this should be obvious because you would not be able to get serial comms working there either. If you can get serial comms working in the IDE but not in Node-RED, then we know we have a different issue.

Is this your PC or a university/college/school one? Because it looks, from the user name, as though it is not your own. If so, you may need to confirm with your system administrators that you have access to USB/Serial.

Kenneth Chia

unread,
Nov 11, 2016, 4:01:48 AM11/11/16
to Node-RED
Hi Julian,

Thanks for your reply!

I closed the Arduino IDE. What you said works, thanks! Have tested it out, the serial node can work when the arduino IDE is closed. But that opens up another problem for me as I cannot test on the Arduino IDE Serial Monitor if I have received the string from Node-Red. Any ideas on how to solve this?

Yes, but I have been given full admin access. 

Thank you so much!

Dave C-J

unread,
Nov 11, 2016, 5:42:54 AM11/11/16
to node...@googlegroups.com
You can't use method 1 and 2 on the workspace at the same time. As the arduino node will try to autodetect the arduino and grab the serial port - blocking the serial node from getting it... or vice versa... 
For what you want just use method 2 - the standard serial node and remove the arduino node completely - you will probably have to remove it from the menu - "configuration nodes" as well.

Kenneth Chia

unread,
Nov 11, 2016, 5:56:15 AM11/11/16
to Node-RED
Hi Dave,

Thanks for your reply!

Yup I know, I only placed method 1 & 2 together to show you guys what I did. Yup have done as what Julian has adviced. Thanks again for your reply.


Regards, 

Kenneth

Dave C-J

unread,
Nov 11, 2016, 7:42:37 AM11/11/16
to node...@googlegroups.com
OK - so 2 "should" work - as long as something else (eg arduino config node) has not grabbed the port (or maybe the Arduino IDE... that has to be closed also)

Julian Knight

unread,
Nov 11, 2016, 11:12:28 AM11/11/16
to Node-RED
The Arduino IDE grabs exclusive use of the port AFAIK. Not sure if Node.JS does the same thing which will be why only one works at a time. You could try using a 3rd party terminal emulator that supports serial. Putty for example - though you will need to check that it too doesn't require exclusive access. No, strike that, it looks like Windows always takes exclusive access. There is at least one tool to get round that but it isn't free. http://www.eltima.com/products/serialshare/

Possibly the easiest way to test if you've received the input on the Arduino is to have a slight delay and then send back a different response message confirming receipt.

Kenneth Chia

unread,
Nov 13, 2016, 8:35:26 PM11/13/16
to Node-RED
Alright thanks so much Julian & Dave for your guidance! Have a good week ahead!

Juan Ignacio Beloqui

unread,
Jan 17, 2017, 1:01:33 PM1/17/17
to Node-RED
Hey guys, sorry to to bother you. But i have read all the messages in this topic and i still have the same problem. When i lunch the Node-red, it threw me the message show in image "error". I am running node-red in a PC with windows 7 64-bit. The arduino IDE is not open, i tested the port with other terminal program and is working fine. I have an Arduino UNO with a basic programm, listening to the serial port and one serial node in the node-redd and i can not make it work. Please can someone help me, is driving me crazy
Error.JPG

Julian Knight

unread,
Jan 21, 2017, 11:01:38 AM1/21/17
to Node-RED
You appear to be using a user name called "Windows"? Is that a Standard user or an admin user?
Reply all
Reply to author
Forward
0 new messages