Questions from a Newbie - Looking for Help

Hi. I am new to Node-Red, and haven't done much with Pi. In my current project, I came across a few problems. Most of them are solved, thanks to this forum.

Now, I have 4 problems left:
1- Starting Node-Red at boot, and deploying the project at full screen. Goal here is to give user only the project screen on a touchscreen, blocking the user from doing anything beyond touching the on/off button on the screen, after plugging the system up.

2- Without doing any changes, I sometimes get "Connection Lost" errors. Sometimes too frequently, sometimes once in a few hours. I think this is because of the wiring. I was using a breadboard, but I'm going to solder it, and then see what happens. Another thing that may cause this (I think), is maybe computational limitations. Maybe this is the reason I sometimes get the error after it running for a few hours. Never had a problem like this one, so I am not sure. Lastly, maybe the NOOBS OS can be the problem. I have a Raspberry Pi 4 B+ with 2GB RAM. A friend of mine told me that he even used it as a personal computer for 3 months without having a single issue like freezing. Mine keeps freezing at simple tasks like opening a new tab, or clicking somewhere before typing. Sometimes, I even see letters coming up 3-4 seconds later while I am typing something. My friend said that this never happened to him. Also, I checked updates at day 1, and there were no updates that I needed to download.

3- Chromium notifies me that it needs a manual update, because it is too old. When I click on it, it opens up the page to install Chrome, not Chromium. Would I need to configure anything, if I were to download and use Node-Red on Chrome? Also, can this be the cause of the problem I mentioned in "2"?

4- I need to use a Water Flow Sensor to give an error notification, if there is no flow, or not enough flow. I have YF-S201 Water Flow Sensor. I searched for a while, but I couldn't find a node for that. I found a Python script in this link:

I tried to run a Python script in Node-Red, and I managed to turn on and off an LED, but I couldn't do the main thing I was trying to do at that time. So, I'd prefer using a node for this sensor, or another hall effect node to make it work. I'd be really happy, if you could share a link for the sensor's node, or any node I can use with it. If you don't know any, can you guide me on how to run this Python script on Node-Red?

What are you trying to start at boot, the browser or node-red. Assuming you installed using the script from the docs then you can tell the system to start node-red at boot by doing
sudo systemctl enable nodered
Note, no dash in nodered.
As for opening the browser in fullscreen (if that is what you mean) then that isn't a node-red issue, I don't know the answer.

For the freezing problem I made some suggestions in your previous thread, but you haven't mentioned which you have done and whether they helped.

Again, nothing to do with node-red. Someone here might have a clue, but not me.

You may want to look at "kiosk mode" to restrict input to a single app (the browser) on a single page.

However, this wouldn't be all that secure fundamentally. Better would be to run the Node-RED server on a locked-away device with just the front-end and browser on the user accessible device.

To what? you don't say. Also what frequency are your data updates and how large.

Again, I'll point out that running a full desktop on the same device as Node-RED is generally not a brilliant experience unless you are using a Pi 4 with a reasonable amount of RAM.

That is a Pi issue not a Node-RED issue.

Since you have found a node.js package for it, you should be able to use that at least in a Node-RED function node by adding the require for it in your settings.js file's globals section. you can then do something like const wfs = global.get('water-flow-sensor') in the function node.

Can you explain the part where you answered the 4th question in more detail?

Node-RED is built using node.js. Node.js uses the npm package manager. So you can add any npm package to Node-RED by installing the package to your userDir folder (normally ~/.node-red) and then using node.js's standard require function inside the globals section of your settings.js file that configures Node-RED. You will find that file also in your userDir folder. It has an example embedded in it. Search for require in the file.

Once you've loaded the package via require and assigned it to a global variable, you can reconnect to it in a function node using the code I gave previously. After that, you should be able to use it as per the examples from that package.

You should note that, as a complex platform, occasionally packages loaded this way don't work as expected but most things do.

This is also described in the section Loading additional modules in the node-red docs page Writing Functions.

1 Like

Can be solved with the workaround from below post. I tried and it worked for me.

Thanks a lot! This solved that problem!

Nice to know. Surprisingly for me is that the same fix seems to have resolved also issue #1, that was also happening on my testing lab. I could not spare time to investigate further though.

Good to know!

I couldn't find "settings.js". It doesn't exist in the "~/.node-red" folder. What can I do?

Please issue the following commands on a terminal session on the pi

cd .node-red
ls -al

copy the results and paste them to a response

1 - did you install the desktop or lite version of raspbian on the Pi
2 - are you trying to run the browser directly on the Pi

> total 144
> drwxr-xr-x   4 pi pi  4096 Jul 20 10:27 .
> drwxr-xr-x  24 pi pi  4096 Jul 19 16:06 ..
> -rw-r--r--   1 pi pi 19332 Jul 16 16:22 .config.json
> -rw-r--r--   1 pi pi 19333 Jul 16 16:22 .config.json.backup
> -rw-r--r--   1 pi pi  9198 Jul 19 15:22 flows_raspberrypi.json
> -rw-r--r--   1 pi pi  9198 Jul 19 15:19 .flows_raspberrypi.json.backup
> drwxr-xr-x   3 pi pi  4096 May 27 11:01 lib
> drwxr-xr-x 136 pi pi  4096 Jul 20 10:27 node_modules
> -rw-r--r--   1 pi pi   367 Jul 20 10:27 package.json
> -rw-r--r--   1 pi pi 58473 Jul 20 10:27 package-lock.json

1- Full version from NOOB OS.

2- Yes. I am using Chromium.

Did you install node-red using the script or are you using the version that comes with raspbian?

The one that comes with raspbian.

And how do you start node-red?

Pi icon -> Programming -> Node-Red.

in a terminal window run this command
find . -name settings.js

I would suggest you open a terminal window on the pi and run the script to bring NR asnd node.js up to the current levels. The preinstalled version of NR is always behind the current version. This will also allow you to have NR start as a system service so it will start when you boot the Pi.

> pi@raspberrypi:~/.node-red $ find . -name settings.js
> pi@raspberrypi:~/.node-red $

Nothing happened. Then, I did this:

> pi@raspberrypi:~ $ find . -name settings.js
> ./.config/chromium/Default/Extensions/cjpalhdlnbpafiamejdnhcphjbkeiagm/1.27.10_0/js/settings.js

It is not the one we are looking for.

Run the script

bash <(curl -sL

and then start node-red (in a terminal use node-red) and then add an inject node and deploy. Then stop node-red (in the terminal do a ctrl-c - then look in the .node-red folder and see if the settings file is there.