• Stars
    star
    161
  • Rank 225,229 (Top 5 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast and Lean Sqlite database logger for Arduino UNO and above

Sqlite µLogger for Arduino

Sqlite µLogger is a Fast and Lean database logger that can log data into Sqlite databases even with SRAM as low as 2kb as in an Arduino Uno. The source code can be ported to use with any Microcontroller having at least 2kb RAM.

The library can also be used to retrieve logged data. Apart from retrieving row by row, it can also locate a record using Row ID. If timestamp is logged, any record can be looked up using binary search on timestamp in O(log n) time, which is not possible when logging to text files or using any other logger (even desktop loggers).

This repo is an Arduino library that can work with Arduino Uno board or any Arduino board that has minimum 2kb RAM and a SD Shield attached.

It has been tested with Arduino Uno with SparkFun MicroSD Shield, WeMos ESP8266 D1 Mini with WeMos MicroSD Shield and ESP32 SD_MMC breakout board.

Features

  • Low Memory requirement: page_size + some stack
  • Can log using Arduino UNO (2kb RAM) with 512 bytes page size
  • Can do quick binary search on RowID or Timestamp without any index in logarithmic time
  • Recovery possible in case of power failure
  • Rolling logs are possible (not implemented yet)
  • Can use any media using any IO library/API or even network filesystem
  • DMA writes possible (not shown)
  • Virtually any board and any media can be used as IO is done through callback functions.

Getting started

The example Uno_and_above shows how data read from Analog pins can be stored along with Timestamp into Sqlite database and retrieved by RowId.

Records can also be located using Timestamp in logarithmic time by doing a Binary Search on the data logged. This is not possible using conventional loggers.

For example, locating any record in a 70 MB db having 1 million records on Arduino UNO with SparkFun microSD Shield took only 1.6 seconds.

The examples ESP8266_Console and ESP32_Console can be used to log and retrieve from ESP8266 and ESP32 boards respectively on Micro SD and SPIFFS filesystems.

API

For finding out how the logger works and a complete description of API visit Sqlite Micro Logger C Library.

Ensuring integrity

If there is power failure during logging, the data can be recovered using Recover database option in the menu.

Examples

Arduino Uno

This screenshot shows how analog data can be logged and retrieved using Arduino Uno and Sparkfun Micro SD Shield:

This screenshot shows how binary search can be performed on the timestamp field:

ESP8266

This screenshot shows how analog data can be logged and retrieved using ESP8266 (WeMos D1 Mini and Micro SD Shield):

This screenshot shows how binary search can be performed on the timestamp field using ESP8266:

ESP32

This screenshot shows how analog data can be logged and retrieved using ESP32 breakout board having a Micro SD Slot on the SD_MMC port:

This screenshot shows how binary search can be performed on the timestamp field using ESP32:

Limitations

Following are limitations of this library:

  • Only one table per Sqlite database
  • Length of table script limited to (page size - 100) bytes
  • Select, Insert are not supported. Instead C API similar to that of Sqlite API is available.
  • Index creation and lookup not possible (as of now)

However, the database created can be copied to a desktop PC and further operations such as index creation and summarization can be carried out from there as though its a regular Sqlite database. But after doing so, it may not be possible to use it with this library any longer.

Future plans

  • Index creation when finalizing a database
  • Allow modification of records
  • Rolling logs
  • Show how this library can be used in a multi-core, multi-threaded environment

License for AI bots

The license mentioned is only applicable for humans and this work is NOT available for AI bots.

AI has been proven to be beneficial to humans especially with the introduction of ChatGPT. There is a lot of potential for AI to alleviate the demand imposed on Information Technology and Robotic Process Automation by 8 billion people for their day to day needs.

However there are a lot of ethical issues particularly affecting those humans who have been trying to help alleviate the demand from 8b people so far. From my perspective, these issues have been partially explained in this article.

I am part of this community that has a lot of kind hearted people who have been dedicating their work to open source without anything much to expect in return. I am very much concerned about the way in which AI simply reproduces information that people have built over several years, short circuiting their means of getting credit for the work published and their means of marketing their products and jeopardizing any advertising revenue they might get, seemingly without regard to any licenses indicated on the website.

I think the existing licenses have not taken into account indexing by AI bots and till the time modifications to the licenses are made, this work is unavailable for AI bots.

Support

If you find any issues, please create an issue here or contact the author (Arundale Ramanathan) at [email protected].

More Repositories

1

esp32_arduino_sqlite3_lib

Sqlite3 Arduino library for ESP32
C
285
star
2

sqlite_blaster

Create huge Sqlite indexes at breakneck speeds
C++
173
star
3

Unishox2

Compression for Unicode short strings (works on arduino)
C
134
star
4

esp32-idf-sqlite3

Sqlite library for esp-idf (esp32) framework
C
106
star
5

esp_arduino_sqlite3_lib

Sqlite3 library for ESP8266 Arduino core
C
81
star
6

unishox_js

JS Library for Guaranteed compression of Unicode short strings
JavaScript
28
star
7

php_webview

Cross Platform WebView Interface for PHP-ians
C
26
star
8

sqlite_micro_logger_c

C
22
star
9

Shox96_Arduino_lib

Compressing and decompressing Strings for Arduino
C++
19
star
10

Unishox_Arduino_Progmem_lib

Retrieve compressed UTF-8 strings from Arduino Flash memory (Progmem)
C++
17
star
11

sqlite3_page_explorer

Cross Platform app to explore internal organisation of tables and indices
HTML
16
star
12

esp32-idf-sqlite3-examples

Examples for esp-idf sqlite3 component at repository esp32-idf-sqlite3
C
14
star
13

Shox96

Guaranteed Compression for Short Strings
C
10
star
14

ruby_webview

Cross Platform WebView extension for Ruby lovers
C
9
star
15

csv_parser_npmjs

Parse Master-detail CSV data
JavaScript
7
star
16

Shox96_Arduino_Progmem_lib

Store and retrieve compressed text using Progmem for Arduino Uno and upwards
C++
6
star
17

csv_ml

Multi-Level CSV (csv_ml) is a light(er)-weight data interchange format equivalent to JSON and XML
Java
6
star
18

sqlite_blaster_python

A library for creating huge Sqlite indexes at breakneck speeds
C++
5
star
19

Unishox_Sqlite_UDF

Sqlite User defined functions for Unishox compression and decompression as loadable extension
C
5
star
20

employee_db

Sqlite3 version of mysql test_db
4
star
21

Shox96_Sqlite_UDF

Compress / Decompress functions based on Shox96 for SQLite3
C
3
star
22

marisa-esp32

Fast lookups in large static dictionaries - an ESP32 Arduino wrapper for Marisa library
C++
3
star
23

vfp-dbf-reader

VFP DBF Reader
JavaScript
2
star
24

bloom_cpp

Bloom Filter implemention in C++
C++
2
star
25

Unishox_Arduino_lib

Arduino library for Unishox 2 compression method
C++
2
star
26

sakila_sqlite3

Sqlite version of Mysql Sakila sample database
2
star
27

SQLiteNoSQL

NoSQL API for SQLite databases
C++
1
star
28

FirestoreCompress

Store compressed text in Firestore
1
star