Blog·

Node-Red, InfuxDB & Grafana Installation

Written in 2019. Software versions and links may have changed since – check the comments under the YouTube video for updates.

Raspberry Pis are very good for monitoring all sorts of things. Today we will use Node-Red, InfluxDB, and Grafana for monitoring as well as enable Smartphone and Mail alarming.

Passwords

Where User Password
Raspberry Pi raspberry
Node-Red Flows admin admin
Node-Red UI User user
InfluxDB User Pi raspberry
Grafana admin admin

Prepare Image on SD card

Download image: http://bit.ly/2GdZbPe
Add empty ssh file to root directory of the card
Add wpa_supplicant.conf to root directory

Content of wpa_supplicant.conf file:

country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid=”…”
  psk=”…”
}

Insert SD card into your Raspberry, boot, and find its IP address using https://www.advanced-ip-scanner.com
Log-in using Putty https://www.putty.org/
update your Raspberry to the newest version:

 sudo apt-get update && sudo apt-get upgrade

Configuration on the Raspberry

Configuration of Mosquitto

sudo nano /etc/mosquitto/mosquitto.conf

insert:
allow_anonymous true

Restart Mosquitto

 sudo systemctl restart mosquitto

Configuration of influxDB

Create User:

CREATE USER "pi" WITH PASSWORD 'raspberry' WITH ALL PRIVILEGES
exit

Change config file:

sudo nano /etc/influxdb/influxdb.conf

In [http] uncomment:
enabled = true and bind-address=:8086

in [monitor] uncomment and change to:
store-enabled = false

sudo service influxdb restart

Configuration of Node-Red

Import Flows from: https://drive.google.com/open?id=1kECuykSaFO7Qb_67QqIHtlpvElpVWDMI

Install Mail

sudo apt-get install ssmtp  
sudo apt-get install mailutils
sudo nano /etc/ssmtp/ssmtp.conf

For Gmail enter this text:

mailhub=smtp.gmail.com:587
AuthUser=[yourmailaddress]@gmail.com
AuthPass=[emailPassword]
UseSTARTTLS=YES
UseTLS=YES

Test your Mail

echo "Hello world email body" | mail -s "Test
Subject" sensorsiot@gmail.com

Add support for less secure apps in Gmail: https://myaccount.google.com/lesssecureapps

Create influxDB database

influx

Create database [your databaseName]
Show DATABASES
Use [your databaseName]
Show series

exit

Install and prepare Telegram

Install Telegram on your PC https://desktop.telegram.org/

Start telegram and search for “botfather”

Enter the name of your desired bot. Note down the token.
Send a text message to the bot.

Go to: https://api.telegram.org/bot[Token]/getUpdates

and take a note of the ID. We will use it later:

Prepare Grafana

Add source

Add Dashboard by importing a JSON file:

Examples:
Beer Pressure: https://drive.google.com/open?id=1beKyu4WuGErAHeYKyE3-8wtpyZJ8yHkZ
Weather: https://drive.google.com/open?id=18326_tjcVln0xBLRJINJn2ZwP0lNlyHX
YouTube: https://drive.google.com/open?id=1TrZAGnxn4zRfyO_X8RXw4ZtQIvJi8JnQ

Add Mail Notification Channel

sudo nano /etc/grafana/grafana.ini

enabled=true
host = smtp.gmail.com:587
user =[receivingEmail]@gmail.com
password =“[emailPassword]“
skip_verify = true
from_address = [sendingEmail]@gmail.com
from_name = [whateverName]

Go to notification Channels

Add new Channel

Edit notification channel

And press “Send Text”

Add Telegram Notification Channel

Add new Telegram Notification Channel

Insert chatID and token from before

And press “Send Test”

You are done!