Storing data in a database using InfluxDB
We will have to configure two parameters to be able to start storing temperatures in the InfluxDB database:
- The InfluxDB database
- A user to access the database
We learned how the InfluxDB database works and how to create it in the Installing and creating databases using InfluxDB subsection in Chapter 7. I recommend you review that subsection, where I showed you how to create the Temperatures InfluxDB database we will use in this project.
Configuring a user to access the database is required to get credentials to store data in the InfluxDB database. We will do this by following these steps:
- Open Settings | Add-ons | InfluxDB and click on the OPEN WEB UI button. The Chronograf interface will open.
- Select the crown icon titled InfluxDB Admin in the Cronograf sidebar.
- Click on the Users tab and then on the + Create User button. In the Create User window, fill the User Name field with
your_name
, and in the Password field, addyour_password
. Click on the Create button. Theyour_name
user will be created. - On the next screen, make sure to set permissions for writing and reading in the Temperatures database by clicking on the WRITE and READ buttons.
- Click on the Apply Changes button in the top-right corner of the screen. Then, click on the Exit button in the top-right corner. The Users tab should look like Figure 10.27:
Figure 10.27 – The created your_name username
As you can see in Figure 10.27, the your_name
user now has read and write access to the Temperatures database.
Surprisingly, there is nothing else to be configured in InfluxDB to store data in the Temperatures database. You should now return to Node-RED and verify that you will not continue to receive the 401
error type you got in the last section.
We can now manipulate the data in the database and present them in charts using Grafana. We will do this in the next section.