Basic UART-SQLite query demo

<< Click to Display Table of Contents >>

Navigation:  STM32F4 Target > Demos > Hardware Modules Demos > aMG SQLite Data Server >

Basic UART-SQLite query demo

Previous pageReturn to chapter overviewNext page

The demo showing to communicate with aMG SQLite Data Server board via UART. It helpful for understanding the command/ protocol to start develop your own software to communicate with aMG SQLite Data Server board.

Hardware requirement:

1. aMG USB Converter N board (Or other USB-serial device which 3.3V interface).

2. aMG SQLite Data Server Board.

Hardware setup

Follow below hardware setup, connection between aMG USB Coverter N and aMG SQLite Data Server board.

 Tx pin of aMG USB Converter N ---> Rx pin of aMG SQLite Data Server

 Rx pin of aMG USB Converter N <--- Tx pin of aMG SQLite Data Server

 

amgsqlite_hwsetup1

 

Software setup

The use putty.exe for communication software, download from: http://www.putty.org/

1. UART port configuration

amgsqlite_softwaresetup1

amgsqlite_softwaresetup3

2. Terminal configuration

amgsqlite_softwaresetup2

Testing

1. press Enter, to display main prompt ">".

2. Ask for board firmware version, by keying "version" + press Enter key.

amgsqlite_softwaretesting1

3. Enter SQLite3 prompt mode, by keying "sqlite dbname.db" + press Enter key.

amgsqlite_softwaretesting2

Note: If database name not specified when switch to SQLite prompt, it will use the default "database.db".

4. Now try to create data table, to store temperature measure at room no.1, no.2 and no.3 for every minutes.

Given:

T1 - Temperature measure at room no.1

T2 -  Temperature measure at room no.2

T3 -  Temperature measure at room no.3

amgsqlite_softwaretesting3

Note: aMG SQLite Data Server board did not implement command history, it not support Arrow key.

5. Display data in table name "temperature", by using "SELECT" statement.

amgsqlite_softwaretesting4

6. Disconnect from SQLite prompt mode, exit to main prompt. By keying ".quit" + press Enter key.

amgsqlite_softwaretesting5

Repeat step3 if you want to enter SQLite prompt again.

Checking SD card for generated database file

amgsqlite_softwaretesting6

Open database file on Host PC (Process database)

1. Download sqlite3.exe, from http://www.sqlite.org/download.html at section "Precompiled Binaries for Windows".

2. Extract executable file to "C:\sqlite", also copy database file "dbname.db" from SD Card place into same directory.

amgsqlite_softwaretesting7

3. Start windows command line prompt, cmd.exe

amgsqlite_softwaretesting8

4. At windows command prompt, change current directory to "C:\sqlite". Type command "cd \" to change to root directory "C:\", then type "cd sqlite".

5. Run sqlite3.exe with specify database name "dbname.db"

6. Display data storing in database by "SELECT" statement.

amgsqlite_softwaretesting9

Export data to CSV format

amgsqlite_softwaretesting10

amgsqlite_softwaretesting11

amgsqlite_softwaretesting12