Store Arduino sensor network data in an SQL database

Arduino Calling SQL

© Lead Image © 3355m, 123RF.com

© Lead Image © 3355m, 123RF.com

Article from Issue 293/2025
Author(s):

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

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • WiFi Thermo-Hygrometer

    A WiFi sensor monitors indoor humidity and temperature and a Node-RED dashboard reports the results, helping you to maintain a pleasant environment.

  • Low-Code with Snap4Arduino

    Snap4Arduino brings the power of low-code programming to the Arduino hardware environment.

  • Node-RED

    Node-RED lets you connect ready-made code building blocks to create event-driven applications with little or no code writing.

  • IoT with RabbitMQ

    Connect multiple protocols and servers together on your IoT projects.

  • IoT with Redis Servers

    Include binary data and image files in your IoT projects with Redis, an open source, in-memory data structure store.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News