ESP32: How to Log Data (9 Different Ways).

If you want a specific datalogging example with sensing units, we also have the list below jobs (you can conveniently modify the tasks to use other sensors):

ESP32 How to Log Data 9 Different Ways

Advantages of making use of a microSD card with the ESP32 for datalogging:

However, you need to take right into account some of the adhering to disadvantages:

1) ESP32 Datalogging using a MicroSD Card

ESP32 microSD card module wiring breadboard

The ESP32 consists of a Serial Peripheral Interface Flash File System (SPIFFS).

Advantages of using SPIFFS or LittleFS with the ESP32 for datalogging:

Disadvantages:

Firebase is Google’s mobile application development system that provides numerous devices to conserve information:

After saving your data on Firebase, you can access all the data online by going to your Firebase console.

If you want to discover how to make use of Deta Base with the ESP32, you can follow our guide:

  • Low-cost solution: microSD card modules are very cheap.
  • Huge storage capacity: microSD cards are widely available and can save huge amounts of data.
  • Easy to use: it is easy to connect and easy to program with the ESP32.
  • Doesn’t require a connection to the internet: so it’s an interesting solution in remote places.
  • It can save data in different file formats.

Advantages of using Deta Base with the ESP32:

  • Extra hardware: unless your board already comes with a built-in microSD card slot, you’ll need to get a microSD card module.
  • Data corruption: after long periods of using the microSD card, it might be corrupted and you’ll lose all your data;
  • Data is not accessible in real-time: you need to remove the microSD card from the board and insert it into your computer to access the data (unless you build a webserver that serves the microSD card files online).

2) Save Files on the ESP32 Filesystem (SPIFFS or LittleFS)

Disadvantages:

ThingSpeak is an IoT system in which you can produce channels to store data.

If you want a particular datalogging instance with sensors, we likewise have the list below projects (you can easily change the projects to make use of other sensors):

Advantages of utilizing a microSD card with the ESP32 for datalogging:

However, you require to take right into account some of the following downsides:

The ESP32 contains a Serial Peripheral Interface Flash File System (SPIFFS).

  • Easy to use: it is compatible with the FS.h library —it’s also used with the microSD card to create and handle files.
  • No extra hardware needed: all ESP32 boards comes with a flash chip, so you can use SPIFFS or LittleFS straight away.
  • Doesn’t require internet connection.

Advantages of making use of SPIFFS or LittleFS with the ESP32 for datalogging:

  • Storage limit: the number and size of files you can save will depend on the flash chip memory size. Most will be in the range of 4MB, so the SPIFFS/LittleFS partition will be lower than that. Additonally, you can’t use all SPIFFS partition memory for storage, only about 75%—.
  • Not suitable for long term datalogging or very frequent writes: read and write to the filesystem might become slower as the available memory decreases.
  • Not easy to visualize your data: if you need to access all your data to process it later, you’ll need to write a sketch that gets all data saved in spiffs, or a server that provides access to the filesystem files.

3) ESP32 Save Data to the Firebase Realtime Database

Firebase logo

Disadvantages:

  • Realtime Database: realtime, cloud-hosted, NoSQL database; data is stored in a JSON structure.
  • Cloud Firestore: realtime, cloud-hosted, NoSQL database; data is stored in “documents”.
  • Cloud Storage: scalable file storage to upload and download files.

Firebase is Google’s mobile application advancement platform that supplies numerous devices to conserve data:

Firebase Realtime Database Datalogging

After saving your information on Firebase, you can access all the information online by going to your Firebase console.

Advantages of making use of InfluxDB for Datalogging with the ESP32:

Disadvantages:

  • Access from anywhere: after submitting the data, it is available online and you can check it from anywhere in the world;
  • Store and retrieve data in real-time: the data submitted to the Firebase Realtime Database synchronizes in real-time with other devices and services (if you have several boards or a web app listening to that database, it receives the changes almost instantly);
  • Free usage for small projects: for personal projects, you can use Firebase tools for free until a predefined storage limit;
  • Flexibility: It’s great if you want to build a web app for your IoT projects and you need to save different types of data;
  • Users and authentication: Firebase services provide tools to easily handle users and authentication.

Deta Base is a NoSQL database.

  • Might be difficult to get started: You need to set up a Firebase project with authentication methods, database rules, and other settings that might be difficult for beginners (but if you follow our , you’ll get everything set up in no time);
  • Requires internet connection: the ESP32 needs to be connected to the internet to connect with Firebase services, if the ESP32 is used in an environment without internet access, it will not be able to communicate with Firebase.
  • Additional costs: Firebase has a free plan that’s usually more than enough for personal applications, but if you need more data storage, you’ll need to get a paid plan. However, the free plan was always more than enough for our projects.

4) InfluxDB Time Series Database

ESP32 ESP8266 Sensor Readings Dashboard InfluxDB

If you desire to discover how to use Deta Base with the ESP32, you can follow our guide:

Advantages of making use of Deta Base with the ESP32:

Disadvantages:

ThingSpeak is an IoT system in which you can create networks to save data.

Advantages of saving ESP32 data to Google Sheets:

Disadvantages:

  • It’s a time-series database: each reading you submit to the database will be associated with a specific timestamp. You don’t need to get the date and time on the ESP32.
  • Dashboard with customizable charts: InfluxDB user interface provides tools for building custom dashboards to visualize your data. Without any knowledge of web programming, you can build awesome dashboards with customizable charts.
  • It’s available online: if you use InfluxDB cloud storage, you can access your data from anywhere in the world by accessing your InfluxDB account.
  • Also available offline: if you want to have full control over your data, you can also install InfluxDB on your own cloud server, or .

You can set up a MySQL Database on a cloud server and then, make requests with the ESP32 to publish as well as fetch information.

  • Requires installation: you need to install and/or setup InfluxDB first, which might require an extra step on your project;
  • Only time-based data: all data is associated with a specific timestamp, so it might not be the best database if you want to save data that doesn’t require a timestamp like JSON data.
  • Requires internet connection: the ESP32 needs to be connected to the internet to connect with InfluxDB, unless you install it locally.
  • Retention period: the free cloud plan only lets you save data until the last 30 days.

5) Use Deta Base to Save Your Data

deta base with ESP32 UI demonstration

Deta Base is a NoSQL database. It is unlimited, free, and easy to use. Additionally, it requires minimal setup. So, it’s perfect for your hobbyist projects and prototyping. It offers a UI through which you can easily see, query, update and delete records in the database.

The biggest advantage of Deta Base over other database solutions is that it requires very little setup. Once you sign up for Deta Base, it’s ready to use.

As with Firebase, you can create your own web applications to interact with the database.

If you want to learn how to use Deta Base with the ESP32, you can follow our guide:

Advantages of using Deta Base with the ESP32:

  • It’s free.
  • It requires minimal setup, once you sign up to Deta Base, you can start using it right away to store data.
  • It’s fast and scalable.
  • You can check your data online from anywhere from your account.

Disadvantages:

  • Small community: it’s still in the early stages, so if you need help, there’s still little information online.
  • Beta version: it’s in beta version, and you might encounter unexpected bugs.
  • Requires internet connection: like the other cloud solutions, the ESP32 needs to have access to the internet.

6) Use ThingSpeak Channels

ESP32 board ThingSpeak channels

ThingSpeak is an IoT platform in which you can create channels to store data. It provides visualization tools and different widgets to display your data like charts, gauges, or numeric displays. The submitted data is also associated with a timestamp, which is useful if you want to display it on charts to see how it behaves over time.

You can have multiple devices publishing data to your Thingspeak account. Usually, each device will require a channel. The free plan is limited to four channels.

In my opinion, the visual interface is easy to use, but it allows very little customization when compared with the tools provided by InfluxDB. However, it is perfect if you just want a simple visualization without having to worry about formatting details (like series colors, charts background colors, etc.).

The data is stored in the cloud, so you can access your data anywhere from your account,

We have two different tutorials that show different methods to publish data to Thingspeak. The following shows how to make an HTTP POST request with data to Thingspeak services (you need to write the request manually on the code):

An easier way to publish data to Thingspeak with the ESP32 is to use a library. You just need to call a function and pass as an argument the data you want to send.

Advantages of using ThinsSpeak with the ESP32:

  • Suitable for multiple IoT devices: you can have multiple ESP32 boards and other IoT devices publishing data to your Thinspeak account.
  • Free to use: it provides a free plan with up to four channels. Usually, each device will require a different channel on ThingSpeak.
  • Minimal setup: you don’t need to install anything on your computer or set up any database settings; once you create an account and a new channel, it’s ready to use.
  • Simple dashboard: the data will be displayed on the widget of your choice, without having to program anything on the user interface.

Disadvantages:

  • Limited free plan: the free plan is limited to four channels, which might not be enough for your project.
  • Little customization: the number of available widgets is limited and allows very little customization.
  • Requires internet connection: like the other cloud solutions, the ESP32 needs to have access to the internet.

7) Save ESP32 Data to Google Sheets

ESP32 publish data to google sheets

Another great alternative to log data with the ESP32 is to use Google Sheets. Then, you can analyze, manage and display your data using the features provided in Google Sheets. You can have access to your data from anywhere using your Google account. This is a good method if you need to store data that needs processing later on.

We have a guide showing how to log sensor readings to Google Sheets using IFTTT services. The advantage of using IFTTT services is that you don’t need to create any scripts or additional configurations in your Google account. However, it has some limitations in the number of requests you can make with the free account and with how much information you can save at once. Here’s the tutorial:

If you don’t want to rely on a third-party service to publish data to google sheets with the ESP32, there’s currently a library to do that. Check the .

Advantages of saving ESP32 data to Google Sheets:

  • Easy data management: if you need to process your data after collecting it, you can use all the functionalities of google sheets to process data.
  • Access from anywhere: you can easily access your data from your google account.
  • Shareable: you can share the google sheet file with other people by providing access to their specific email.

Disadvantages:

  • It doesn’t display the data visually automatically. You need to know how to create charts and graphs (which is not difficult, so I don’t think this is a big limitation).
  • If using a third-party service like IFTTT (free account) you’re limited to the number of requests and fields you can pass at a time.
  • Requires internet connection: like the other cloud solutions, the ESP32 needs to have access to the internet.

8) ESP32 Save Data to MySQL Database on a Cloud Server

ESP32 Save Data to MySQL on a Cloud Server

You can install a MySQL Database on a cloud server and then, make requests with the ESP32 to publish and retrieve data. This method is great for those who like programming, setting up their own servers, and want to have full control over their data storage. If you’re already familiar with MySQL and PHP, you’ll certainly like this method.

The biggest disadvantage of this method is that you need to set up everything on your own from scratch which is easily prone to errors. Additionally, you’ll need to pay for hosting and a domain name.

You can follow the next tutorials to set up a MySQL database on your own server and then, learn how to create a web page to display the data on charts:


9) MySQL Database on a Local Server (Raspberry Pi)

This is an alternative to the previous solution. If you want to set up a MySQL database locally on a Raspberry Pi to save the data coming from the ESP32, you’ll need to follow the next tutorial first:

Then, you can follow the next tutorial to learn how to actually publish data with the ESP32 to your local server and how to display it on a web page:

Wrapping Up

In this tutorial, we compiled different methods that you can use to save and log data permanently using your ESP32. Depending on your expertise level and project requirements, one solution might be more suitable than the others. There are many other methods besides the ones we covered here. We created a compilation of the tutorials we already have about this subject.

We hope you found this compilation guide useful. Let us know what’s your favorite storage method and for which applications you use it.

Learn more about the ESP32 with our resources:

Thanks for reading.