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

25,884

83

11

Posted

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

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.

Step 1: 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.

Step 2: ​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
TX point

RX point

Step 3: Create the Interface

1 - Set up a new project LoRa

Press icon cog to open project config

Step 4: Add Gauge

2) Open the gauge slider.

· 3) Scroll to the GPS.

· 4) Add one to the desk.

Step 5: 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

Step 6: 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

Step 7: Get Code

10) Activate code container

Button on top right button, select all and copy base code.

Step 8: Arduino IDE

· 11) Paste code on Arduino IDE

· 12) Edit code Add this line in the definition

Step 9: Coding Details

Add this line in the definition

//*************************************************************************

//** LIBRARY ** //*************************************************************************

#include <TinyGPS.h> // ++ GPS library

#include<SPI.h> // ++ 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.
http://iot.dataino.it/beta/view/site/lora-arduino-gps.html

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    9 Comments

    communication between two LoRa SX 1278 module using Arduino pro mini.

    Internet Of Things.

    IoT Using Rf LoRa1278.

    see my project video

    https://youtu.be/FpgbShufCB0

    Congrats! Great project! Could you please point me to the right direction about the tool you used for creating the interface?

    Thank you!

    "Press icon cog"
    great..... but what icon cog? what software?

    I see. Do you test the module RF1276? You can add RF1276 in your article.

    Semtech's LoRa™ SX12xx modules only really differ in their frequency coverage.

    SX1278 - 137 MHz to 525 MHz           SX1276 - 137 MHz to 1020 MHz

    As I was most interested in 433MHz ISM applications I stayed with  Asian sourced SX1278 offerings.   MicroChip's versatile  LoRa™ RN2483 module has also caught my eye & I may well extend the Instructable to cover it.          Stan.

    RN2483-teardown.jpg