In the last post we wrote the Arduino code - the one that collects the data from all the sensors.
But we need a way to send this data to the Raspberry Pi so we can store it in our DB.
First thing first, we need a DB - I hate MySQL, so I looked online for a mainstream DB that is supported by Grafana and decided to go with InfluxDB;
Why? Simply because it was the first result on Google, and lets be honest, we don’t want to over-complicate things.
You can find here an article on how to install InfluxDB on your Pi.After installing and starting the DB, create two DBs:
Yes, it’s that easy…
sensors_data will hold… our sensors data received from the Arduino, and events will hold events such as errors, heaters on/off triggers etc.
Now that we got this out of the way, we can proceed to the Python code;
Before you begin make sure you have all these libraries installed, how? just import everything and see if it works, if not - pip3 it.
influxdb_client is important, make sure you have the correct version.
The code will start a few different processes:
All this Shabeng will get the variable from config.json file, such as DB information, socket information, fan speeds and more.
We also have calibrations.json which will offset all the sensor results based on the existing data in the json file (remember that I told you to write it down?)
You can download everything from the Github page.
Happy new year!
~Tal