ROCKPI_E and Waveshare current hat (i2c)

Hello.

Until now i used a Raspberry pi Modul 4 with a WAVESHARE current hat to measure a 4-20 mA Signal. For this i am using node red and this node: node-red-contrib-easybotics-ina219-sensor (node) - Node-RED. All is woking as expected.

The problem now: Like i mentioned i am using am Raspberry pi model 4. This model has only 1 ETH port. For my project it is essential to have 2 working ETH ports. Until now i was using a USP to ETH adapter which worked.

I now tried to migrate to a Rockpi E (Rock Pi E D8 Dual Ethernet Board RK3328 1GB RAM oh. Wifi/BT | Rock Pi E | Rock Pi/Radxa | Single Board Computer | Single Board Computer | ALLknow Store) because it is cheaper and hast 2 ETH ports an BT.

I am now facing the problem, that i cant install the node easybotics, that i mentioned above. I always get an error like :

rock@rockpie:~$ npm install node-red-contrib-easybotics-ina219-sensor
npm ERR! code 1
npm ERR! path /home/rock/node_modules/i2c-bus
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@18.16.1 | linux | arm64
npm ERR! gyp info find Python using Python version 3.7.3 found at "/usr/bin/pyth on3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/rock/.nvm/versions/node/v18.16.1/lib/node_ modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/rock/node_modules/i2c-bus/build/config.gyp i',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/rock/.nvm/versions/node/v18.16.1/lib/node_ modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/rock/.cache/node-gyp/18.16.1/include/node/ common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/rock/.cache/node-gyp/18.16 .1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/rock/.nvm/versions/node/v18 .16.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/rock/.cache/node-gyp/18.16 .1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/rock/node_modules/i2c-bu s',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
npm ERR! gyp ERR! stack at getNotFoundError (/home/rock/.nvm/versions/node/v 18.16.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:1 0:17)
npm ERR! gyp ERR! stack at /home/rock/.nvm/versions/node/v18.16.1/lib/node_m odules/npm/node_modules/node-gyp/node_modules/which/which.js:57:18
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at step (/home/rock/.nvm/versions/node/v18.16.1/lib/ node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:54:21)
npm ERR! gyp ERR! stack at /home/rock/.nvm/versions/node/v18.16.1/lib/node_m odules/npm/node_modules/node-gyp/node_modules/which/which.js:71:22
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at subStep (/home/rock/.nvm/versions/node/v18.16.1/l ib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:69:33)
npm ERR! gyp ERR! stack at /home/rock/.nvm/versions/node/v18.16.1/lib/node_m odules/npm/node_modules/node-gyp/node_modules/which/which.js:80:22
npm ERR! gyp ERR! stack at /home/rock/.nvm/versions/node/v18.16.1/lib/node_m odules/npm/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /home/rock/.nvm/versions/node/v18.16.1/lib/node_m odules/npm/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! System Linux 4.4.194-19-rockchip-g287ff75afc47
npm ERR! gyp ERR! command "/home/rock/.nvm/versions/node/v18.16.1/bin/node" "/ho me/rock/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/b in/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/rock/node_modules/i2c-bus
npm ERR! gyp ERR! node -v v18.16.1
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

to be honest, i dont realy understand this error. Has anyone an idea?

thank you

You have not installed the build tools. Normally that would be done using
sudo apt install build-essential
but whether that applies to your OS I don't know.

Also you were trying to install the node from the wrong folder. Normally that folder is ~/.node-red. It is where the flows file is.

Also I notice that you have used nvm to install nodejs. Generally that is not a good idea as confusion can arise about which version to use.

Hello,

thank you for your answer.

to be honest, now i have a couple more questions.

I have installed this OS: Rock4/Debian - Radxa Wiki.

Is there a correct way to install node-red, that potential problems can be minimized?

May usual way to install node red is on a freshly set up device:

sudo apt-get update
sudo apt-get dist-upgrade

sudo apt install nano
sudo apt install curl
sudo apt install ufw

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

sudo systemctl enable nodered.service

sudo reboot

how do i have to install npm correct, that to install nodejs. now that you mentioned it, there were often warnings that node red should be installed with npm, but i weighted this warning not to much importance. probably a mistake.

thank you

The instructions for running that script also say that you should install build-essential and git

As for the fact that nvm is has been used to install nodejs, as can be seen from the line

Then if you did not do do it I can only assume that the OS comes with it installed that way already. In which case I recommend completely getting rid of nvm (you will have to google that) and delete the .nvm folder, then run the install script again to make sure a good version of nodejs is installed.

1 Like

Thank you.

I set up a new OS and tried it again.

sudo apt-get update
sudo apt-get dist-upgrade

sudo apt install nano
sudo apt install curl
sudo apt install ufw

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

and i get this error:

Stop Node-RED \u2714
Remove old version of Node-RED \u2714
Remove old version of Node.js \u2714
Install Node.js 16 LTS \u271\u2718 Bad install: Node.js v10.24.0 Npm missing - E xitlean npm cache
Install Node-RED core
Move global nodes to local
Npm rebuild existing nodes
Install extra Pi nodes
Add shortcut commands
Update systemd script

I dont get it. I thought this script will install npm and the necessary node.js

What do is miss?

And i get this when i run this command before the script: sudo apt install build-essential git curl

Node-RED v3.x no longer supports Nodejs 10

You can force an install of node 14, 16 or 18 by using the --node14, --node16 or --node18 parameter.
However doing so may break some nodes that may need re-installing manually.
Generally it is recommended to update all nodes to their latest versions befor e upgrading.

If you wish to stay on nodejs 10 you can update to the latest Node-RED 1.x or 2.x version by adding
--nodered-version="1.3.7" or --nodered-version="2.2.2" to that install command . If in doubt this is the safer option.
Please backup your installation and flows before upgrading.

thank you

What do
which node
and
apt policy nodejs
show?

Thank you again sir for the support.

rock@rockpie:~$ which node
/usr/bin/node
rock@rockpie:~$ apt policy nodejs
nodejs:
Installed: 10.24.0~dfsg-1~deb10u3
Candidate: 10.24.0~dfsg-1~deb10u3
Version table:
*** 10.24.0~dfsg-1~deb10u3 500
500 http://security.debian.org buster/updates/main arm64 Packages
100 /var/lib/dpkg/status
10.24.0~dfsg-1~deb10u1 500
500 Index of /debian buster/main arm64 Packages

I read that the script leaves node.js untouched if it detects node.js > 10. So i tried to update npm manualy with

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

and confirmed it with:

rock@rockpie:~$ npm -v
9.5.1
rock@rockpie:~$ node -v
v18.16.1

when i run the script i get;

Stop Node-RED \u2714
Remove old version of Node-RED \u2714
Node option not specified : --node14, --node16, or --node18
Leave existing Node.js : v10.24.0 Npm 5.8.0
Clean npm cache -
Install Node-RED core \u2714 3.0.2
npm WARN npm npm does not support Node.js v10.24.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.pdate systemd script
npm WARN npm You can find the latest version at https://nodejs.org/
Move global nodes to local -
Leave existing nodes -/nodered-install.log
Install extra Pi nodes \u2714
Add shortcut commands \u2714
Update systemd script \u2714

after that when i enter the version number i get

rock@rockpie:~$ node -v
-bash: /usr/local/bin/node: No such file or directory
rock@rockpie:~$ npm -v
-bash: /usr/local/bin/npm: No such file or directory
rock@rockpie:~$

after a reboot:

rock@rockpie:~$ node -v
v10.24.0
rock@rockpie:~$ npm -v
5.8.0
rock@rockpie:~$

to be honest i am now at maximum confusion-level..
seems that the script downgrades my npm and node.js versions

You have missed the s off the end.

i have edited the error in my last post

Does the folder ~/.nvm exist? If so then my original advise remains. Uninstall nvm completely and delete the .nvm folder.

hmm as far as i can tell no.

I (hopefully) confirmed it with:

rock@rockpie:~$ find ~/.nvm
find: '/home/rock/.nvm': No such file or directory

rock@rockpie:~$ nvm -v
-bash: nvm: command not found

That says that nodejs version 10.24.0 is installed from the raspbian repository. That must be installed by default by the OS.

You should not have installed npm manually, the correct version will be installed when the node-red installs nodejs for you.

The first thing to do is to uninstall the system supplied version of nodejs and npm.

sudo apt remove nodejs
sudo apt remove npm

Then make sure that node is gone by running

node -v
which node

Then try the script again. If it fails then post the full /var/log/nodered-install.log here.

Hello

I deinstalled node and npm and let the script run. Unfortunly it did not work. It seems that node.js 10.19.0 will always be reinstalled with the script.

the logfile gives me this

Started : Mon Jul 10 13:38:49 CEST 2023
Running for user rock at /home/rock
Failed to stop nodered.service: Unit nodered.service not loaded.
Found global nodes: :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodered
Installing nodejs 16

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodejs-legacy' is not installed, so not removed
Package 'nodejs' is not installed, so not removed
Package 'npm' is not installed, so not removed
The following packages were automatically installed and are no longer required:
libc-ares2 libnode64 nodejs-doc
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
libc-ares2 libnode64 nodejs-doc
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 30.1 MB disk space will be freed.
(Reading database ... ^M(Reading database ... 5%^M(Reading database ... 10%^M(Reading database ... 15%^M(Reading database ... 20%^M(Reading database ... 25%^M(Reading >
Removing libnode64:arm64 (10.19.0~dfsg-3ubuntu1) ...
Removing libc-ares2:arm64 (1.15.0-1ubuntu0.3) ...
Removing nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Grab the LTS bundle

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version (7.68.0-1ubuntu2.18).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Installing the NodeSource Node.js 16.x repo...

Populating apt-get cache...

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libc-ares2 libnode64 nodejs-doc
Suggested packages:
npm
The following NEW packages will be installed:
libc-ares2 libnode64 nodejs nodejs-doc
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 6479 kB of archives.
After this operation, 30.3 MB of additional disk space will be used.
Get:1 Index of /ubuntu-ports focal-security/main arm64 libc-ares2 arm64 1.15.0-1ubuntu0.3 [35.3 kB]
Get:2 Index of /ubuntu-ports focal/universe arm64 libnode64 arm64 10.19.0~dfsg-3ubuntu1 [5440 kB]
Get:3 Index of /ubuntu-ports focal/universe arm64 nodejs-doc all 10.19.0~dfsg-3ubuntu1 [942 kB]
Get:4 Index of /ubuntu-ports focal/universe arm64 nodejs arm64 10.19.0~dfsg-3ubuntu1 [61.2 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 6479 kB in 1s (7747 kB/s)
Selecting previously unselected package libc-ares2:arm64.
(Reading database ... ^M(Reading database ... 5%^M(Reading database ... 10%^M(Reading database ... 15%^M(Reading database ... 20%^M(Reading database ... 25%^M(Reading >
Preparing to unpack .../libc-ares2_1.15.0-1ubuntu0.3_arm64.deb ...
Unpacking libc-ares2:arm64 (1.15.0-1ubuntu0.3) ...
Selecting previously unselected package libnode64:arm64.
Preparing to unpack .../libnode64_10.19.0~dfsg-3ubuntu1_arm64.deb ...
Unpacking libnode64:arm64 (10.19.0~dfsg-3ubuntu1) ...
Selecting previously unselected package nodejs-doc.
Preparing to unpack .../nodejs-doc_10.19.0~dfsg-3ubuntu1_all.deb ...
Unpacking nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_10.19.0~dfsg-3ubuntu1_arm64.deb ...
Unpacking nodejs (10.19.0~dfsg-3ubuntu1) ...
Setting up libc-ares2:arm64 (1.15.0-1ubuntu0.3) ...
Setting up libnode64:arm64 (10.19.0~dfsg-3ubuntu1) ...
Setting up nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
Setting up nodejs (10.19.0~dfsg-3ubuntu1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...

Versions: node:v10.19.0 npm:missing

You told us that you ran sudo apt-get update but you did not tell us that it failed. You need to sort that first. The problem with the radxa repository is nothing to do with node-red.

thank you very much. the problem with node red and node.js was indeed the pubkey problem.

sorry for that. i was so focused on node-red that i missed it.

So far i was able to install node red and my ina219 node.

I made a small example:

[
{
"id": "10a45d2b5f56557d",
"type": "ina-sensor",
"z": "e101447de2b66c15",
"name": "",
"handle": "1c3e2f89e297f582",
"x": 430,
"y": 280,
"wires": [
[
"e7bd1ddc27c874dd"
],
[
"d71139838b0dd349"
]
]
},
{
"id": "e7bd1ddc27c874dd",
"type": "debug",
"z": "e101447de2b66c15",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 200,
"wires":
},
{
"id": "d71139838b0dd349",
"type": "debug",
"z": "e101447de2b66c15",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 700,
"y": 320,
"wires":
},
{
"id": "1c3e2f89e297f582",
"type": "ina-sensor-manager",
"address": "0x40",
"delay": "250",
"ohms": "0.01",
"customResistor": false
}
]

i tried to enable on my rockpi i2c and ran (following this guide Rockpi4/dev/libmraa - Radxa Wiki) a command to detect i2c and got this:

rock@rockpie:~$ sudo mraa-i2c detect 0
[sudo] password for rock:
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

I have my waveshare mounted. does this mean my i2c adress of my device is 18?

thank you

Sorry, I don't know about i2C.

My only experience is with RPI's so things might be a little different with the rockpi_e but it should be similar so the address is 0x18

For an example of doing it on a RPI take a read of this:

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