DataScriba - Tutorial

The goal of this tutorial is to get you started quickly with DataScriba. It shows how to create a small program to run on the Raspberry Pi. The data structure for this device will contain the board temperature, updated each second. A substructure will also be created with a field enable and a field counter. If enable is TRUE, then the counter will be incremented every second.

A video per step is available to help your progress.


Step 1: Setup

1. Make sure that the DataScriba Eclipse plugin is installed. You can refer to the section Download of your account for instructions on how to install it.

2. Download the demo device package, which contains the code to get you started! Also available in the section Download of your account.

3. Once this is done, we will be using the demo project Empty, located in the Demo Device Package. In this video, the supplied project is open in Eclipse - any editor should be fine!


Step 2: Creating the data structure

1. In Eclipse, create a new DataScriba File in a project. You can leave the default name as is.

2. Click on Add Field to Root to add the first field Temperature. Set the data type to FLOAT and the sample quantity to 100. The sample quantity is, as you might have already guessed, the quantity of samples that will be buffered by the device if no communication with the DataScriba server is available. The goal of the device is to make sure that the server receives all the values.

3. Click in the grid to confirm your changes.

4. Create a new field, but only specify the name to Control. Click in the grid.

5. Make sure that the field Control is still selected. Click on Add Field To Selection and create the field enable. Keep the default data type and set the sample quantity to 100. Click in the grid.

6. Select again Control and click again on Add Field to Selection. Create the field counter, with a data type of UINT32 and a sample quantity of 100. Click in the grid.

7. Once this is completed, save the file and generate the source code associated. You will notice that the files DeviceData.c and DeviceData.h have been generated.


Step 3: Creating the program

1. Open the file main.c.

2. Uncomment the line of code related to the account name and replace your_account_name by the account to which the device is associated. The account name is the one that was provided when the account was created - it can be found at the top of the right column after you login in your account.

3. Uncomment the line of code related to the device password and replace your_device_password by the password you wish to set for this device. Note this password as you will need to provide it when registering the device to your account.

4. Before the execution of the main loop, it is a good practice to set the initial value of the fields of the data structure, to prevent the device from sending unwanted values on startup. You will notice that an earlier call to the function getDeviceData() returns a pointer of type strDeviceData. This pointer actually points on the data structure you defined earlier, and can be used to read and write the status of the system.

5. In the main loop of the program, remove the unwanted code. Periodically assign the value returned by the function ReadTemperature to the field Temperature.

6. Still in the main loop, increment the value of the field counter in case the field enable is TRUE.

7. Once this is done, you can compile the program using your development environment. In case you use the makefile provided, the compiled program will be located in the folder bin, at the root of the folders.


Step 4: Running the program

1. Ensure that you have the latest compiled program on your embedded platform (the Raspberry Pi, in the video).

2. If you try to run the program right away, you will notice that the registration of the device to the server fails. This is simply because the device has not yet been added in the account.

3. Click on the menu Devices and select Add device.

4. Enter a name for the device and the password you set in the code. Finally, set the identifier, which was printed out by the device when it started. Click on Save changes.

5. Now the device can connected to the server and current and historical values can be visualized. You can click to view a graphical history of the values over time.

6. You can also set the field enable to 1 and see the field counter increment.

CONGRATULATIONS! You have just developed your first program using DataScriba!

Make sure to give us feedback about your experience and give us comments or suggestions about features you would like to see in this product.