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?
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?
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:
npm i node-red-node-serialport
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 :
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!!
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) 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
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
For sure @mustafa. I share you this tutorial of serial communication between Arduino and Node-RED 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:
you should see now:
I hope it helps you!!!
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 ??
You must run npm install from your node-red folder /home/pi/.node-red
- you ran it from /home/pi
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.
27 packages are looking for funding
run npm fund
for details
found 0 vulnerabilities
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
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.
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
Yes @mustafa you can connect your ESP8266 with Node-RED via MQTT. For this you need some things:
1.- Download and install "PubSubClient.h" 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, you can install it in your same Raspberry pi.
3.- Node-RED has two nodes to communicate with MQTT: MQTT in / out.
video support.
video support 2
I hope it helps you!!
Also read this tutorial which will tell you all you need to know about the principles of MQTT. MQTT Essentials - All Core Concepts explained
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.