Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano Based LoRa Receiver with I2C LCD Display

Image of Arduino Nano Based LoRa Receiver with I2C LCD Display

Circuit Documentation

Summary

This circuit integrates an Arduino Nano microcontroller with a LoRa Ra-02 SX1278 module for long-range communication and an I2C LCD 16x2 Screen for display purposes. The Arduino Nano serves as the central processing unit, managing the communication between the LoRa module and the LCD display. The LoRa module enables the Arduino to send and receive data over long distances using radio waves, while the LCD screen displays information received from the LoRa module.

Component List

Arduino Nano

  • Description: A compact microcontroller board based on the ATmega328P.
  • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK

LoRa Ra-02 SX1278

  • Description: A wireless communication module that uses the SX1278 chip for LoRa communication.
  • Pins: GND, NSS, MOSI, MISO, SCK, D105, DI04, 3.3V, RST, DI00, DI01, D102, DI03

I2C LCD 16x2 Screen

  • Description: A 16x2 character LCD display that uses the I2C communication protocol.
  • Pins: SCL, SDA, VCC (5V), GND, VDD, VO, RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7, BLA, BLK

Wiring Details

Arduino Nano

  • GND connected to:
    • I2C LCD 16x2 Screen GND
    • LoRa Ra-02 SX1278 GND
  • 5V connected to I2C LCD 16x2 Screen VCC (5V)
  • D2 connected to LoRa Ra-02 SX1278 DI00
  • A5 connected to I2C LCD 16x2 Screen SCL
  • A4 connected to I2C LCD 16x2 Screen SDA
  • D9 connected to LoRa Ra-02 SX1278 RST
  • D10 connected to LoRa Ra-02 SX1278 NSS
  • D11/MOSI connected to LoRa Ra-02 SX1278 MOSI
  • 3V3 connected to LoRa Ra-02 SX1278 3.3V
  • D12/MISO connected to LoRa Ra-02 SX1278 MISO
  • D13/SCK connected to LoRa Ra-02 SX1278 SCK

LoRa Ra-02 SX1278

  • GND connected to Arduino Nano GND
  • NSS connected to Arduino Nano D10
  • MOSI connected to Arduino Nano D11/MOSI
  • MISO connected to Arduino Nano D12/MISO
  • SCK connected to Arduino Nano D13/SCK
  • 3.3V connected to Arduino Nano 3V3
  • RST connected to Arduino Nano D9
  • DI00 connected to Arduino Nano D2

I2C LCD 16x2 Screen

  • GND connected to Arduino Nano GND
  • VCC (5V) connected to Arduino Nano 5V
  • SCL connected to Arduino Nano A5
  • SDA connected to Arduino Nano A4

Documented Code

#include <NewPing.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <LoRa.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
String inString = "";
int counter = 0;

// Pinout on Arduino Nano
// LoRa module > Arduino: GND:GND, GND:GND, 3.3V:3.3V, RST:D9, DI00:D2, NSS:D10, MOSI:D11, MISO:D12, SCK:D13
// LCD 16x2 > Arduino: GND:GND, 5V:5V, SDA:A4, SCL:A5

void setup() {

  // initialize display
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);

  // Begin Serial communication at a baudrate of 9600:
  Serial.begin(9600);
  while (!Serial);
  Serial.println("LoRa Receiver");
  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  LoRa.setSpreadingFactor(12);
  LoRa.setSignalBandwidth(62.5E3);
}

void loop() {
  int packetSize = LoRa.parsePacket();
  if (packetSize) 
  {
    // received a paket
    Serial.println("");
    Serial.println(".................");
    Serial.println("Received packet: ");

    // read packet
    inString = "";
    while (LoRa.available())
    {
      char incoming = (char)LoRa.read(); //read each chr
      if( incoming == '*')
        {break;}             //breaks the appending action; if '*'
      inString += incoming; //append all chr
      counter ++;
    }
  }
  int newlineIndex = inString.indexOf('\n');
  String line1 = inString.substring(0, newlineIndex);
  String line2 = inString.substring(newlineIndex + 1);
  //if any string is captured
  if (counter>0)
  { 
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(line1);
    lcd.setCursor(0, 1);
    lcd.print(line2);
    Serial.print(inString); //display in monitor
  }
  counter =0; 
}

This code is designed to run on the Arduino Nano and handles the initialization and communication with both the LoRa module and the I2C LCD screen. It sets up the LoRa module for receiving data at a frequency of 433 MHz and displays any received data on the LCD. The code also includes error handling for the LoRa module initialization and reads incoming data until a '*' character is received, indicating the end of a message.