Long range GPS asset tracker using the Cicerone board

Please note this article is a work in progress and will change over the coming days

In this guide we detail how to make a long range (10km+) GPS asset tracker using the Cicerone board and LoRaWAN. This is the written version of the project featured in this video:

Build list

To make this project we need the following items:

  • Cicerone board: https://www.move-x.it/cicerone-board/
  • LiPo battery: https://amzn.to/3EzEgpw
  • 868MHz antenna: https://uk.rs-online.com/web/p/telemetry-antennas/1251251
  • GPS antenna: https://amzn.to/3ClnLus
  • Assorted cables

Assembly

I 3D printed a small box to contain all the components listed above. The battery connects to the Cicerone board via the 2mm JST connector and the two antennas are connected to their respective ufl connectors.

Programming

We used the new Arduino IDE version 2 in this project and it worked like a charm. We need to add the Cicerone board to the Arduino board manager. This is done by clicking the following button in the Arduino IDE preferences:

In the dialogue box that opens, add the following URL and then press OK. The board should now install.

https://github.com/Move-X/Move-Xduino/raw/main/package_move-x_index.json

Final Code – Cicerone Board

#include <LibLoRaWAN.h>
#include <Wire.h> //Needed for I2C to GNSS
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;

bool net_joined = false; // will store join status


void userloop();

// Set your LoRaWAN keys here
uint8_t devEUI[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t appEUI[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t appKEY[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t nwkKEY[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void setup()
{
  Serial.begin(115200);

  // Set up LoRaWAN
  Serial.println("Init LoRaWAN");
  LoRaWAN.attachLoop(userloop, 5000);
  LoRaWAN.begin(false); // Add &Serial as second parameter to enable debug messages on console

  if (LRW_OK != LoRaWAN.setRegion(LRW_REGION_EU868))
    Serial.println("setRegion() error!");

  if (LRW_OK != LoRaWAN.setDevEUI(devEUI))
    Serial.println("setDevEUI() error!");

  if (LRW_OK != LoRaWAN.setJoinEUI(appEUI))
    Serial.println("setJoinEUI() error!");

  if (LRW_OK != LoRaWAN.setAppKey(appKEY))
    Serial.println("setAppKey() error!");

  if (LRW_OK != LoRaWAN.setNwkKey(nwkKEY))
    Serial.println("setNwkKey() error!");

  if (LRW_OK != LoRaWAN.Join(LRW_JOIN_OTAA))
    Serial.println("Join() error!");

  // Configure GPS
  Wire.begin();

  //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

  if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
  {
    Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
    while (1);
  }

  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
  myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
}

void loop()
{
  LoRaWAN.process();
}

void userloop() {
  

  if (!net_joined)
  {
    /* Update join status */
    if (LRW_OK == LoRaWAN.NetJoined()) {
      net_joined = true;
      Serial.println("Net Joined");
    }
  }
  else
  {
    
      // Read GPS Data and convert to string format
    float latitude = myGNSS.getLatitude();
    float longitude = myGNSS.getLongitude();

    char lat[9];
    char lon[9];
    char buffer[strlen(lat) + strlen(lon) + 1];

    dtostrf(latitude, 8, 5, lat);
    dtostrf(longitude, 8, 5, lon);
    sprintf(buffer, "%s,%s", lat, lon);

   // Send sensor data
       if (LRW_OK != LoRaWAN.Send(111, LRW_UNCONFIRMED_MSG, (uint8_t*)buffer, sizeof(buffer))) {
         Serial.println("Send() error!");
       }
    
  }
}

Conclusion

So that is our programming done, now we can move the tracker outside and start gathering GPS location (every twelve hours)!

Leave a comment

Your email address will not be published. Required fields are marked *