Logo

Getting Started with TTGO LoRa32 SX1276 OLED

What is the TTGO LoRa32 SX1276 Board?

The TTGO LoRa32 SX1276 is a development board based on the ESP32 microcontroller with an integrated Semtech SX1276 LoRa transceiver (868/915 MHz) and a built-in 0.96" OLED display. It is ideal for creating IoT applications that require long-range communication without internet dependency, such as weather stations, agriculture monitoring, and asset tracking.

How TTGO LoRa32 Works

This board allows two or more nodes to communicate wirelessly using the LoRa protocol. The SX1276 chip enables ultra-long-range spread spectrum communication with high interference immunity. One board can be configured as a sender (transmitter), and another as a receiver. Data sent via LoRa is received and can be displayed on the OLED or sent to other peripherals.

  • Connect TTGO LoRa32 via USB to your computer.
  • Install necessary libraries for LoRa and OLED in Arduino IDE.
  • Write and upload code for both sender and receiver roles.
  • Use LoRa.begin() to initialize communication at 915 MHz (or 868 MHz).
  • Display received data on the OLED screen.
  • Power both boards and observe long-range data transmission.

Formula: LoRa Packet = [Payload Data] + [Spreading Factor] + [Frequency] + [CRC]

Components Required

  • 2 × TTGO LoRa32 SX1276 OLED Boards
  • Micro USB Cables
  • Laptop with Arduino IDE
  • Antenna (included with boards)
  • Sensors (optional for transmitting data)
  • Battery pack or USB power bank (for mobility)

Pin Configuration

  • OLED SDA: GPIO 4 (I2C Data)
  • OLED SCL: GPIO 15 (I2C Clock)
  • LoRa NSS: GPIO 18 (SPI CS)
  • LoRa RST: GPIO 14 (Reset)
  • LoRa DIO0: GPIO 26 (Interrupt)
  • MOSI: GPIO 27
  • MISO: GPIO 19
  • SCK: GPIO 5

Ensure antennas are connected before powering the boards to avoid damage to the SX1276 chip. Mismatched frequencies (e.g., sending on 868 MHz and receiving on 915 MHz) will result in communication failure.

Wiring and Connections (Optional Sensors)

  • Sensor VCC -> 3.3V
  • Sensor GND -> GND
  • Sensor OUT -> GPIO 33

Sender Code for TTGO LoRa32 SX1276

1#include <SPI.h>
2#include <LoRa.h>
3#include <Wire.h>
4#include <Adafruit_SSD1306.h>
5
6#define OLED_SDA 4
7#define OLED_SCL 15
8#define SCREEN_WIDTH 128
9#define SCREEN_HEIGHT 64
10Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
11
12void setup() {
13  Serial.begin(115200);
14  Wire.begin(OLED_SDA, OLED_SCL);
15  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
16  display.clearDisplay();
17  display.setTextSize(1);
18  display.setTextColor(WHITE);
19  display.setCursor(0, 0);
20  display.println("LoRa Sender");
21  display.display();
22
23  LoRa.setPins(18, 14, 26);
24  if (!LoRa.begin(915E6)) {
25    Serial.println("Starting LoRa failed!");
26    while (1);
27  }
28  Serial.println("LoRa Initialized");
29}
30
31void loop() {
32  String message = "Hello from TTGO Sender!";
33  LoRa.beginPacket();
34  LoRa.print(message);
35  LoRa.endPacket();
36
37  Serial.println("Sent: " + message);
38  display.clearDisplay();
39  display.setCursor(0, 0);
40  display.println("Sent:");
41  display.println(message);
42  display.display();
43  delay(2000);
44}

Code Explanation

  • #include <LoRa.h>: Includes the LoRa library to handle wireless transmission.
  • LoRa.setPins(18, 14, 26);: Sets the SPI CS, reset, and DIO0 pins for the LoRa module.
  • LoRa.begin(915E6);: Initializes LoRa on 915 MHz frequency.
  • display.begin(): Initializes the OLED screen with I2C settings.
  • LoRa.beginPacket(): Starts a new LoRa data packet to be sent.
  • LoRa.endPacket(): Ends and transmits the data packet.

Applications

  • Long-range IoT communication
  • Smart farming data transmission
  • Remote environmental monitoring
  • Wildlife tracking networks
  • Disaster alert mesh systems
  • Asset tracking with GPS add-on

Conclusion

The TTGO LoRa32 SX1276 board with its built-in OLED and LoRa capability offers a robust platform for long-distance, low-power communication. It simplifies the development of scalable IoT systems that operate without Wi-Fi or cellular networks. Whether you're building a sensor network or a real-time alert system, this board is a powerful tool for prototyping and deployment.