Circular Buffer demo


Create a database in the SD card using an Database browser. The following query can be used.

CREATE TABLE "smc_4_20mA_data" (
    "timestamp"    INTEGER,
    "CH1_raw"    TEXT,
    "CH1_conv"    TEXT,
    "CH2_raw"    TEXT,
    "CH2_conv"    TEXT,
    "CH3_raw"    TEXT,
    "CH3_conv"    TEXT,
    "CH4_raw"    TEXT,
    "CH4_conv"    TEXT

Demo file : esp32_circular_buffer_demo.slx


This demo shows a simple use case scenario for the circular buffer block. In this example data of 8 sensors (not actual sensors. Matlab Simulink blocks were used to mimic sensors) along with the UNIX timestamp needs to be inserted to the database. Inserting large amounts of data to a database could be a blocking process. Thus to ensure sensor readings are recorded every 1 second a circular buffer is used to hold the sensor data as an intermediate before writing to the database using the SQLite block.

Change the following configuration parameters in the model file.

In the WIFI Block
  • SSID: Any WiFi SSID with internet access
  • Password: Password of the selected WiFi SSID
In the SQLite NonRetrieveData
  • Database Path: Path to the database created in perquisites.

Hardware Setup

  1. ESP32 module with SD card reader
  2. WiFi connection with internet access

What should be happening?

When running the user could monitor INSERT commands to the database using a serial monitor. After a while the user could connect the SD card to a PC and check the sensor readings using a Database browser.

Previous : HTTP Server demo
Next : LEDC demo

Also available in: PDF HTML TXT