Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and LoRa GPS Tracker with OLED Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO and LoRa GPS Tracker with OLED Display

Circuit Documentation

Summary

This circuit involves two Arduino UNO microcontrollers, two LoRa Ra-02 SX1278 modules, a GPS NEO 6M module, an OLED display, and two power supplies. The primary function of this circuit is to read GPS data and transmit it via LoRa, while the second Arduino receives the data and displays it on the OLED screen.

Component List

Arduino UNO

LoRa Ra-02 SX1278

GPS NEO 6M

Power Supply

OLED Display 2.42

Wiring Details

Arduino UNO (1)

LoRa Ra-02 SX1278 (1)

GPS NEO 6M

Power Supply (1)

Arduino UNO (2)

LoRa Ra-02 SX1278 (2)

OLED Display 2.42

Power Supply (2)

Documented Code

Arduino UNO (1) Code

#include <SPI.h>
#include <LoRa.h>
#include <SoftwareSerial.h>

// GPS Module Pins
#define RXPin 4
#define TXPin 3

SoftwareSerial GPS(RXPin, TXPin);

void setup() {
  Serial.begin(9600);
  GPS.begin(9600);

  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  // Read data from the GPS module
  if (GPS.available()) {
    String gpsData = GPS.readStringUntil('\n');
    Serial.println(gpsData);
    
    // Send GPS data via LoRa
    LoRa.beginPacket();
    LoRa.print("SOS, Location: ");
    LoRa.print(gpsData);
    LoRa.endPacket();
    
    delay(10000); // Wait 10 seconds before sending the next message
  }
}

Arduino UNO (2) Code

#include <SPI.h>
#include <LoRa.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// OLED Display Pins
#define OLED_CS     10
#define OLED_DC     9
#define OLED_RESET  8

Adafruit_SSD1306 display(128, 64, &SPI, OLED_CS, OLED_DC, OLED_RESET);

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

  // Initialize OLED display
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  // Check for incoming LoRa packets
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    String incoming = "";
    while (LoRa.available()) {
      incoming += (char)LoRa.read();
    }
    Serial.println(incoming);

    // Display received message on OLED
    display.clearDisplay();
    display.setCursor(0, 0);
    display.println("Received message:");
    display.println(incoming);
    display.display();
  }
}