Skip to main content

Real-time 3D trajectories display from accelerometer on IoT platform

Student: Lorenzo Brunato

Supervisor: prof. Pier Luca Montessoro

Platform: Orange Pi PC 2

Overview

This Bachelor thesis is focused to real-time data manipulation and graphic representation. The data come from an accelerometer. The purpose of the thesis is the development on an IoT platform (an Orange Pi PC 2 in this case) of a software for:

  • receive data from the accelerometer;
  • process data to calculate the position;
  • display the position values in a real-time 3D graphic.

Data transmission from accelerometer to software is based on client-server architecture and communication protocols 802.11 and TCP/IP. For data manipulation and the development of graphic interface is used Qt library.

The client transmits to the server the data about acceleration projections in a string with an apposite format. Data are sampled every 100 milliseconds and this value is configurable via software in the client.

The server is divided in two classes: MyServer and Mygrafic3d. Myserver class has the purpose of create connection with client, receive the string with the data from client and do a first processing of data for understanding the type of data (number of samples or acceleration values). Mygrafic3d extracts data from string, convert them in float values, calculate the positions from accelerations and plots the values in a real-time interactive 3D graphic.

The two classes can communicate with signal-slot mechanism typical of Qt library.

 

What you need

  • Orange Pi PC 2 (you can use also other model of Orange Pi or other boards)
  • accelerometer LIS3DH
  • an Ethernet cable
  • Wi-Fi connection
  • Lorenzo Brunato's code (Github)

 

Setup

The first step is the connection of the accelerometer to Orange Pi board. In particular, for use I2C protocol you have to follow theese indications:

  • pin 1: SDO
  • pin 2: VIN
  • pin 3: SDA
  • pin 5: SCL
  • pin 6: GND

Then, the next step is connect Orange Pi PC 2 to your pc with an Ethernet cable and configure a network bridge between your Wi-Fi and Ethernet: go to PC Settings => Network & Internet => Network connections, select Wi-Fi and Ethernet, right click and select Bridging connecions to obtain a Network bridge. Complete the network bridge configuration: right click on Network bridge, double click on Internet Protocol version 4 (TCP/IPv4) and edit the parameters. You have to put your pc IP address added by 1. Other parameters like netmask, default gateway, DNS servers can remain the same. Now you can connect to Orange Pi board with Remote Desktop Connection software at configured IP address.

Run the program

The first step is obtain root permits with Linux command sudo su. Then you can verify the accelorometer connection with the command:

# gpio i2cdetect

If all is good will appear a number 19 in the answer.

For the server you have to launch Qt Creator, open the project Tcp_Server_Graphics_3D and click the button Run. At this point the server is started and two windows will be open, one for the server and one for the 3D graphic.

The next step is the building of the client software with the commands:

# cd <path to client folder> 

# gcc -o acc_lis3dh.exe acc_lis3dh.c Lis3dh.c -lwiringPi -lpthread

Then you can launch the client program with the command:

# ./acc_lis3dh.exe <protocol> <LIS3DH full scale> <server IP address> <port>

where protocol is I2C or SPI, full scale can be 2, 4, 8 or 16, server IP address is your pc IP address and for the port you can choose the number. Example:

# ./acc_lis3dh.exe I2C 4 192.168.1.8 5000

At this point in the client you can digit the number of samples to send to the server and start to move the accelerometer. You can see the measured accelerations on the client and again the accelerations plus the computed positions on the server. On the 3D graphic are plotted the trajectories of the accelerometer.

Future developments

The main future development of this project regards the possibility to add a gyroscope to the system. In fact only an accelerometer is not enough to calculate the exact position becasue it's a inertial device and it doesn't discern a rotation and a linear acceleration. The used accelerometer LIS3DH measures only external accelerations and not angular accelerations. With a gyrosope could be possible to measure both linear and angular accelerations. In particular we suggest to replace the LIS3DH accelerometer with a device that works as accelerometer and gyroscope like LSM6DS3 inertial module.