The Data Logger module allows you to save data in form of CSV file. You can create and configure file according to your needs and monitor them while they are being logged. This module also works in the background allowing you to save your data while using other modules. Once the data logging process is complete you can also open and share the file. You can also access previously logged files anytime.
For creating a Data Logger file you need to give following instructions from hardware:
- File name – The name with which you want to generate your CSV.
- Column Name – The name of various columns that you have to create in your data logging sheet.
- Data – Values that are to be stored in various created columns
- Close file – Give this command when you want to stop logging and close the file.
- A data logging file is created. By using the button marked ‘X’ you can close the created file from smartphone itself.
- When the process of data logging is going on.
There is an icon beside “connect” icon it is to open previously made files. You can view these files, share them and also delete the unwanted files.
Arduino IDE Functions
To include the GamePad module in the Arduino program, you have to include the following header:
After defining the above mention headers, you have to include the dabble library:
You can download the zip of Arduino Library for
depending on the board you are using.
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
- For evive and Arduino Mega, Uno and Nano
- For ESP32
In place of Bluetooth_Name enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”.
Refreshing the data
To refresh the data that the device has got from the mobile app, you have to use the following line of code:
DataLogger.createFile(FileName) – Open a CSV file of name passed as parameter in this function.
DataLogger.createColumn(CoulmnName) – Create column of the name passed as parameter in this function. The previous function created a file. Now in order to create a column in that file, we have to use this function.
DataLogger.send(ColumnName,Data) – As there can be multiple columns in a file hence in order to instruct in which column you want to log data you have to pass that column’s name and the associated data as the parameter.
DataLogger.close() – To close the ongoing file.
DataLogger.sendSettings(&FunctionName) – This is a callback function. It is used to send commands as soon as the bluetooth connection is established. Its use will be more clear from the example.
PictoBlox (Scratch) Blocks
The stacked block “create () named ()” is for configuring the initial parameters of the data logger file. Before starting the logging process you have to create the file in which you will store data. Hence you have to give the file name and the column names in which you will be logging different data values. This block consists of two elements in its drop down. One is File and one is Column. The text written in the text field of the block is assigned to either of the element selected from the drop-down.
The “log () with data ()” block is used for sending data that is to be logged in the file. The block has two text fields. In the first text field you have to write the column name and in the second text filed you have to log the data to be stored. The column name written is the name of any of the columns that you have given while creating columns in your data logger file using the above block.
In order to stop the data logging process and close the currently open data logger file use this block.