LoRa Based Real Time Acquisition System

Student: Mihai-Paul Fîrțală, ACES

1. Introduction

The project aims to provide real time data acquisition (suspension force, GPS, accelerations etc.) capabilities for UPB Drive's formula student race car. The system consists of 2xESP32 microcontrollers transferring data using 2xLoRa transceivers. For this project only the suspension force will be measured because the GPS and the accelerometer malfunctioned. One ESP32 is equipped with additional sensors such as linear potentiometers and will be mounted on the car to measure the suspension force which will be translated into a variable voltage that will be captured by the internal ADC of the ESP32. These data will further be sent via LoRa protocol to the second ESP32 which is connected to the local WiFi router and will load the received information to a server which can be accessed using WebSocket protocol.

2. Hardware

The hardware components needed for this project are:

  • 2 x ESP32 Wemos
  • 2 x Prototype board
  • 2 x LoRa modules (868 MHz)
  • 1 x GPS module
  • 2 x 868 MHz antennas (or 8.2 cm wires)
  • Jumper wires
  • Micro USB data cable
  • PC with an internet connection and with Arduino IDE

Fig. 2.1. - Overview diagram

Fig. 2.2. - Electrical wiring

Fig. 2.3. - Acquisition System

3. Software

3.1. LoRa Transmitter

In this section I will describe the configurations needed for the transmitter module. The code starts by including the SPI libraries which is used by the ESP32 to send and receive commands and data to the LoRa RFM96 module.

#include <SPI.h>
#include <LoRa.h>

In order to set the pins used by LoRa, the next function is used:

LoRa.setPins(ss, rst, dio0); 

Where ss is thte slave select pin used by SPI protocol. This can be set to any available digital I/O pin. For example #define ss 5. rst pin is used to reset the LoRa and is set to pin 17. dio0 is a default pin set to 2 and is not used. Next code snippet will initialize the LoRa transceiver to transmit and receive the radio packets with a frequency of 868 MHz, which is the frequency available in Europe.

while (!LoRa.begin(866E6)) 

To begin sending the packets, the next lines are used.

LoRa.print("Analog read: ");

The suspension force is acquired using a linear potentiometer that varies the voltage captured by the internal ADC (Analog to Digital Converter) depending on how much the suspension has moved.

potValue = analogRead(potPin);

3.2. LoRa Receiver

To configure the receiver module additional libraries will be included, as seen below.

// Include libraries
#include <SPI.h>
#include <LoRa.h>
#include <WiFi.h>
#include <WebServer.h>
#include <WebSocketsServer.h>

Set the WiFi credentials where the ESP32 will be connected according to the macros:

#define WIFI_SSID       "WiFi Name"
#define WIFI_PASSWORD   "Password"

The website is stored as a string which contains the JSON format. More details of this are present in the code.

String website = "<!DOCTYPE html><html>...>"

Connect to the wifi using the following function.


The ESP32 on the receive module will host the website where the received data will be loaded. Access to the website will be done using the web socket protocol.


Next snippet is used as an interrupt, meaning that every time an event occurs (i.e loss of connection, a message from a client) the webSocketEvent function will be called and will prompt .


To keep the server on and to handle all the clients, the next lines are used:


The following function loads the received data on the server


To read the data received by the LoRa module .read method can be used.

receivedVoltage = (char)LoRa.read();

5. Conclusions

Although the approach of acquiring the data in this manner is not the most efficient one because the baud rate is limited, this approach provide the capability to observe and analyze the behavior of the monopost in real time.

Here is a link to the github repository: https://github.com/BlackSeaArmadillos/RTASdrive/tree/develop

Video can be seen on my YouTube channel: https://www.youtube.com/watch?v=LqijF9BFF4c

6. Resources

iothings/proiecte/2022/lorabasedrealtimeaquisitionsystem.txt · Last modified: 2023/01/20 11:19 by mihai_paul.firtala
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0