In this project, we’ll design a GPS-based location-tracking system using LoRa technology, offering versatile asset-tracking capabilities.
LoRa-based asset tracking
This system employs a GPS module, establishing a virtual circle roughly 20 meters from the initial location. The location data is transmitted to the Arduino Nano through UART communication. For location updates, the system follows a dynamic approach. If the asset remains within the 20-meter circle, the interval for location sending is set to one minute. However, if the asset moves outside the circle, the interval is reduced to 10 seconds for more frequent updates.
The Arduino Nano acts as the data Collector and forwards all location data to the LoRa E5 mini board. This compact LoRa board is the communication gateway, relaying the location data to the chosen gateway. The gateway is connected to the cloud, ensuring seamless integration of the location data into a cloud-based platform. This enables real-time asset tracking and remote monitoring, making it ideal for various applications, including fleet management, logistics, and asset security.
LoRa technology provides long-range communication and low power consumption, enabling extended device operation and reliable data transmission. This combination of GPS-based location tracking with LoRa technology offers an efficient and cost-effective asset-tracking solution in indoor and outdoor environments.
Project content
- Firmware for Arduino
- Circuit diagram and connections
- How to send data through the LoRa gateway via Chirpstack
- Program flow or algorithm
- Explanation
Requirements
- Ensure the LoRa gateway is already installed
- The LoRa E5 mini-board by Seed Studio
- Arduino NANO
- A GPS module (GY-GPS6MV2)
Uploading code to LoRa E5
Before designing the GPS-based location tracking system, ensure the LoRa to UART code (LoRaE5_mini_UART_to_Lora) is uploaded to your mini board. To do so, follow the instructions in this article. This code facilitates communication between LoRa E5 and the gateway.
After the LoRa to UART code is successfully uploaded to the mini board, upload the GPS-based location tracking code to Arduino. This code enables the Arduino to interface with the GPS module and process the location data.
The GPS module creates a virtual circle about 20 meters from the initial location. Depending on the asset’s position relative to this circle, Arduino sets a “location-sending” interval. The interval is set to one minute if the asset is within the circle. If the asset moves outside the circle, the interval is 10 seconds for more frequent updates.
Arduino collects the location data and forwards it to LoRa through UART communication. As the communication gateway, the LoRa transmits the location data to the designated gateway using LoRa technology.
Uploading code to Arduino
Open the “Parking Detect” Arduino NANO code in Arduino IDE.
Select the Board and Port, upload the code, and ensure there is nothing connected to Arduino’s the RX, TX pins.
Circuit diagram
Adding a device to the gateway
Learn how to add a LoRa device in the gateway and find the key in this article.
Decoding the data
To view the data, go to the “Events” tab in ChirpStack as per below.
Copy the data and open any hex-to-text converter website to convert the hexadecimal value to text. The text is the location coordinates.
How the code works
Upon device initialization, the GPS-based location tracking system saves the current GPS coordinates as the initial location. The system defines a virtual circle with a radius of 20 meters around this initial location using software code.
As the device operates, it continuously monitors the GPS coordinates. If the device stays within this 20-meter radius circle from the initial location, the system will consider it inside the circle. In this case, the location data will be sent to the gateway at one-minute intervals to conserve power.
Note: The GPS module requires a clear view of the sky for optimal performance. Placing the GPS module in an open area or outside the device enclosure allows it to receive signals from multiple satellites, resulting in better accuracy and faster satellite acquisition. Cloudy or obstructed weather conditions can affect GPS performance. Thick cloud cover, tall buildings, or dense foliage can block GPS signals, leading to weaker satellite reception and potentially inaccurate or delayed location data.
In the circle
When the device is in the circle, it sends the location every minute. The LED on Arduino remains off as shown in the below image.
Out of the circle
When the device is out of circle, Arduino’s LED will turn on and send data to LoRa in intervals of 10 seconds.
Algorithm
Code explanation
For Arduino NANO: When GPS data is available on the software serial, the getGps() function will be called.
Inside the getGps(): First it stores the current GPS location.
Here is the calculated distance between the saved and the current locations.
After calculating the distance, the code sets the LED on or off and changes the interval for sending data on LoRa.
For the LoRa E5 mini board: the code for Lora E5 mini board is explained here.
Making asset tracking more reliable
Implementing GPS-based location tracking is straightforward, but optimizing power consumption is crucial for battery-operated devices.
To enhance battery life, consider the following modifications:
LoRa’s Class selection: Switching from LoRa’s Class C to Class A reduces power consumption. Class A devices have periodic receive windows, allowing them to sleep most of the time and wake up only at specific intervals to check for incoming messages, saving significant power.
Arduino sleep mode: Using Arduino’s sleep mode, the device temporarily suspends operations during idle periods, minimizing power consumption. It can wake up periodically to perform tasks and then return to sleep, conserving energy.
By combining these power-saving measures, the GPS-based location tracking system can operate efficiently on battery power — extending device life and enabling long-term tracking without frequent battery replacements. Such optimizations are particularly valuable for IoT applications and devices deployed in remote or challenging environments where battery life is critical for seamless operation.
You may also like:
Filed Under: Tutorials
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.