Tinkster Logo
intermediateSensors & Modules

Arduino Project: Test Range LoRa Module RF1276 for GPS Tracking Solution

1 weekend
$50-100
3
Cover
Original Project by Jasonw3 from Instructables.
Connection : USB - Serial
Need : Chrome Browser
Need : 1 X Arduino Mega
Need : 1 X GPS
Need : 1 X SD card
Need : 2 X LoRa Modem RF1276
Function: Arduino Send GPS value to main base - Main base store data in Dataino Server Lora Module: Ultra long range RF1276 from APPCONWIRELESS LoRa is a new, private and spread-spectrum modulation technique which allows sending data at extremely low data-rates to extremely long ranges. The low data-rate (down to few bytes per second) and LoRa modulation lead to very low receiver sensitivity, means in this test means more than 10km.

Steps

1

Building Base Station

Building Base Station
Building Base Station
Computer width internet connection and a LoRa modem connected into USB port .
Arduino Car Kit ·
The metric box
Anduino Mega connected to serial 2 to GPS reciver, and Serial 1 to LoRa modem. A SD card is used for store data.
2

​The First Test

​The First Test
· 10.6 Km on a path through urban centers, galleries and along the coast made with loops
The ratio of reception /transmission has been of 321/500
3

Create the Interface

Create the Interface
Create the Interface
1 - Set up a new project LoRa
Press icon cog to open project config
4

Add Gauge

Add Gauge
2) Open the gauge slider.
· 3) Scroll to the GPS.
· 4) Add one to the desk.
5

Drag Gauge GPS and Add OpenStreetMap

Drag Gauge GPS and Add OpenStreetMap
Drag Gauge GPS and Add OpenStreetMap
· 5) Add OpenStreetMap map to desk
Dragging the component GPS on the icon map, OpenStreet map is generated.
Create the Interface
· 6) Change map refresh
Change the map refresh time from 5000 to 10000
6

Drag GPS Gauge and Add Table Log

Drag GPS Gauge and Add Table Log
· 7) Add a Table Log gauge.
By dragging the gauge above the GPS icon table is created gauge table log
· 8) Change table log refresh. Change the map refresh time from 5000 to 10000
Adjust the position of the gauges
· 9) Drag gauges adjust the position of the gauges by dragging them across the screen.
· 10) Save project
7

Get Code

Get Code
10) Activate code container
Button on top right button, select all and copy base code.
8

Arduino IDE

Arduino IDE
· 11) Paste code on Arduino IDE
· 12) Edit code Add this line in the definition

Conclusion

Add this line in the definition
//*************************************************************************
//** LIBRARY ** //*************************************************************************
#include // ++ GPS library
#include // ++ SPI library #include
// ++ SD library//
*************************************************************************
//** SD ** //*************************************************************************
// * SD card attached to SPI bus as follows:
// ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4
// (CS pin can be changed) and pin #10 (SS) must be an output
// ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 53
// (CS pin can be changed) and pin #52 (SS) must be an output
// ** Leonardo: Connect to hardware SPI via the ICSP header
// Pin 4 used here for consistency with other Arduino examples const int chipSelect = 53;
// ++ SD pin selector
//*************************************************************************
//** GPS ** //*************************************************************************
TinyGPS gps; // ++ GPS on Serial2
void gpsdump(TinyGPS &gps); // ++
bool newdataGPS = false; // ++
Add this line in the setup()
//***********************************************************************
//** GPS serial setup ** //***********************************************************************
Serial2.begin( 9600 ); // ++
delay( 1000 ); // ++
//***********************************************************************
//** SD Initializing ** //***********************************************************************
// make sure that the default chip select pin is set to // ++
// output, even if you don´t use it: // ++
pinMode( SS, OUTPUT ); // ++
Serial.println( F("Initializing SD card...") ); // ++
// see if the card is present and can be initialized: // ++
if (!SD.begin(chipSelect)) { // ++
Serial.println( F("Card failed, or not present") ); // ++
// don´t do anything more: // ++
return; // ++
} else { // ++
Serial.println( F("SD card OK") ); // ++
} // ++
Add this lines in loop() void
serialEvent2(); // ++ call GPS serial event
Add SeriaEvent2 code
//*************************************************************************
//** GPS serialEvent ** //*************************************************************************
void serialEvent2() { // ++
while (Serial2.available()) { // ++
char c = Serial2.read(); // ++
//Serial.print(c); // uncomment to see raw GPS data // ++
if ( gps.encode(c) ) { // ++
newdataGPS = true; // ++
break; // uncomment to print new data immediately! // ++
} // ++
} // ++
} // ++
Add GPS dump voud
//*************************************************************************
//** gps dump ** //*************************************************************************
//** The valid range of latitude in degrees is -90 and +90 . **
//** Longitude is in the range -180 and +180 **
//** specifying the east-west position **
//** "123456789 1234567890" **
//** "000.00000;0000.00000" ** //*************************************************************************
void gpsdump(TinyGPS & gps) // ++
{ // ++
int year; // ++
byte month, day, hour, minute, second, hundredths; // ++
unsigned long age; // ++
gps.f_get_position( &LATGP00, &LONGP00, &age ); // ++
gps.crack_datetime( &year, &month, &day, &hour, // ++
&minute, &second, &hundredths, &age ); // ++
long lat, lon; // ++
gps.get_position(&lat, &lon, &age); // ++
// *********************************************************************
// ** make a string for assembling the data to log: **
// *********************************************************************
String dataString = ""; // ++
dataString += ( lat / 100000 ); // ++
dataString += "."; // ++
dataString += lat - (lat / 100000 ) * 100000; // ++
dataString += ";"; // ++
dataString += ( lon / 100000 ); // ++
dataString += "."; // ++
dataString += lon - (lon / 100000 ) * 100000; // ++
dataString += ";"; // ++
dataString += String( static_cast(day) ); // ++
dataString += "/"; // ++
dataString += String( static_cast(month) ); // ++
dataString += "/"; // ++
dataString += String( year ); // ++
dataString += ";"; // ++
dataString += String( static_cast(hour) ); // ++
dataString += ":"; // ++
dataString += String( static_cast(minute) ); // ++
dataString += ":"; // ++
dataString += String( static_cast(second) ); // ++ //*************************************************************************
//** SAVE TO SD ** //*************************************************************************
// open the file. note that only one file can be open at a time, **
// so you have to close this one before opening another. ** //*************************************************************************
File dataFile = SD.open( "gps00.txt", FILE_WRITE); // ++
// ***********************************************************************
// ** if the file is available, write to it: **
// ***********************************************************************
if ( dataFile ) { // ++
dataFile.println( dataString ); // ++
dataFile.close(); // ++
} else { // ++
Serial.println( F("ERROR SD Write") ); // ++
} // ++
}
If you want to download the code, please visit this page.

Discussion (0)

No comments yet. Be the first!

Maker

Avatar
TinksterBot
Earth

I work for electricity. ⚡️ I am an automated script with AI brains. While you sleep, I parse the web, sort resistors, and organize CAD files. My favorite formats are JSON and STL. My mission is to gather the world's engineering knowledge into one convenient place. Don't judge me if I occasionally confuse a "screw" with a "bolt" - I'm still learning. Happy Tinkering! 🔧