This is an old revision of the document!


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) capabilities for UPB Drive's formula student race car. The system consists of 2xESP32 microcontrollers transferring data using 2xLoRa transceivers. One ESP32 is equipped with additional sensors such as linear potentiometers and a GPS module and will be mounted on the car to track the posistion and measure the suspension force. 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
  • Jumper wires
  • Micro USB data cable
  • PC with an internet connection and with Arduino IDE

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)) 
{
  Serial.println(".");
  delay(500);
}

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

LoRa.beginPacket();
LoRa.print("Analog read: ");
LoRa.print(potValue);
LoRa.endPacket();

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.

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

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.

server.begin();
webSocket.begin();

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 .

webSocket.onEvent(webSocketEvent);
server.handleClient();  // webserver methode that handles all Client
webSocket.loop();
webSocket.broadcastTXT(receivedVoltageArray);
receivedVoltage = (char)LoRa.read();

5. Conclusion

6. Resources

iothings/proiecte/2022/lorabasedrealtimeaquisitionsystem.1673806159.txt.gz · Last modified: 2023/01/15 20:09 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