The first thing is creating a default configuration that we will modify to adapt it to our scenario: sudo docker run -rm telegraf telegraf config > nf sudo docker pull telegrafīefore using Telegram, it is necessary to configure it.
It is time to install and configure Telegraf, the component that connects to the MQTT broker subscribing to the channel where sensor data is published and store this information into the InfluxDB.
With these few lines, we have created a database named sensors and a user with username telegraf and password telegraf. Next, let us create the database and the user: create database sensors create user "telegraf" with password "telegraf" grant all on sensors to telegraf The user will be used by Telegraf when it accesses to the database to store the data coming from the MQTT channel.įirst, start the InfluxDB CLI: docker exec -it influxdb influx The next step is creating the database and the user that will access this database.
In this case, we start the database as deamon and we create a volume to store the data in /var/lib/influxdb: How to Create an InfluxDB Database and User Once the installation is complete, it is possible to start InfluxDB: sudo docker run -d -p 8086:8086 -v influxdb:/var/lib/influxdb -name influxdb influxdb As you may already know, InfluxDB is a time-series database where we can store data time-dependant. Once the Mosquitto is up and running, we can install and configure InfluxDB.
Wait until the download complete and then you can start the MQTT broker: sudo docker run -it -p 1883:1883 -p 9001:9001 eclipse-mosquitto To do it, we will use Docker so that we can install all we need easily: sudo docker pull eclipse-mosquitto Just remember: Mosquitto is the MQTT broker. The first step is installing Mosquitto on Raspberry Pi. Installing and Configuring Mosquitto on Raspberry Pi Using Docker First, we start building and configuring all these components.ĭuring this tutorial, we will assume that Docker is already installed on your Raspberry Pi. Now, we know all the components and the role they play we can build the system.
While the ESP8266 manages the sensors that send data using the MQTT protocol. The Raspberry Pi acts as a central server that runs the following components:
This Raspberry Pi IoT tutorial will build an IoT system that monitors sensors using InfluxDB, MQTT, and Grafana. Learn how to build a dashboard based on Grafana that visualizes data acquired by sensors.