Skip to content

Commit

Permalink
Added option to install SQLite node in Node-RED, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
gcgarner committed Oct 29, 2019
1 parent 533ad97 commit d57ccc2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
Docker stack for getting started on IoT on the Raspberry Pi.

This Docker stack consists of:
* nodered
* grafana
* influxDB
* postgres
* mosquitto mqtt
* portainer
* adminer
* Node-RED
* Grafana
* InfluxDB
* Postgres
* Mosquitto mqtt
* Portainer
* Adminer
* openHAB

In addition, there is a write-up and some scripts to get a dynamic DNS via duckdns and VPN up and running.

Firstly what is docker? The correct question is "what are containers?". Docker is just one of the utilities to run container.

Container can be thought of as ultra-minimal virtual machines. You download a preconfigured base image and create a new container and only the differences between the base and your "VM" are stored.
Container can be thought of as ultra-minimal virtual machines, they are a collection of binaries that run in a sandbox environment. You download a preconfigured base image and create a new container and only the differences between the base and your "VM" are stored.
Containers don't have [GUI](https://en.wikipedia.org/wiki/Graphical_user_interface)s so generally the way you interact with them is via web services or you can launch into a terminal.
One of the major advantages is that the image comes mostly preconfigured.

There are pro's and cons for using native installs vs containers. For me, one of the best parts of containers is that it doesn't "clutter" your device, and if you don't need Postgres anymore then just stop the container and delete it and it's like it was never there.

It's not advised to try to run the native version of an app and the docker version, the container will fail. It would be best to install this on a fresh system.

For those looking for a script that installs native applications check out Peter Scargill's [script](https://tech.scargill.net/the-script/)

# Tested platform
Raspberry Pi 3B and 4B Raspbian (Buster)
Expand All @@ -28,16 +34,9 @@ Please direct all feature requests to [Discord](https://discord.gg/W45tD83)
# Youtube reference
This repo was originally inspired by Andreas Spiess's video on using some of these tools. Some containers have been added to extend its functionality.

[Yolutube video](https://www.youtube.com/watch?v=JdV4x925au0): This is an alternative approach to the setup. Be sure to watch the video for the instructions. Just note that the network addresses are different, see note below

For those looking for a script that installs native applications check out Peter Scargill's script
https://tech.scargill.net/the-script/
[YouTube video](https://www.youtube.com/watch?v=JdV4x925au0): This is an alternative approach to the setup. Be sure to watch the video for the instructions. Just note that the network addresses are different, see note below

There are pro's and cons for using native installs vs containers. For me, one of the best parts of containers is that it doesn't "clutter" your device, and if you don't need Postgres anymore then just stop the container and delete it and it's like it was never there.

It's not advised to try to run the native version of an app and the docker version, the container will fail. It would be best to install this on a fresh system.

## Download the project
# Download the project

```
git clone https://github.com/gcgarner/IOTstack.git ~/IOTstack
Expand Down Expand Up @@ -198,11 +197,17 @@ Edit the file called services/mosquitto/mosquitto.conf and remove the comment in
# Node-RED
https://hub.docker.com/r/nodered/node-red

## Build warning
The Node-RED build will complain about several issues. This is completely normal behaviour.

## SQLite
Thanks to @fragolinux the SQLite node will install now. WARNING it will output many error and will look as if it has gotten stuck. Just give it time and it will continue.

## GPIO
To communicate to your Pi's GPIO you need to use the `node-red-node-pi-gpiod` node. It allowes you to connect to multiple Pis from the same nodered service.

You need to make sure that pigpdiod is running. The recommended method is listed [here](https://github.com/node-red/node-red-nodes/tree/master/hardware/pigpiod)
You run the following command `sudo nano /etc/rc.local` and add the line `/usr/bin/pigpiod` above `exit 0` and reboot the Pi. there is an option to secure the service see the writeup.
You run the following command `sudo nano /etc/rc.local` and add the line `/usr/bin/pigpiod` above `exit 0` and reboot the Pi. There is an option to secure the service see the writeup for further instuctions.

Drop the gpio node and use your Pi's IP. Example: 192.168.1.123 (127.0.0.1 won't work because this is the local address of every computer'.)

Expand Down
10 changes: 10 additions & 0 deletions menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ node_selection=$(whiptail --title "Node-RED nodes" --checklist --separate-output
"node-red-node-random" " " "OFF" \
"node-red-node-smooth" " " "OFF" \
"node-red-node-darksky" " " "OFF" \
"node-red-node-sqlite" " " "OFF" \
"node-red-contrib-influxdb" " " "ON" \
"node-red-contrib-config" " " "OFF" \
"node-red-contrib-grove" " " "OFF" \
Expand All @@ -74,17 +75,26 @@ node_selection=$(whiptail --title "Node-RED nodes" --checklist --separate-output

nr_dfile=./services/nodered/Dockerfile

sqliteflag=0

touch $nr_dfile
echo "FROM nodered/node-red:latest" > $nr_dfile
#node red install script inspired from https://tech.scargill.net/the-script/
echo "RUN for addonnodes in \\" >> $nr_dfile
for checked in "${checked_nodes[@]}"; do
#test to see if sqlite is selected and set flag, sqlite require additional flags
if [ "$checked" = "node-red-node-sqlite" ];
then
sqliteflag=1
else
echo "$checked \\" >> $nr_dfile
fi
done
echo "; do \\" >> $nr_dfile
echo "npm install \${addonnodes} ;\\" >> $nr_dfile
echo "done;" >> $nr_dfile

[ $sqliteflag = 1 ] && echo "RUN npm install --unsafe-perm node-red-node-sqlite" >> $nr_dfile
}

#---------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit d57ccc2

Please sign in to comment.