Datalogging With MQTT, NODE-RED, INFLUXDB, GRAFANA Using RASPBERRY PI
Datalogging With MQTT, NODE-RED, INFLUXDB, GRAFANA Using RASPBERRY PI
Resources
Raspberry Pi Imager
Pi My Life guide to installing InfluxDB
Official guide to installing Node-RED on Raspberry Pi
Official guide to install Grafana on Raspberry Pi
The plan
Whatever data source you want to record, there are a few
common building blocks that you will need. Each of these
building blocks has multiple alternatives. There are also
totally different architectures that do things in a different
way.
Prepare Raspberry Pi
Begin by installing Raspberry Pi OS (formerly known as
“Raspbian”) on your Raspberry Pi. The easiest way to do it
these days is to use the Raspberry Pi Imager, which runs on
Windows, MacOS, or Linux and can be downloaded
from www.raspberrypi.org/downloads/.
Command: ipconfig
This will create a text file called “pwfile” with the details in
them.
mosquitto_passwd -U pwfile
Display the contents of the file to verify that it has now been
encrypted:
cat pwfile
allow_anonymous false
password_file /etc/mosquitto/pwfile
From now on, all connections to your MQTT broker will need
to supply the username and password that you configured.
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo
393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c
influxdata-archive_compat.key' | sha256sum -c && cat influxdata-
archive_compat.key | gpg --dearmor | sudo tee
/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg]
https://repos.influxdata.com/debian stable main' | sudo tee
/etc/apt/sources.list.d/influxdata.list
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add
Now you can add the repository. There are a few different
versions available, so you need to copy and paste the
command that matches your operating system.
To find out what version you’re running, you can type the
following command:
lsb_release -a
influx
Now you can exit out of InfluxDB. Simply type “exit” and
press ENTER.
exit
auth-enabled = true
pprof-enabled = true
pprof-auth-enabled = true
ping-auth-enabled = true
From now on, any time you want to connect to the InfluxDB
command line you will need to supply the username and
password.
exit
You can start the service manually this time, but in future it
will happen automatically when your Pi starts up:
sudo systemctl start nodered.service
If you are using the example Arduino sketch for the Air
Quality Sensor, open it in the Arduino IDE and go to the tab
called “config.h”. Edit the broker IP address and the MQTT
username / password to match your own settings:
After the sensor starts up with the new settings, you should
see some action in the Mosquitto client! You’ll see a startup
message from the sensor, and then it will periodically begin
publishing its readings.
Step 6: Receiving and storing
single-value sensor readings
aoeu
http://192.168.1.248:3000
1. Open a terminal.
1. Open a terminal.
ifconfig
3. Look under the eth0 entry (for wired connection) or
wlan0 (for wireless). The inet address is your IP.
1. Open a terminal.