Store Arduino sensor network data in an SQL database
Arduino Calling SQL

© Lead Image © 3355m, 123RF.com
If you need to store long-term historical data, you can cobble together some Arduino modules, sensors, and displays and get them all to talk to an SQL server.
In most Arduino projects, devices use messaging protocols like Message Queuing Telemetry Transport (MQTT) [1] or custom dashboard platforms such as Arduino Cloud [2] or ThingsBoard [3] to talk to each other. While those two approaches offer excellent solutions for viewing short-term sensor data, they have limitations when used for long-term historical storage.
A common solution that supports historical storage is to connect MQTT brokers to data-logging packages like Node-RED, InfluxDB, or Grafana. Another approach is to install SQL drivers on the Arduino controllers and then pass sensor data directly to a database server. There are Arduino C/C++ libraries for MariaDB/MySQL, Microsoft SQL, PostgreSQL and even local SQLite 3 databases. SQL-based solutions have some useful benefits such as:
- No intermediate storage is required
- Access raw historical data or aggregate calculations
- Write custom queries
- Use back-end views and procedures to minimize dashboard code
[...]
Buy this article as PDF
(incl. VAT)