# Display Arduino readings via node red

**URL:** <https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425>\
**Category:** General\
**Created:** [6 August 2021 14:45 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425 "2021-08-06T14:45:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [6 August 2021 14:45 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/1 "2021-08-06T14:45:43Z")

</div>

Hi  
I have a specific code on Arduino to measure analog signal like current and voltage but I need to connect Arduino to raspberry pi 3 to display these readings on ui dashboard

Is it possible to do that and how?

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [6 August 2021 15:13 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/2 "2021-08-06T15:13:55Z")

</div>

Hi @mustafa. Yes it is possible, i know two ways:

1.- Could use Serial Port to communicate with Raspberry Pi, this with the Serial In/Out Nodes, maybe it will be easier way, remember you should configure, baud rate, port, etc... :  
To install Serial Nodes:

```auto
npm i node-red-node-serialport

```

![Captura de pantalla 2021-08-06 a la(s) 10.03.06 a. m.](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5dd379201a48298bde54825b3e53190591b4be47.png)

2.- The second one, is use MQTT communication, you could use the "PubSubClient.h" library for Arduino, and use for example; WiFi or Ethernet shield to communicate. In Node-RED, this nodes are MQTT in & MQTT out, in the library there are many examples to start :

![Captura de pantalla 2021-08-06 a la(s) 10.08.07 a. m.](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce7e965513a33fc473f23fedcf3e09adc9fbad71.png)

to this you should configure, a broker MQTT as Mosquitto or something like that, in Arduino, should configure, IP or direction of BROKER MQTT, Port (1883/8883), Topic, Payload, etc.

but maybe there are many other forms to communicate. I hope it helps you!!

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [6 August 2021 16:14 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/3 "2021-08-06T16:14:26Z")

</div>

Hi@MecatronicaMADE  
Just now I did with serial communication node exactly as per this video ([Raspberry pi and Arduino serial connection using Node-RED - YouTube](https://www.youtube.com/watch?v=0hopHBvRsA8)) but the arduino didn't connect with RPI  
please see the debug out:

8/6/2021, 7:06:27 PMnode: dcb43463c0772bb9  
msg : string[29]  
"port not found : /dev/ttyACM1"  
8/6/2021, 7:08:46 PMnode: dcb43463c0772bb9  
msg : string[29]  
"port not found : /dev/ttyACM1"  
8/6/2021, 7:09:21 PMnode: Uno  
msg : string[21]  
"missing serial config"  
8/6/2021, 7:09:52 PM  
msg : string[126]  
"[serialconfig:35e4a510b43d031d] serial port /dev/ttyACM0 error: Error: Error Resource temporarily unavailable Cannot lock port"

and for the command please see what i got

```auto
npm i node-red-node-serialport
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

+ node-red-node-serialport@0.14.1
updated 1 package and audited 582 packages in 15.486s

41 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

pi@pi:~ $ npm fund
/home/pi
├─┬ https://github.com/sponsors/feross
│ └── safe-buffer@5.2.1, buffer@5.7.1, base64-js@1.5.1, ieee754@1.2.1, simple-concat@1.0.1
├─┬ https://www.patreon.com/feross
│ └── safe-buffer@5.2.1, buffer@5.7.1, base64-js@1.5.1, ieee754@1.2.1, simple-concat@1.0.1
├─┬ https://feross.org/support
│ └── safe-buffer@5.2.1, buffer@5.7.1, base64-js@1.5.1, ieee754@1.2.1, simple-concat@1.0.1
├─┬ https://github.com/sponsors/epoberezkin
│ └── ajv@8.6.0
├─┬ https://github.com/cheeriojs/cheerio?sponsor=1
│ └── cheerio@1.0.0-rc.10
├─┬ https://github.com/sindresorhus/got?sponsor=1
│ └── got@11.8.2
├─┬ https://github.com/sponsors/fb55
│ └── cheerio-select@1.5.0, htmlparser2@6.1.0, css-select@4.1.3, css-what@5.0.1, domelementtype@2.2.0
├─┬ https://github.com/cheeriojs/dom-serializer?sponsor=1
│ └── dom-serializer@1.3.2
├─┬ https://github.com/fb55/domhandler?sponsor=1
│ └── domhandler@4.2.0
├─┬ https://github.com/fb55/htmlparser2?sponsor=1
│ └── htmlparser2@6.1.0
├─┬ https://github.com/fb55/domutils?sponsor=1
│ └── domutils@2.7.0
├─┬ https://github.com/fb55/nth-check?sponsor=1
│ └── nth-check@2.0.0
├─┬ https://github.com/fb55/entities?sponsor=1
│ └── entities@2.2.0
├─┬ https://github.com/sindresorhus/is?sponsor=1
│ └── @sindresorhus/is@4.0.1
├─┬ https://github.com/sponsors/sindresorhus
│ └── decompress-response@6.0.0, get-stream@5.2.0, normalize-url@6.1.0, mimic-response@3.1.0, quick-lru@5.1.1, make-dir@3.1.0, mimic-response@2.1.0
├─┬ https://github.com/sponsors/isaacs
│ └── glob@7.1.7, rimraf@3.0.2
├─┬ https://github.com/sponsors/RubenVerborgh
│ └── follow-redirects@1.14.1
└─┬ https://opencollective.com/serialport/donate
  └── serialport@9.2.0, @serialport/binding-mock@9.0.7, @serialport/bindings@9.2.0, @serialport/parser-byte-length@9.0.7, @serialport/parser-cctalk@9.0.7, @serialport/parser-delimiter@9.0.7, @serialport/parser-inter-byte-timeout@9.0.7, @serialport/parser-readline@9.0.7, @serialport/parser-ready@9.0.7, @serialport/parser-regex@9.0.7, @serialport/stream@9.0.7, @serialport/binding-abstract@9.0.7

```

I have a problem in finding the port and if I find it I lost the communication or the port is changed

is there any idea please especially for the serial method it is much easer to me than the MQTT

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [7 August 2021 01:29 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/4 "2021-08-07T01:29:22Z")

</div>

For sure @mustafa. I share you this tutorial of [serial communication between Arduino and Node-RED](https://www.youtube.com/watch?v=wk4FqMBKGSQ&t=1s) it is in spanish but you can understand the code in Arduino and the flow in Node-RED.

One thing, if you are programming your Arduino at the same Raspberry Pi where is working Node-RED, remember, when you are working with Serial Port in Node-RED, you should disable or close the "Serial Monitor" in Arduino, and when you are uploading the code in Arduino, you should disable serial node in Node-RED. To disable the node use:

![Captura de pantalla 2021-08-06 a la(s) 8.24.48 p. m.](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/23b8eab472ec252d1575127d285084a45ac3fbb5.png) ![Captura de pantalla 2021-08-06 a la(s) 8.24.59 p. m.](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a9598e4d49b9f9d513ede6bbe168fefef902a17.png)

you should see now:

![Captura de pantalla 2021-08-06 a la(s) 8.27.09 p. m.](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7db8e90620d196c29e4d606e5c1adc9c187e6b8.png)

I hope it helps you!!!

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [7 August 2021 15:31 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/5 "2021-08-07T15:31:32Z")

</div>

I saw the video but I'm wondering if after upload this code to the arduino in order to establish the serial communication ,so how can I upload ad firrent code to the arduino again ? for example now I uploaded the Emon library code to the arduino to calculate electrical current and voltage  
is it possible to upload any code like Emon after uploading the code in your video ??

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 August 2021 15:35 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/6 "2021-08-07T15:35:51Z")

</div>

> [@mustafa](#):
>
> ```auto
> npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
> 
> ```

You must run npm install from your node-red folder `/home/pi/.node-red` - you ran it from `/home/pi`

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [7 August 2021 16:11 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/7 "2021-08-07T16:11:50Z")

</div>

is it solved now ??  
npm i node-red-node-serialport  
npm WARN pi@1.0.0 No description  
npm WARN pi@1.0.0 No repository field.

- node-red-node-serialport@0.14.1  
updated 1 package and audited 326 packages in 40.282s

27 packages are looking for funding  
run `npm fund` for details

found 0 vulnerabilities

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 August 2021 16:15 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/8 "2021-08-07T16:15:55Z")

</div>

> [@mustafa](#):
>
> is it solved now ??

It seems as though the serial port is now installed and working however, your goal was to communicate to Arduino.

You didnt say if it had WIFI built in?

If it does have WIFI, then MQTT is MUCH simpler than serial comms

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [7 August 2021 16:20 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/9 "2021-08-07T16:20:42Z")

</div>

Yes @mustafa, you can add more libraries on the base code, as "EmonLib.h" for example, but as @Steve-Mcl commented; if your device has WIFI, MQTT is better option. You could use a WIFI or Ethernet Shield Arduino for example.

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [7 August 2021 19:54 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/10 "2021-08-07T19:54:35Z")

</div>

My arduino doesn't have wifi ,but I have another ESP8266 with wifi I dont know if it can connected with RPI or not  
appreciate if there is a link for video for connecting RPI with ESP8266 with MQTT  
and many thanks for your help

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [7 August 2021 20:13 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/11 "2021-08-07T20:13:27Z")

</div>

Yes @mustafa you can connect your ESP8266 with Node-RED via MQTT. For this you need some things:

1.- Download and install ["PubSubClient.h"](https://pubsubclient.knolleary.net/) library, look at the code examples, to understand. This will allow you set your ESP8266 as Client MQTT to Publish and Subscribe messages to Node-RED.

2.- You need some one MQTT Broker, to manage the communication, maybe you can use: [Mosquitto BROKER](https://mosquitto.org/), you can install it in your same Raspberry pi.

3.- Node-RED has two nodes to communicate with MQTT: MQTT in / out.

[video support.](https://www.youtube.com/watch?v=NI39fZvupaQ&t=64s)  
[video support 2](https://www.youtube.com/watch?v=am04ceNFBQA&t=408s)

I hope it helps you!!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 August 2021 20:33 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/12 "2021-08-07T20:33:42Z")

</div>

Also read this tutorial which will tell you all you need to know about the principles of MQTT. [MQTT Essentials - All Core Concepts explained](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 October 2021 20:34 UTC](https://discourse.nodered.org/t/display-arduino-readings-via-node-red/49425/13 "2021-10-06T20:34:15Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
