TTGO LoRa32 SX1276 OLED Board: Getting Started with Arduino IDE

The TTGO LoRa32 SX1276 OLED is an ESP32 development board with a built-in LoRa chip and an SSD1306 0.96 inch OLED display. In this guide, we’ll show you how to: send and receive LoRa packets (point to point communication) and use the OLED display with Arduino IDE.

TTGO LoRa32 OLED SX1276 Board: Getting Started with Arduino IDE

For an introduction to LoRa communication, read: ESP32 with LoRa using Arduino IDE.

TTGO LoRa32 SX1276 OLED Overview

The TTGO LoRa32 SX1276 OLED is a development board with an ESP32, a built-in LoRa chip and an SSD1306 OLED display. This is the OLED model display we use in most of our electronics projects (Guide for OLED display with ESP32).

 TTGO LoRa32 OLED SX1276 Overview

The board also features several GPIOs to connect peripherals, PRG (BOOT) and RST buttons, and a lithium battery connector. For a more in-depth overview of this board, read: TTGO LoRa32 SX1276 OLED Review.

Where to buy?

You can go to the TTGO LoRa32 SX1276 OLED page on Maker Advisor to find the best price at different stores. To complete this tutorial, you’ll need two TTGO LoRa32 boards.

TTGO LoRa32 OLED SX1276

TTGO LoRa32 SX1276 OLED

The following figure shows the TTGO LoRa32 OLED board pinout.

 TTGO LoRa32 OLED SX1276 Pinout Diagram

The OLED displays communicates using I2C communication protocol. It is internally connected to the ESP32 on the following pins:

OLED (built-in)ESP32
SDAGPIO 4
SCLGPIO 15
RSTGPIO 16

The SX1276 LoRa chip communicates via SPI communication protocol, and it is internally connected to the ESP32 on the following GPIOs:

SX1276 LoRaESP32
MISOGPIO 19
MOSIGPIO 27
SCKGPIO 5
CSGPIO 18
IRQGPIO 26
RSTGPIO 14

Recommended reading: ESP32 Pinout Reference Guide

Install ESP32 Boards on Arduino IDE

To program the TTGO LoRa32 board, we’ll use Arduino IDE. So, you must have Arduino IDE installed as well as the ESP32 add-on. Follow the next guide to install the ESP32 package on Arduino IDE, if you haven’t already:

Installing OLED Libraries

There are several libraries available to control the OLED display with the ESP32. In this tutorial we’ll use two Adafruit libraries: Adafruit_SSD1306 library and Adafruit_GFX library.

Follow the next steps to install those libraries.

1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open.

2. Type “SSD1306” in the search box and install the SSD1306 library from Adafruit.

Installing the Adafruit SSD1306 library for OLED display Arduino IDE

3. After installing the SSD1306 library from Adafruit, type “GFX” in the search box and install the library.

Installing GFX Library for ESP32 Arduino IDE

Installing LoRa Library

There are several libraries available to easily send and receive LoRa packets with the ESP32. In this example we’ll be using the arduino-LoRa library by sandeep mistry.

Open your Arduino IDE, and go to Sketch > Include Library > Manage Libraries and search for “LoRa“. Select the LoRa library highlighted in the figure below, and install it.

Installing LoRa Library for ESP32 Arduino IDE

After installing the libraries, restart your Arduino IDE.

LoRa Sender Sketch

Copy the following code to your Arduino IDE. This code sends a “hello” message followed by a counter via LoRa every 10 seconds. It also displays the counter on the OLED display.

/*********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/ttgo-lora32-sx1276-arduino-ide/
*********/

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

//define the pins used by the LoRa transceiver module
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 866E6

//OLED pins
#define OLED_SDA 4
#define OLED_SCL 15 
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//packet counter
int counter = 0;

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

void setup() {
  //initialize Serial Monitor
  Serial.begin(115200);

  //reset OLED display via software
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  //initialize OLED
  Wire.begin(OLED_SDA, OLED_SCL);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("LORA SENDER ");
  display.display();
  
  Serial.println("LoRa Sender Test");

  //SPI LoRa pins
  SPI.begin(SCK, MISO, MOSI, SS);
  //setup LoRa transceiver module
  LoRa.setPins(SS, RST, DIO0);
  
  if (!LoRa.begin(BAND)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  Serial.println("LoRa Initializing OK!");
  display.setCursor(0,10);
  display.print("LoRa Initializing OK!");
  display.display();
  delay(2000);
}

void loop() {
   
  Serial.print("Sending packet: ");
  Serial.println(counter);

  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();
  
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("LORA SENDER");
  display.setCursor(0,20);
  display.setTextSize(1);
  display.print("LoRa packet sent.");
  display.setCursor(0,30);
  display.print("Counter:");
  display.setCursor(50,30);
  display.print(counter);      
  display.display();

  counter++;
  
  delay(10000);
}

View raw code

How the code works

Start by including the libraries to interact with the LoRa chip.

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

Then, include the libraries to interface with the I2C OLED display.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Define the pins used by the LoRa transceiver module:

#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

Select the LoRa frequency:

#define BAND 866E6

Define the OLED pins.

#define OLED_SDA 4
#define OLED_SCL 15 
#define OLED_RST 16

Define the OLED size.

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Create a counter variable to keep track of the number of LoRa packets sent.

int counter = 0;

Create an Adafruit_SSD1306 object called display.

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

setup()

In the setup(), to start using the OLED you need to do a manual reset via software using the RST pin. To do this reset, you need to declare the RST pin as an output, set it to LOW for a few milliseconds and then, set it to HIGH again.

pinMode(OLED_RST, OUTPUT);
digitalWrite(OLED_RST, LOW);
delay(20);
digitalWrite(OLED_RST, HIGH);

Start an I2C communication using the defined OLED_SDA and OLED_SCL pins using Wire.begin().

Wire.begin(OLED_SDA, OLED_SCL);

After that, initialize the display with the following parameters. The parameters set as false ensure that the library doesn’t use the default I2C pins and use the pins defined in the code (GPIO 4 and GPIO 15).

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32
  Serial.println(F("SSD1306 allocation failed"));
  for(;;); // Don't proceed, loop forever
}

Then, you can use the methods from the Adafruit library to interact with the OLED display. To learn more you can read our tutorial about the I2C OLED display with the ESP32.

Write the message “LORA SENDER” to the display.

display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.print("LORA SENDER ");
display.display();

Initialize the serial monitor for debugging purposes.

Serial.begin(115200);
Serial.println("LoRa Sender Test");

Define the SPI pins used by the LoRa chip.

SPI.begin(SCK, MISO, MOSI, SS);

And set up the LoRa transceiver module.

LoRa.setPins(SS, RST, DIO0);

Finally, initialize the LoRa transceiver module using the begin() method on the LoRa object and pass the frequency as argument.

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

If we succeed in initializing the display, we write a success message on the OLED display.

display.setCursor(0,10);
display.print("LoRa Initializing OK!");
display.display();

loop()

In the loop() is where we’ll send the packets. You initialize a packet with the beginPacket() method.

LoRa.beginPacket();

You write data into the packet using the print() method. As you can see in the following two lines, we’re sending a hello message followed by the counter.

LoRa.print("hello ");
LoRa.print(counter);

Then, close the packet with the endPacket() method.

LoRa.endPacket();

Next, write the counter on the OLED display

display.clearDisplay();
display.setCursor(0,0);
display.println("LORA SENDER");
display.setCursor(0,20);
display.setTextSize(1);
display.print("LoRa packet sent.");
display.setCursor(0,30);
display.print("Counter:");
display.setCursor(50,30);
display.print(counter);
display.display();

After this, the counter message is incremented by one in every loop, which happens every 10 seconds.

counter++;
delay(10000);

Testing the LoRa Sender

Upload the code to your board. You need to select the right board and COM port you’re using.

To select the board, in the Arduino IDE, go to Tools > Board and select the TTGO LoRa32-OLED V1 board.

Select TTGO LoRa32 OLED V1 in Arduino IDE

After uploading the code to your board, it should start sending LoRa packets.

TTGO LoRa ESP32 Dev Board Sender

LoRa Receiver Sketch

Now, upload the receiver sketch to another TTGO LoRa32 OLED board. This sketch listens for LoRa packets within its range and prints the content of the packets on the OLED, as well as the RSSI (relative received signal strength).

/*********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/ttgo-lora32-sx1276-arduino-ide/
*********/

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

//define the pins used by the LoRa transceiver module
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 866E6

//OLED pins
#define OLED_SDA 4
#define OLED_SCL 15 
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

String LoRaData;

void setup() { 
  //initialize Serial Monitor
  Serial.begin(115200);
  
  //reset OLED display via software
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);
  
  //initialize OLED
  Wire.begin(OLED_SDA, OLED_SCL);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("LORA RECEIVER ");
  display.display();

  Serial.println("LoRa Receiver Test");
  
  //SPI LoRa pins
  SPI.begin(SCK, MISO, MOSI, SS);
  //setup LoRa transceiver module
  LoRa.setPins(SS, RST, DIO0);

  if (!LoRa.begin(BAND)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  Serial.println("LoRa Initializing OK!");
  display.setCursor(0,10);
  display.println("LoRa Initializing OK!");
  display.display();  
}

void loop() {

  //try to parse packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    //received a packet
    Serial.print("Received packet ");

    //read packet
    while (LoRa.available()) {
      LoRaData = LoRa.readString();
      Serial.print(LoRaData);
    }

    //print RSSI of packet
    int rssi = LoRa.packetRssi();
    Serial.print(" with RSSI ");    
    Serial.println(rssi);

   // Dsiplay information
   display.clearDisplay();
   display.setCursor(0,0);
   display.print("LORA RECEIVER");
   display.setCursor(0,20);
   display.print("Received packet:");
   display.setCursor(0,30);
   display.print(LoRaData);
   display.setCursor(0,40);
   display.print("RSSI:");
   display.setCursor(30,40);
   display.print(rssi);
   display.display();   
  }
}

View raw code

This sketch is very similar with the previous one. We just need to modify some lines to receive LoRa packets instead of sending.

In the loop(), we check if there are new packets to receive using the parsePacket() method.

int packetSize = LoRa.parsePacket();

If there’s a new packet, we’ll read its content. To read the incoming data, use the readString() method. The data received is saved on the LoRaData variable.

if (packetSize) {
  //received a packet
  Serial.print("Received packet ");

  //read packet
  while (LoRa.available()) {
    LoRaData = LoRa.readString();
    Serial.print(LoRaData);
  }

We also get the RSSI of the received packet by using the packetRSSI() method.

int rssi = LoRa.packetRssi();

Finally, display the received message, as well as the RSSI.

display.clearDisplay();
display.setCursor(0,0);
display.print("LORA RECEIVER");
display.setCursor(0,20);
display.print("Received packet:");
display.setCursor(0,30);
display.print(LoRaData);
display.setCursor(0,40);
display.print("RSSI:");
display.setCursor(30,40);
display.print(rssi);
display.display();

Testing the LoRa Receiver

Upload the code to your board. Don’t forget you need to select the TTGO LoRa32-OLED V1 in the Boards menu.

After uploading the code, it should start receiving the LoRa packets from the other board.

TTGO LoRa ESP32 Dev Board Receiver

Wrapping Up

This article was a quick getting started guide for the TTGO LoRa32 board how to: send LoRa packets in point to point communication and use the OLED display.

Now, the idea is to combine what you’ve learned here to build IoT projects. LoRa can be specially useful if you want to receive sensor readings that are not covered by your wi-fi network and are several meters apart. Additionally, you can also connect your board to the TTN (The Things Network).

We hope you’ve found this tutorial useful. Learn more about the ESP32 with our resources:

Thanks for reading.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

175 thoughts on “TTGO LoRa32 SX1276 OLED Board: Getting Started with Arduino IDE”

  1. How i can transfer from this board using UART the data to a pic18.
    I would like to have a Pic18 + Lora+ ESP and be able to send 30 bytes to a second Pic18, or receive from other PIC18 a group of 30 bytes.

    Reply
  2. The TTGO series of boards are great, they have loads of really odd ones too, like esp32 + a camera, or SIM card, or GPS, or DHT sensor, just about any project you want, there is a TTGO board for it.
    Only thing I’ve found is the range of the TTGO LoRa is pretty poor, I’m only getting a couple 100m in clear open countryside, rather than the 1000s of m it should really be.

    Reply
      • Hi Sara,
        may I point your attention to a new (or not so new) fact:
        The TTGO LoRa32 SX1276 OLED Board has obviously changed it’s I2C pins.
        It’s not any more as stated in the sketch:
        #define OLED_SDA 4
        #define OLED_SCL 15
        #define OLED_RST 16
        but
        #define OLED_SDA 21
        #define OLED_SCL 22
        #define OLED_RST (N/A) 23

        As OLED_RST is somewhere used in the sketch and I was too lazy to friggle throuh the lines I used pin 23 which is the LORA reset but works out fine.

        Thanks for your detailed instructions, this helped me to get the display alive again.
        Best regards
        Peter

        Reply
  3. Hello Rui and Sara.
    I can send and receive text via Lora.
    But I would like to send an analog value and an on / or switch command to a receiver. I have not yet succeeded. Have you already done something with it? It seems very nice to be able to read something from a greater distance and to switch than just to transfer text.
    I just have no idea how to handle that and I need a hint. The Text distance that I have already covered here is not that great yet. About 1000 Meters, but that is also sufficient for me.
    Greetings from bert from (cold) Netherlands.

    Reply
    • Hi Bert.
      You just need to send your sensor readings as a String.
      For example, the following snipet sends several sensor readings on the same message. Note that each reading is separated by a special character. This way, on the receiver side, you know how to split the message.

      void sendReadings() {
      // Send packet data
      // Send temperature in Celsius
      message = String(readingID) + “/” + String(tempC) + “&” +
      String(soilMoisture) + “#” + String(batteryLevel);
      // Uncomment to send temperature in Fahrenheit
      //message = String(readingID) + “/” + String(tempF) + “&” +
      // String(soilMoisture) + “#” + String(batteryLevel);
      delay(1000);
      LoRa.beginPacket();
      LoRa.print(message);
      LoRa.endPacket();
      }

      This works the same way if you want to sendo commands to turn something on or off.
      On the receiver side, we use the following to read and split the data:

      void getLoRaData() {
      Serial.print(“Lora packet received: “);
      // Read packet
      while (LoRa.available()) {
      String LoRaData = LoRa.readString();
      // LoRaData format: readingID/temperature&soilMoisture#batterylevel
      // String example: 1/27.43&654#95.34
      Serial.print(LoRaData);

      // Get readingID, temperature and soil moisture
      int pos1 = LoRaData.indexOf(‘/’);
      int pos2 = LoRaData.indexOf(‘&’);
      int pos3 = LoRaData.indexOf(‘#’);
      readingID = LoRaData.substring(0, pos1);
      temperature = LoRaData.substring(pos1 +1, pos2);
      soilMoisture = LoRaData.substring(pos2+1, pos3);
      batteryLevel = LoRaData.substring(pos3+1, LoRaData.length());
      }

      Now, feel free to modify these functions to use in your project.
      REgards,
      Sara

      Reply
      • Hi Sara,
        thank you for this piece of code. It’s very interesting since I try to send temperature and soil moisture sensor values with these boards.
        I was wondering if I can still use I2C to connect a BME280.
        I2C is already used by the oled display, but I think it is possible to have both device on the same “line” with different I2C adresses.
        Am I right ?
        Many thanks to you and Ruis for your work and nice tutos ^^

        Reply
          • Hi Antoine and Sarah.

            I tried this on the same I2C bus with bad results. I was using the GY-21P dual sensor. BMP280 and Si7021. I just could not get this working on GPIO 4 and GPIO 15 sharing with the Oled bus.

            My solution was to initialise the display using IO 4 and 15, set it up and display welcome message etc. Then initialise the BMP280 on IO 22 and 23. If left like this it breaks the display.

            To work around this I then use Wire.begin (4,15); which reassigns the I2C to the Oled.

            When reading from BMP280, start the function with Wire.begin (22,23); do the reading and end the function with Wire.begin (4,15);

            In other words, programmatically switch the I2C bus pin configuration when needed. Not sure if this is the best way, but was a simple solution for me.

            Regards,

            Mike.

      • Hi Sara, i was using this command to transfer multiple sensor data through LoRa. I’m using Arduino Nano but there is always give me an error for this piece of command.

        message = String(readingID) + “/” + String(tempC) + “&” +
        String(soilMoisture) + “#” + String(batteryLevel);

        when i delete this command, i can compile succesfully without errror. do i need to install any library to be able to use this command

        Reply
  4. Hi
    I have used these boards to control my outdoor light etc.
    i have connected them with solar cells and 18650 battery with charger module as instructed in Learn ESP32 for Arduino.

    everything has been working perfectly for a month until the battery runs out of power.
    after that I cannot contact the board over USB

    the first time it happened I thought it was a bad board
    but today it happened again with two boards running out of power
    no sun in DanmarK 🙁

    it may be a problem that they get power through the lithium battery. Connecting even if they write is ok?

    Regards
    Aage

    Reply
  5. Hi,

    Great article. I got myself a pair of these to see what I could do.
    They came already programmed as a pair but did not have the signal strength displayed so I re-programmed them using the code in the article which worked flawlessly, thank you.
    I do have a problem though, the range is extremely poor. Although I am only using the antennas that were supplied, I expected much more range. I am getting barely 10m away and the signal is lost.
    I tried disconnecting the antennas on both transmit and receive ends to see if there was a drop in signal which would indicate the antennas were working, (no drop in signal would show one or both antennas were faulty in some way).
    For example, with about 50cm between the two units I get an RSSI of -85 and just moving to the next room (5m away and through just a stud wall) the RSSI drops to -104.
    Is there something wrong do you think?

    Thanks
    Martin

    Reply
    • I’ve had the same problem. But now I checked my failure: I did not select the proper frequency. One has to pay attention to the built in different frequencies of the LoRa transceivers. So I changed “LoRa.begin(866E6)” to “LoRa.begin(433E6)” and the range grew up to more than 1 kilometer.

      Reply
      • How can we check that? I bought two units as the ones on the tutorial, and I’m also getting too short of a range. Is there any problem in setting the frequency to 443MHz?

        Reply
  6. November 28, 2019   —
    Now that we have this board working, I would like to know if the TTGO Model LoRa32 V2.1_1.6 T3 can be programmed using the Arduino IDE?  If Yes, Under the tools tab of the IDE, what board do I select, what upload speed do I select, what programmer do I select, etc.?  Also, do I need to do other things to the board during the upload process ( for instance, as with the TTGO LoRa32-OLED V1 it was required to push and hold the \”prog\” button)?   Bob Rader  

    Reply
      • Hi Sara,
        Can you provide a link or directions to this please? I’m getting an Arduino IDE “Error compiling for board TTGO LoRa32-OLED.” and I think this would help?

        Thank you kindly for your work and assistance helping us all. All these wonderful creations have a spark from you and Rui in them now!

        Kind regards,
        Justin

        Reply
  7. This is cool. Great tutorial! I have a problem, using the TTGO devices. The sender goes forever, but the webserver stops after 50- 250 packets. I switched the sender and receiver and the same thing happens. The webserver/receiver stops responding. No idea why. Was going to put the sender in my observatory to keep track of conditions, but it it quits, won’t be of use. Ideas?

    Thanks,
    Joe

    Reply
  8. Thank you for these examples. The pin assignments for the SPI interface to the SX1276 chip were what I needed to get things working. You’ve provided more information than LilyGo about their own TTGO product. Please note that your code also works with the version that does NOT have the built-in display, just by taking out the OLED code.

    Reply
  9. Hello
    A great tuto as usual !

    I have implemented this LoRa send and LoRa recieve codes on ESP LoRa OLED from TTGO.
    I have combined this tuto with the tuto on BM280 data so that LoRA can relay weather data to a host site for display over the web.
    This can work for hours ( some 8000 packets ) and suddenly the receiver stops receiving packets without any reasons. I need to reset the ESP to restart. When it stucks all Serial.prints are stopped on the serial console, no more IRQ signal are available on IRQ/DiO0 pin.
    I am investigating the following problems: CRC error on reception, unexpected LoRA chip reset on RST pin, LoRa chip loosing LoRa Begin configuration, SPI interrupt conflicting with the OLED display, idle mode ?
    Have you any ideas to solve the problem?

    Reply
    • Hi Alain.
      You can check for that in your code and when something wrong happens like: fail to init LoRa, drop internet connection or something, restart the board with: ESP.restart();

      I hope this helps.
      Regards,
      Sara

      Reply
      • Hi Sara

        Thank you for your prompt answer.
        Today, my workaround was to include a LoRa.begin(BAND) command after each sucessfully received packet .
        This looks to solve the problem for now more than 23 000 packets received.
        I hope this could also help other members in the ESP/LoRa community.
        Besr regards

        Alain

        Reply
        • I tried this and it’s the receiver that quits. Restarting the receiver gets it going again??? Dies at somewhere around 70 packets.

          Reply
          • Instead of restarting the receiver I have schedule the receiver to go in deep sleep modefor 10 secondes after every sucessful reception of the LoRa packet. This greatly increased the robustness of the service. A Longer test period is necessary to conclude.
            Note : the idea of reprogramming with LoRa begin after reception was not 100% satisfactory for me. The receiver still stuck after some 12000 packets.

          • I wonder it it is related to the frequency. I’m in the US so am using the 915 band. I am sampling every 60 sec.

    • After experiencing the receiver stall problem mentioned several time in these comments, and trying all the mentioned fixes with no satisfaction, I checked the API and found the following: LoRa.receive(); which according to the docs sets the chip to continuous receive. Has worked well for several days now with 100ms updates of the received data (a counter). so I’m guessing the chip goes to sleep on its own for some reason. I will dig into the 1276 data sheet for more info as time permits. For now the following code works:

      void initLora() {
      //SPI LoRa pins
      SPI.begin(SCK, MISO, MOSI, SS);
      //setup LoRa transceiver module
      LoRa.setPins(SS, RST, DIO0);
      LoRa.begin(BAND);
      LoRa.receive(); // Sets continuous receive

      Reply
  10. Hello

    I have sucessfully implemented this brillant tutotrial to deliver BME 280 data to a web server accessible over WiFi.
    I am periodically experiencing the LoRa receiver that stops delivering packets after some 1000’s of perfect data transmission.
    No more IRQ signals are visible from the LoRa chip. The ESP is still looping correctly.
    With full ESP restart, the receiver resumes its task. Also with a single LoRa.begin(BAND) command (without ESP reset) the receiver also resumes its task.
    Can we suspect conflicts between functions/librairies : OLED, LoRa, WiFi, http?

    Reply
  11. January 12, 2020
    Hi Sara,

    The TTGO LoRa project is going well for me and thanks a million for all your tutorials, posts and the E-Books.
    Using a pair of TTGO V2.1 – 1.6 T3 modules I have been able to transmit & receive the transmitted signal more than 5km. I like Using this module because it allows me to connect the module directly to a vertically polarized dipole antenna at both the Tx & Rx ends. For this distance test the signal path was line-of-sight with no interfering obstructions.
    Now, my next project will be to see how far I can actually transmit the LoRa signal. To do this I will need to play with some of the LoRa SX1276 parameters which effect the range such as coding factor, bandwidth, Tx power, etc…

    One issue I have NOT been able to successfully resolve is changing these LoRa RF parameters on the SX1276 using the LoRa library. For instance, I recently attempted to adjust the transmit power parameter without success. Note, I am using a spectrum analyzer to view and characterize the short burst of RF output signal from the TTGO module.

    I also would like to play with some of the other LoRa parameters like coding factor, bandwidth, spreading factor and other such parameters. However, I am unable to find the correct syntax nor any documentation as to how to set and use such parameters.

    Can you help???

    Regards,
    Bob Rader

    Reply
  12. I’m using the heltec board and my program pauses within this if statement. What would the issue be with this?

    if (!LoRa.begin(BAND)) {
    Serial.println(“Starting LoRa failed!”);
    while (1);
    }

    Reply
    • Hi Harry.
      It probably means that LoRa is not initializing properly.
      What LoRa boards are you using? Your board might be using a different pinout than ours.
      Regards,
      Sara

      Reply
        • Hi again.
          I just checked and the Heltec LoRa boards with oled have the same pinout as the TTGO LoRa32. So, the code should work straight away (unless you have a “weird” version of an heltec board).
          So, without more information, it is very difficult to find out what might be wrong :/
          Regards,
          Sara

          Reply
  13. Hello Sara Santos, how are you? I hope fine.

    I have two modules TTGO LORA_V1_0_OLED and they working normally, however I using the standard Send/Receive LoRa examples, I would like to know if its possible to improve the RSSI value by adjusting some parameters on the code like for an example the TxPower on the Sender? Have you tried this and could you share the part of your code?

    Thank you!

    Reply
      • Hi Sara,
        I am responding to Cassio Lucas’ post of February 2, 2020 and your reply to him. I am providing a copy of my Sender & Receiver sketches allowing for and utilizing the LoRa RF & Modulation parameters.
        I have also done distance testing and have so far been able to send a LoRa message more than 5 km. To do this I am using the TTGO V2.1 -1.6 T3 with a home made ground plane antenna at each end. My signal path also is “line-of-sight” with NO intervening obstructions. I have found that the external antennas are very very important to get good range.
        Further please note that this testing was done on the 433 Mhz band here in the US running under amateur radio authorization. I have also used the same sketches on 915 Mhz making the appropriate frequency changes in the sketches, LoRa module & antenna.
        I also would like to suggest 2 articles I found very helpful to help understand the LoRa Modulation parameters.
        Two very good articles explaining the LoRa RF parameters are:
        “A Study of LoRa: Long Range & Low Power Networks for the Internet of Things”
        explaining the LoRa parameters can be found at https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5038744/
        &
        Decoding Lora https://revspace.nl/DecodingLora

        Here are my two sketches (please note it appears that the copy did not preserve the exact/ correct formatting):

        //
        //
        /*********
        Rui Santos
        Complete original project details at https://RandomNerdTutorials.com/ttgo-lora32-sx1276-arduino-ide/

        ********************************** Receive Unit set For 433 Mhz Band *********

        TTGO V2.1_1.6 T3 — Receiver Sketch —
        Version 1-30-20

        Notes: ** LoRa RF parameters for the receiver MUST BE set the same as the SENDER **

        Modified by Bob Rader 1-22-20 added LoRa RF Parameters, internal green
        LED and an external output for an LED on pin 12 to verify receipt of packet.
        Added to the display the analog reading & digital status sent from sender
        Mod of 1-30-20 — added call sign
        2-2-20 modified for signal range test without the Digital or Analog, Removed Call Sign

        Two very good articles explaining the LoRa RF parameters:

        “A Study of LoRa: Long Range & Low Power Networks for the Internet of Things”
        explaining the LoRa parameters can be found at https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5038744/
        &
        Decoding Lora https://revspace.nl/DecodingLora

        *********/

        //433E6 for Asia
        //866E6 for Europe
        //915E6 for North America

        /**************************** SET LoRa RF & Modilation Parameters *******************************
        *
        Define parameters to be used by LoRa module
        Band Band or Freq — 433E6 for Asia, 866E6 Europe, 915E6 North America
        ie: 915E6 or 922350000 or any specific frequency
        Power Tx Power 2 to 20 default 17
        SF Spreading Factor 6 to 12 default 7
        BW Bandwith 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,
        41.7E3, 62.5E3, 125E3, & 250E3 default 125E3
        CR Coding Rate 5 or 8 default 5
        Preamble Preamble 6 to 65535 default 8
        SyncWd Sync Word byte val to use as sync word default 0x12

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

        #define Band 433E6 // Set Band or Frequency in Hz
        #define SF 10 // Set Spreading Factor
        #define BW 125E3 // Set Bandwidth
        #define CR 5 // Set Coding Rate
        #define Preamble 255 // Set Preamble
        #define SyncWd 0x12 // Set Sync Word

        //************************************………….. Libraries for LoRa

        #include
        #include

        //************************************………….. Libraries for OLED Display

        #include
        #include
        #include

        //************************************………….. Define pins used by LoRa module

        #define SCK 5
        #define MISO 19
        #define MOSI 27
        #define SS 18
        #define RST 23
        #define DIO0 26

        //************************************……………Define pins & Parameters used by OLED Display
        // and variables

        #define OLED_SDA 21
        #define OLED_SCL 22
        #define OLED_RST 16
        #define SCREEN_WIDTH 128 // OLED display width, in pixels
        #define SCREEN_HEIGHT 64 // OLED display height, in pixels

        Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

        String LoRaData;
        const int ledPin = 25; //Use pin 25 for Led
        const int ledPin1 = 12; //Use pin 12 for External Led

        void setup() {

        pinMode(ledPin, OUTPUT); //Define ledPin as output
        pinMode(ledPin1, OUTPUT);//Define ledPin as output
        //reset OLED display via software
        pinMode(OLED_RST, OUTPUT);
        digitalWrite(OLED_RST, LOW);
        delay(20);
        digitalWrite(OLED_RST, HIGH);

        digitalWrite(ledPin, HIGH);

        //************************************…. Initialize OLED ……. Address 0x3C

        Wire.begin(OLED_SDA, OLED_SCL);
        if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C
        Serial.println(F(“SSD1306 allocation failed”));
        for(;;); // Don’t proceed, loop forever
        }
        //***********************************…..Set-Up Display

        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setTextSize(1);
        display.setCursor(0,0);
        display.print(“LORA RECEIVER “);
        display.display();

        // initialize Serial Monitor
        Serial.begin(115200);

        Serial.println(“LoRa Receiver Test”);

        //************************************ LoRa SPI pins

        SPI.begin(SCK, MISO, MOSI, SS);
        //************************************ setup LoRa transceiver module & Frequency

        LoRa.setPins(SS, RST, DIO0);

        if (!LoRa.begin(Band)) { // Please Set Correct Frequency/ Band above
        Serial.println(“Starting LoRa failed!”);
        while (1);
        }

        //************************************ Setup LoRa Transmission Parameters
        LoRa.setSpreadingFactor(SF); // 6-12
        LoRa.setSignalBandwidth(BW); // 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,
        // 41.7E3, 62.5E3, 125E3, & 250E3
        LoRa.setCodingRate4(CR); // 5 or 8
        LoRa.setPreambleLength(Preamble); // 5 to 65535
        LoRa.setSyncWord(SyncWd); // byte val to use as sync word

        Serial.println(“LoRa Initializing OK!”);
        display.setCursor(0,10);
        display.println(“LoRa Initializing OK!”);
        display.display();
        }
        //************************** START LOOP **********************************
        //*******************************************************************************

        void loop() {

        //*****************************……… parse data from packet
        int packetSize = LoRa.parsePacket();
        if (packetSize) { // when no more data in packet — end
        //received a packet
        Serial.print(“Received packet “);

        //*****************************……….read packet data
        while (LoRa.available()) { // while data is in packet
        LoRaData = LoRa.readString(); // read data
        Serial.print(LoRaData); // continue until all packet
        } // data has been read

        //*****************************……….print RSSI
        int rssi = LoRa.packetRssi(); // read the transceiver RSSI value
        Serial.print(” with RSSI “);
        Serial.println(rssi);

        //*****************************……….display information on Oled Display
        display.clearDisplay();
        display.setCursor(0,0); // Set cursor to col 0 line 0
        display.setTextSize(2);
        display.print(“LoRa 433Rx”); // Send “LORA RECEIVER” to top line of display
        display.setCursor(10,18); // Set cursor to col 10 line 18
        display.print(LoRaData);
        display.setCursor(0,54); // Set cursor to col 0 line 54
        display.setTextSize(1);
        display.print(“RSSI = “);
        display.setTextSize(2);
        display.setCursor(48,50); // Set cursor to col 48 line 50
        display.print(rssi);
        display.display();

        if (LoRaData == “Test 123”) // test to see if data received is
        { // same as data sent — if yes,
        for (int i = 0; i < 3; i++) // blink ledPin 3 times
        {
        digitalWrite(ledPin, HIGH);
        digitalWrite(ledPin1, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        digitalWrite(ledPin1, LOW);
        delay(200);
        }
        }

        //*****************************……….blink external & internal green LED
        // 3 times to verify receipt of packets
        /* for (int i = 0; i < 3; i++){
        digitalWrite(ledPin, HIGH);
        digitalWrite(ledPin1, HIGH);
        delay(300);
        digitalWrite(ledPin, LOW);
        digitalWrite(ledPin1, LOW);
        delay(300);
        }
        */
        }
        }

        //**************** END ****************
        //
        //

        /*
        **************………. TTGO V2.1-1.6 T3 Transmit/ Sender Sketch……….***********
        Original sketch from
        Rui Santos
        Complete original project details at https://RandomNerdTutorials.com/ttgo-lora32-sx1276-arduino-ide/

        Set for transmittion on 433 Mhz

        Sketch 2-2-20 Used to send test text "Testing 123" to TTGO Receiver Module

        Modified 12-9-19 By Adolfo Mondragon added both an Analog Input & digital Input

        ********************************** Sender/ Transmit Unit set For 433 Mhz Band *********

        TTGO V2.1_1.6 T3 — Sender Sketch —
        Version 2-2-20

        Notes: ** LoRa RF parameters for the receiver MUST BE set the same as the SENDER **

        Modified by Bob Rader 1-22-20 added LoRa RF Parameters, internal green Led

        Added to the display the analog reading & digital status sent from sender
        Mod of 1-30-20 — added call sign
        modified for signal range test without the Digital or Analog, Removed Call Sign

        Two very good articles explaining the LoRa RF parameters:

        "A Study of LoRa: Long Range & Low Power Networks for the Internet of Things"
        explaining the LoRa parameters can be found at https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5038744/
        &
        Decoding Lora https://revspace.nl/DecodingLora

        **************************************………….. SET LoRa Modulation & RF Parameters

        Band Band or exact Freq 433E6 for Asia, 866E6 Europe, 915E6 America
        ie: 915E6 or 922350000 or another specific frequency
        Power Tx Power 2 to 20 default 17
        SF Spreading Factor 6 to 12 default 7
        BW Bandwith 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,
        41.7E3, 62.5E3, 125E3, & 250E3 default 125E3
        CR Coding Rate 5 or 8 default 5
        Preamble Preamble 6 to 65535 default 8
        SyncWd Sync Word byte val default 0x12
        ********************************************************************************************
        */

        #define Band 433E6 // Set Module Frequency
        #define Power 17 // Set Power (2 to 20)
        #define SF 10 // Set Spreading Factor (6 to 12)
        #define BW 125E3 // Set Bandwidth (see above)
        #define CR 5 // Set Coding Rate (5 or 8)
        #define Preamble 8 // Set Preamble (6 to 65535)
        #define SyncWd 0x12 // Set Sync Word ( default 0x12)

        //********************………….. Libraries for LoRa………******************
        #include
        #include

        //*******************………….. Libraries for OLED Display …………..**********
        #include
        #include
        #include

        //******************…………. Define pins used by LoRa SX1276 module…………..***
        #define SCK 5
        #define MISO 19
        #define MOSI 27
        #define SS 18
        #define RST 23
        #define DIO0 26

        const int ledPin = 25; // Uses Pin 25 for internal Grn LED to indicate transmission made

        //*********************……………Define pins & Parameters used by OLED Display…………..
        #define OLED_SDA 21
        #define OLED_SCL 22
        #define OLED_RST 16
        #define SCREEN_WIDTH 128 // OLED display width, in pixels
        #define SCREEN_HEIGHT 64 // OLED display height, in pixels
        Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, & Wire, OLED_RST);

        //********************………….. Define Sensors…………..**********

        byte sensor_D ; // This will be the Digital I/O Input on pin 14
        int sensor_A ; // This will be the Analog Input on pin 12

        //*******************………….. initialize and set-up ESp32 Pins & Serial Monitor …………..

        void setup() {
        Serial.begin(9600); // set baud rate for serial monitor

        pinMode(14, INPUT_PULLUP); // Use pin 14 for Digital Input SENSOR with pull-up
        pinMode(12, INPUT); // Use pin 12 for Analog Input SENSOR, see below
        pinMode(ledPin, OUTPUT); // Use pin 25 For internal Led — On when in Tx mode

        //***************************………….. Reset OLED display…………..**********
        pinMode(OLED_RST, OUTPUT);
        digitalWrite(OLED_RST, LOW);
        delay(20);
        digitalWrite(OLED_RST, HIGH);

        //************************************…. Initialize OLED at address 0x3C…………..
        Wire.begin(OLED_SDA, OLED_SCL);
        if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) {
        for(;;); // ………. Don’t proceed, loop forever…………..
        }
        //*************************……..Set-Up & Write To Display…………..****************
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setTextSize(1);
        display.setCursor(10,0);
        display.print(“LoRa Sender Module”);
        display.setCursor(30,10);
        display.print(“initalized OK!”);
        display.display();

        //************************************ LoRa SPI pins…………..**********
        SPI.begin(SCK, MISO, MOSI, SS);

        //********************************…………..Set & test LoRa transmit frequency…………..
        LoRa.setPins(SS, RST, DIO0);
        if (!LoRa.begin(Band)) {
        while (1);
        }

        //************************…..Setup LoRa Transmission & Modulation Parameters…………..

        LoRa.setTxPower(Power); // 2 to 20
        LoRa.setSpreadingFactor(SF); // 6-12
        LoRa.setSignalBandwidth(BW); // 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,
        // 41.7E3, 62.5E3, 125E3, & 250E3
        LoRa.setCodingRate4(CR); // 5 or 8
        LoRa.setPreambleLength(Preamble); // 5 to 65535
        LoRa.setSyncWord(SyncWd); // byte val to use as sync word 0x12
        delay(2000);
        }

        //***************** START LOOPING **********************************
        //*************************************************************************
        //***************** Start Looping *********************************

        void loop() {
        //****************************……… Read Sensors…………..**********

        sensor_A = analogRead(12); // Analog Data Attached To Pin 12
        // If using a Test Pot > connect +3.3V — Pin 12 — GND
        sensor_D = digitalRead(14); // Digital Input Attached To Pin 14, Hi or Low

        digitalWrite(ledPin, HIGH); // Turn ESP 32 on-board green LED (attached to pin 25) on
        // to indicate a transmission in progress
        Serial.print(sensor_A); // Print Analog value to serial monitor
        Serial.print(” “); //
        Serial.println(sensor_D); // Print Digital value to serial monitor

        //**************************…. Send the LoRa packets…………..**********

        LoRa.beginPacket();
        LoRa.print(“Test 123”);
        /*
        LoRa.print(sensor_D);
        LoRa.println(“”);
        LoRa.print(“A = “);
        LoRa.print(sensor_A);
        */
        LoRa.endPacket();

        // ***********************………….. Write to local Display On ESP 32…………..
        display.setTextSize(2);
        display.clearDisplay();
        display.setCursor(0,0);
        display.println(“LORA 433TX”);
        display.setCursor(0,40);
        display.print(“”);
        //display.setCursor(55,20);
        //display.print(sensor_D);
        //display.setCursor(0,40);
        display.print(“Test 123”);
        //display.setCursor(55,40);
        //display.print(sensor_A);
        display.display();

        digitalWrite(ledPin, LOW); // turn ESP green LED off

        delay(3000);
        }

        // ************** END ******************
        //
        //

        Reply
        • Hi Bob.
          Thank you so much for sharing this valuable information.
          Can you please share your codes using pastebin? When you paste the code here, some sections are automatically cut and it doesn’t preserve formatting.
          Regards,
          Sara

          Reply
          • Sara,

            Yes! I would be happy to share my code. Please give me the detailed specifics about sharing the code on pastebin . I am not familiar with this process and as such don’t know how to start or do it. Also, I would like to share some pictures of the, simple to make, home made antennas and perhaps a spectrum analyzer output of the RF signal. How to do this?

            Just need the details & specifics how to proceed…

            Bob Rader

          • Feb 4, 2020

            Sara,

            Hopefully I have been able to successfully drop my .ino code for the TTGO Receiver Sketch to paste.bin. As I have never used this feature I hope all went OK.
            Upon your conformation that all is OK, I will work to upload the Transmit/ Sender sketch…

            The title is: TTGO_V2_1-1_6_T3_Receiver_Sketch_From_Bob_Rader_Feb4_2020

            Please confirm if you are able to get it…

            Regards,
            Bob Rader

          • Sara,

            GREAT! Now that I know how pastebin works I will soon send off the sender/ transmit sketch.

            Regards,

            Bob

          • Sara,

            Here is the link to the sender sketch: https://pastebin.com/qVqJbQYt

            I am also planning in the future to do some fotos of the homemade antennas & a spectrum analyzer screen capture of the RF output. Hope you find these sketches helpful…

            Regards,

            Bob

          • Thank you for sharing.
            What was the communication range that you get with these new LoRa parameters?
            Regards,
            Sara

          • Feb. 6, 2020

            Sara,

            Yes! The communications range is effected by the the modulation parameters, however, there are some other factors that more SIGNIFICANTLY effect the communications range and they have little to do with the modulation parameters. Specifically, the antenna, coax and an unobstructed line-of-sight path between sender & receiver.

            I am getting more than 6 km here in southern New Mexico and feel I can get even longer range by looking at the system from an RF standpoint.

            First let me give you the theoretical stuff:
            The TTGO V2.1 – 1.6 T3 ESP32 LoRa system with modulation parameters of, SF=10; BW=125 KHz and a coding rate of 5. Semtech says that the SX1276 with these parameters should have a receiver sensitivity of -132 dBm. With a transmitter power setting of 17 (+17dBm) yields a total ‘link budget’ of (132 + 17) or 149 dB.
            Now calculating the link losses in free air, (37 dB + 20* (log of freq MHz) + 20* (log of distance miles)), 37dB + 20(log915)=59.2 +20 (log40)=32 (0 dB of antenna gain and 0 dB of coax losses are assumed) or a total link loss of 129 dB. If one wanted to have a 20dB signal margin then these numbers work for a theoretical distance of 65 km. Looking at these numbers, it can be seen that a 3 dB increase in the link budget yields a theoretical distance of almost 90 km.

            My testing to date was only to verify that I could communicate 6 km to a farm field. The distance was line-of-sight with no intervening obstructions. I used external home made ground plane antennas at both ends, with the receive system (antenna & TTGO) about 7 meters above ground and the sender system about 1.5 meters above ground. The TTGO systems and antennas were connected directly to the SMA connector provided on the TTGO (this was the main reason for selecting this ESP32 module). The receiving TTGO said the RSSI was -117 for this test and it should be noted here that the RSSI number does not directly relate to dBm.
            Pictures of this set-up, I hope, will be forth coming in the near future.

            It is hopped this helps you and others working with the LoRa technology. I find the LoRa quite fascinating and functional for battery powered low speed data transfers with very long expected battery life.

            Also, I wish to thank you and Rui for all your help with the ESP32 programming end of things. Your help and assistance was invaluable in getting this project up and running.

            Regards,

            Bob Rader

  14. #Bob Rader

    I’am trying to change Signal BandWidth.
    But no matter what I set. SBW stays at 125khz.
    I’ve tried these methods:

    #define BW 62.5E3 // Set Bandwidth

    and…

    LoRa.setSignalBandwidth(62.5E3);

    Can anyone please clarify !

    Reply
    • March 2, 2020

      Hi AuLeeFor,

      A few things come to mind in trying to help with your issue:

      First, I use the TTGO LoRa32 V2.1_1.6 T3 module due to the SMA connector attached directly on the board. For me it makes the antenna mounting easier and less signal loss in the antenna feed line circuit.

      Second, I am using the Sandeepmistry LoRa Library with the
      #include LoRa.h statement at the beginning of my sketch.

      Third, The sender and receiver NEED TO HAVE the exact same parameters, ie, BW, etc defined for both unit’s sketches.

      Forth, If you are wanting to set the BW at 62.5 KHz I would do it as: #define BW 62500 Then later in your sketch ( I did it at in the void setup() { )
      using the statement LoRa.setSignalBandwidth(BW);

      Please note that the LoRa.h library requires statements like LoRa.setxxxxxxxxxx(xx); to be used if you intend to modify the modulation parameters beyond the defaults. I have played with many of these modulation parameters and found them all working as expected.

      Hope this helps…

      Regards,
      Bob Rader

      Reply
  15. I’m also seeing the sender failing with the “Starting LoRa failed!” message. (TTGO LoRa OLED version 1 module.

    I have other code that uses this radio, and it has also stopped working when I rebuild it with the current ESP-IDF / arduino-esp32 environment. I’ve traced it to the low-level SPI communication with the radio chip failing. I wonder if something in the development environment has changed recently?

    Can anyone who has this working with a current build please post the versions of the tools you’re using? Thanks.

    Reply
    • Hi.
      Are you sure that your board is the same as ours?
      If you have a slightly different board, it may use different pins to connect to the LoRa chip. So, if you don’t initialize SPI properly on the right pins, it won’t be able to initialize LoRa.
      Make sure you define the right pins on the next lines:
      //define the pins used by the LoRa transceiver module
      #define SCK 5
      #define MISO 19
      #define MOSI 27
      #define SS 18
      #define RST 14
      #define DIO0 26

      Regards,
      Sara

      Reply
  16. Hi everyone,

    I m trying to use TTGO LoRa 32 OLED V1 and NodeMCU (ESP-12E) modules for my work. I want to send data via UART, from ESP-12E to TTGO LoRa module. However I am unable to implement the receive part on the TTGO LoRa module.

    Can someone suggest how this can be done?

    Thanks in advance,

    -Chandrasekhar DVS

    Reply
    • Hi.
      Basically, you need to instantiate an hardware serial communication – this uses GPIO 17(TX) and GPIO 16 (RX):
      HardwareSerial ss(2);

      in the setup():
      ss.begin(115200); //or change for another baud rate
      Serial.begin(115200); //Serial monitor

      than, to read the information:

      if (ss.available() > 0) {
      // read the incoming byte:
      incomingByte = ss.read();

      // say what you got:
      Serial.print(“I received: “);
      Serial.println(incomingByte, DEC);
      }
      }

      As shown in this example: https://www.arduino.cc/reference/en/language/functions/communication/serial/read/
      I hope this helps.

      Regards,
      Sara

      Reply
      • Hi Sara,

        Thanks for the quick response, I think the default 16 and 17 pins weren’t working right on my board. Referring to the code snippet of yours and some others, I was able to solve the problem. Also I remapped the UART pins. Following is the code snippet I used.

        HardwareSerial ss(2);

        #define RXD2 23
        #define TXD2 18

        String inputString = “”;
        char inChar;

        void setup() {
        // put your setup code here, to run once:
        Serial.begin(9600);
        ss.begin(9600,SERIAL_8N1, RXD2, TXD2);

        inputString.reserve(50);
        }

        void loop() {
        while(ss.available()>0)
        {
        inChar = (char)ss.read();
        inputString+=inChar;

        if(inChar == ‘!’)
        {
        Serial.println(inputString);
        inputString = “”;
        }
        }
        }

        Thanks for your reply.

        -Chandrasekhar DVS

        Reply
        • Hi again.
          I’m glad it is working 😀
          Thanks for sharing your solution. It might be helpful for others.
          Regards,
          Sara

          Reply
  17. Hi, thank you for this great tutorial. At first I didn’t see anything on the oled screen. I did not have any errors during uploading the sketch. In Serial monitor I could see the packets being send so it must be the oled pinout. It turns out that with the TTGO LoRa V2.1_1.6, oled SDA = 21 and oled SCL = 22. after changing that it works great!

    Reply
    • Great!
      You should always look at your board pinout, so that you have the right pin assignment on the code.
      Regards,
      Sara

      Reply
  18. Hi Sara, great ‘TTGO LoRa32 SX1276 OLED’ tutorial.
    I’m working with your code on a TTGO LoRa 32 OLED V1, but I didn’t see anything on the oled screen (like ‘ulco’ said), …any idea?, could you share a sketch/code in order to check only the oled screen?
    I suspect that my oled is damaged becouse the code uploaled is the exactaly same as yours in this tutorial.

    Thanks so much in advance !!

    Reply
    • Hi.
      To test the OLED, you can use the code in this tutorial: https://randomnerdtutorials.com/esp32-built-in-oled-ssd1306/
      But change the following line with the pins used by the OLED in your board:
      So, instead of
      Wire.begin(5, 4);

      You should have
      Wire.begin(4, 15);

      You also need to add the following lines right after the setup()
      pinMode(OLED_RST, OUTPUT);
      digitalWrite(16, LOW);
      delay(20);
      digitalWrite(16, HIGH);

      I hope this helps.
      Regards,
      Sara

      Reply
  19. Hello Sara,
    thank you very much for this excellent tutorial. I am a new user of the Arduino platform, the LoRa protocol has also fascinated me a lot. I’m trying to get my 11-year-old son Gabriel interested. By doing various searches on several sites to find out about LoRa I landed here. I was wondering if you were going to do some tutorials also on LoRaWan, because the literature on the web is very poor and I think the need to be able to read multiple sensors in different positions becomes more and more interesting. Alternatively if you can recommend me some tutorials on LoRaWan and how to connect the same sensors as your tutorial.
    Thanks
    Tiziano

    Reply
    • Hi.
      Thank you for following our work.
      Yes, I intend to do some tutorials about LoraWan and connecting the board to The Things Network (TTN).
      However, I don’t think I’ll be doing it soon. I have other projects on the “waiting list”.
      One of our followers built a very interesting project in which he connects the ESP32 to TTN.
      Here’s a link for his project: https://marcoroda.com/2020/04/12/TTGO-LORA-TTN.html
      I hope this is helpful.
      Regards,
      Sara

      Reply
  20. Hi Sara and team,
    I completed this project and it worked very well. Thanks for all the work you have done.
    However, I hooked up a accelerometer (MPU6050) using the I2C bus (Using the default pins 21, 22) . The MPU6050 works okay on its own but when I integrate the code into the sketch with the Lora/Oled I get a debug or exception error on the monitor.

    If I comment out the following lines from the setup , the 6050 works okay. Any ideas you may have which could help me in this regard ? I am trying to have the Accel/Gyro data transmitted via LOra.

    Thanks,
    Carl

    //reset OLED display via software
    pinMode(OLED_RST, OUTPUT);
    digitalWrite(OLED_RST, LOW);
    delay(20);
    digitalWrite(OLED_RST, HIGH);

    //initialize OLED
    Wire.begin(OLED_SDA, OLED_SCL);
    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128×32
    Serial.println(F(“SSD1306 allocation failed”));
    for(;;); // Don’t proceed, loop forever
    }

    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setTextSize(1);
    display.setCursor(0,0);
    display.print(“LORA SENDER “);
    display.display();

    //SPI LoRa pins

    SPI.begin(SCK, MISO, MOSI, SS);
    //setup LoRa transceiver module
    LoRa.setPins(SS, RST, DIO0);

    if (!LoRa.begin(BAND)) {
    Serial.println(“Starting LoRa failed!”);
    while (1);
    }
    Serial.println(“LoRa Initializing OK!”);
    display.setCursor(0,10);
    display.print(“LoRa Initializing OK!”);
    display.display();
    delay(2000);

    Reply
      • Thanks for your prompt response. I am trying to figure out the I2C communications but in the meantime I disconnected the 6050 and did a I2C port scan and it did not show the integrated OLED device. It is not faulty because it works with test sketches.

        Could you explain the reason why this device does not show up on the port scan ? Btw, when I reconnect the 6050, it’s I2C address shows up with the scan.

        Reply
  21. Hello and thanks for this article!

    I have some questions about this kind ob ESP32 and LoRa board:
    – is it possible to set the ESP & LoRa module to sleep and only wake up the ESP at some kind of intervall for some measuring and then activate the LoRa module if the value changed (for example the temperature) to send the data?
    – what is the current consumption of the whole board when all components are active or in sleep mode?
    – is it possible with the LoRaWAN protocoll on this chip to use the adaptive data rate, for example automatically to change the spreading factor if the end devices moves far away?

    Last question is, why does all the LoRa chips on the market use the older Semtech SX127x and not the newer SX126x versions?

    Reply
  22. Many thanks for a great tutorial! I tested it and made it work directly with my new devices. Unfortunately, I can no longer load new code, not on any of the devices. Would be very happy if you could help me 🙂

    : fatal error: when writing output to preproc\ctags_target_for_gcc_minus_e.cpp: No space left on device
    compilation terminated.
    exit status 1
    Error compiling for board TTGO LoRa32-OLED V1.

    Thanks!
    Joakim

    Reply
  23. hi
    thanks for the tuto
    im just wondering if there is any similar board based on lora that can send data in a range of 10km? if so please tell me
    thank you in advance!

    Reply
    • Hi.
      I’m not sure. I depends on the board antenna, several configuration parameters and also on the environment – on open field the range is better.
      But, I don’t think that you’ll find an ESP32 lora board with 10Km range.
      Regards,
      Sara

      Reply
      • hi
        thanks for the fast reply!
        what board can reach the highest range? what about lora module alone? 10km is just an example
        do you have any tuto or somthing that can help me sending data for long ranges? since im new in this domain
        Regards,

        Reply
  24. Dear Rui, dear Sara.
    Your work with tutorials is impressive and very helpful, I am thrilled.
    I am new to programming but have learned a lot from your and other tutorials. Thank you.
    I once dared to load your sketch from the TTGO LoRa transmitter and receiver onto my ESP’s. The transmitted data is displayed in the serial monitor, my sensor is also output correctly, but in both cases, be it receiver or transmitter, the display does not light up, it is simply black, I then indicate that it has to do with an OLED library, me I tried several without success, I put a display test program on it with the library, and the display works perfectly.
    I use TTGO, T3, V1.6 as a transmitter and
    TTGO T-Beam LiLYGO as a receiver.
    I thank you in advance for your valuable support.
    Sincerely yours,
    Forrer

    Reply
    • Hi.
      Your boards might have a different pinout than ours.
      You need to search for the pinout of your board and see which pins are being used to connect to the OLED.
      Then, modify the following lines to include the right pins.
      //OLED pins
      #define OLED_SDA 4
      #define OLED_SCL 15
      #define OLED_RST 16
      I hope this helps.
      Regards,
      Sara

      Reply
    • Halo Rui
      Thank you very much for your valuable support, I have solved the problem with the display, because it had to be something similar with both ESP32s. With your help, I found out that the OLED pins did not align, my boards do not have to:
      / OLED pins
      #define OLED_SDA 4
      #define OLED_SCL 15
      #define OLED_RST 16
      #define SCREEN_WIDTH 128 // OLED display width, in pixels
      #define SCREEN_HEIGHT 64 // OLED display height, in pixels
      rather:
      // OLED pins
      #define OLED_SDA 21
      #define OLED_SCL 22
      #define OLED_RST 4
      #define SCREEN_WIDTH 128 // OLED display width, in pixels
      #define SCREEN_HEIGHT 64 // OLED display height, in pixels

      Reply
  25. Hi, great tutorial.

    I seem to have an issue with the code as copied from the webpage. The sender works for ever and a day, the reciever however stops displaying the recived packet count after a while of running.
    I swapped the code out on both my units to make sure it wasnt the hardware that was at fault.
    Any ideas or anyone else seen this?

    Reply
    • Hi Scot
      I also encounter similar issue with this Esp lora chip as I used it for periodic temperature transmission. After a random number of pool the transmission drops. The only workaround I found was to put the Esp in sleep mode between pools…
      Alain

      Reply
  26. Thank you so much for this tutorial. I really appreciate the clear explanations for each part of the code. Very well done: I had my boards talking to each other within 15 minutes.

    I have struggled with other LoRa board approaches, mostly because they want to jump to LoRaWAN implementation, which is much more complicated. This is just what I needed for my local control and monitoring needs.

    Reply
  27. Bonjour. J’ai pour projet de réaliser un site web capable de récupérer les informations d’un robot que des collègues programment. Je dois également utiliser une carte Wifi et GPS pour communiquer avec le robot et envoyer l’information de sa position sur l’interface Web. Pensez-vous cela réalisable avec cette carte (TTGO LoRa32). Merci d’avance de votre réponse.

    Reply
  28. Hallo,

    Thanks for this shared information.
    I do have a couple of questions… :
    – can I receive the sender information on my TTN gateway ?
    – how does the indentification between sender and receiver works, is there a handshake ?
    – where can iI find other projects like this, like them very much !!!

    regards,

    Bert.

    Reply
  29. Hi Sara and team
    i got issue on my ttgo Lora32 oled v2 board.

    it show like this.
    esptool.py v2.6
    Serial port COM5
    Connecting…….._____….._____….._____….._____….._____….._____…..____An error occurred while uploading the sketch
    _

    A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

    the detail of the board: https://github.com/LilyGO/TTGO-LORA32

    Before that i can upload code normally. After several test, i got that issue.
    do you guys have any solution regarding this issue?

    Reply
    • Hi.
      Press the on-board RST button when you start seeing the dots.
      Additionally, disconnect any peripherals when uploading the code.
      Regards,
      Sara

      Reply
  30. Hi Sara.
    Both of my OLED display are in good condition.
    As for my project, this tutorial works except for the OLED display.
    In the Serial Monitor in arduino, I can see that the packets are being sent and received perfectly, its just that both of my OLED display didn’t show the details (ie, RSSI, packets sent, received packets, counter etc) mentioned in the coding.
    Kind regards,
    Izzy

    Reply
    • Hi.
      Are you sure your board is the same as ours?
      If it is a different version, it may use different OLED pins. So, the OLED won’t work if you don’t change the pins on the code.
      Regards,
      Sara

      Reply
  31. As always, well explained!
    Small hint: the lines for initializing the serial monitor belong before the OLED initialization, otherwise no error message is displayed.

    Reply
  32. TTGO-LoRa V2.1.6 uses pin 21 for SDA and pin 22 for SCL

    //OLED pins
    #define OLED_SDA 21 // was 4!
    #define OLED_SCL 22 // was 15!

    =================

    //reset OLED display via software
    pinMode(OLED_RST, OUTPUT);
    digitalWrite(OLED_RST, LOW);
    delay(20);
    digitalWrite(OLED_RST, HIGH);

    Is not necessary, because Adafruit does the same if the 4th parameter is not equal to -1 and equal to OLED_RST.

    Reply
      • Estimados Sara y Rui,

        Necesito de su ayuda para implementar un gateway Lora por medio de placas, tengo un nodo Lora que transmite datos en ISM 915Mhz con la placa TTGO LoRa32 SX1276 OLED pro no se como configurar este nodo a modo gateway. Tambien cueto con la placa SPARKFUN SAMD21PRO RF , por favor me podria guiar cual de estas placas es la optima para implementar un gateway lora considerando que resulte un gateway eficiente y robusto en consideracion de las placas que tengo a disposicion o que placa me recomienda para la implementacion.

        Saludos cordiales.

        Reply
  33. Dear Sara and Rui,

    I need your help to implement a Lora gateway through boards, I have a Lora node that transmits data in ISM 915Mhz with the TTGO LoRa32 SX1276 OLED pro board, I don’t know how to configure this node as gateway. I also have the SPARKFUN SAMD21PRO RF board, please could you guide me which of these boards is the optimal one to implement a lora gateway considering that it is an efficient and robust gateway considering the boards that I have available or which board you recommend for the implementation.

    Kind regards.

    Reply
  34. Hi Sara,

    A very interesting project. I have compiled the codes, but produced this error. Appreciate your advice. thanks.

    Arduino: 1.8.5 (Windows 10), Board: “TTGO LoRa32-OLED V1, 80MHz, 921600, None”

    C:\Users\kzaman\Documents\Arduino\testLORA\testLORA.ino:13:30: fatal error: Adafruit_SSD1306.h: No such file or directory

    compilation terminated.

    exit status 1
    Error compiling for board TTGO LoRa32-OLED V1.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    Reply
    • Hi.
      That means that you don’t have the Adafruit SSD1306 library installed.
      In your Arduino IDE, go to Sketch > Library > Manage Libraries and search for ssd1306. Install the library by Adafruit.
      Regards,
      Sara

      Reply
  35. Hi, I am trying to use this boards as a transmiter receiver of correction data for the GNSS base.
    The RTCM data is about 2KB and the transmition will be done in 9.2KB/s.
    I am quite new to Arduino IDE but can you tell me what would be the best code for this kind of project?
    I think in Lora module the Air Rate speed can be configure, but I do not know if that is possible.

    Reply
  36. Hi,

    What would be the code to send/receive UART data of the base GNSS correction via the Lora.
    The packets are send every second and are about 2KB.
    Is there a option to change Air data rate for Lora ?

    Reply
  37. Hello, i have ttgo lora esp32. The problem is i cant upload the code because eror wait packet header, i’ve already read another article abaout that but in this case there isnt the boot button on v1.6, what should i do?

    Reply
  38. hello everybody,
    I am playing around with two ttgo lora sx1276 esp32 modules that one sends and the other receives characters. They are on
    #define BAND 868E6
    They do it successfully. However, for time to time, the receiver receives a packet of characters that includes seemingly garbage or not readable characters. Here are some examples:

    01.07.2021 11:29:28 Home/Lora/inbound WEMOS Receiver Received:[▒TJ▒A▒▒z▒y!▒#▒[ )h▒>0▒▒7D(▒▒&9▒$▒▒”▒”▒%▒▒F▒j▒.▒▒▒▒▒▒n▒▒m▒▒▒
    X▒▒^▒▒] with RSSI -120

    01.07.2021 13:52:19 Home/Lora/inbound WEMOS Receiver Received:[▒▒&}▒▒[▒&l}▒▒▒▒M1g̓▒ C▒}▒▒^▒▒D<▒Q.=
    01.07.2021 13:52:19 uX] with RSSI -119
    01.07.2021 14:51:53 Home/Lora/inbound WEMOS Receiver Received:[т▒8▒;;
    ▒n
    Y0̈́p>▒&▒▒▒▒W
    01.07.2021 14:51:54 ▒,▒F▒▒▒▒▒▒
    I▒u▒▒=▒▒4D1*▒يθ▒▒▒;!-v▒▒

    I guess this could be a parasite or some interference from the environment(?). Or could it be some lora emission (?) How can i go around and decode/decrypt this or search its origin?

    Reply
  39. Hi Rui and Sara

    I was trying to use the TTGO info for these boards to setup a lora tx and rx and what a total failure. TTGO need to fix their poor information for their weird and wonderful series of boards. Then I thought to search RNT. Job done.

    Keep up the great work

    Reply
  40. Hi Rui and Sara
    can I assume that RTC Pins on Esp32 wroom and ADC pins on TTGO LoRa32 SX1276 OLED are the same regarding wakeup pins

    Regards
    Aage

    Reply
  41. Hi Sara, thanks for a great tutorial which has been a valuable resource for me as a newbie to these boards.

    I am having some signal strength issues however – any ideas would gratefully received.

    I am in Glasgow, Scotland, using the 868E6 (I’ve also tried 868E6) band and ~ 200mm antennae (https://www.ebay.co.uk/itm/274640551855). I am sending simple single integer messages from one board to another, and it is repeating the message back to the first board. The best range I can get without failures is 100m through buildings and 200mm in line of sight. I was expecting much larger ranges

    Is this range reasonable for LoRa?
    What steps if any can I take to improve it?

    Reply
  42. hi sara
    i have a problem in my project with lora
    when i send a message from emitter to receiver it work good
    but when i communicated the emiiter to arduino to receive data from it
    i can see the data in the emiiter but it doesnt show anything in the receiver

    Reply
  43. Hi Rui and Sara. I have purchased few copies of your and have trying to program TTGO lora esp32 oled based on your tutorial. Successfully uploaded but got error Lora starting failed. I have read your comment in the tutorial page where you suggested to change the pin number for specific module. I have realised that my lora module is slightly different from yours. Ours has a imprinted antenna on pcb. I suspected it has different pin assignment. I tried to search on internet the pin out of my module, but unsuccessful. I am seeking your your help if you know the type or the pinout of our module. Thanks in advance.

    Reply
  44. Hi Sara,

    Bob Rader did shared his code which makes it possible to play with RF and SF etc… You asked him to use pastebin. Unfortunately the pastebin links don’t work.
    I think his code will be very helpful for many. Did you safe his code by any chance somewhere?

    That would be great.
    And thanks. I really appreciate you detailed and easily understandable script-kiddy-friendly tutorials. Perfect for me 🙂

    Reply
  45. Hi Sara!

    In some other example i found, they used the “SSD1306Wire.h” library instead of the adafruit-made ones, is there any major difference between them OLED libraries? thanks!

    Reply
    • Hi.
      I don’t know. I never tried that library.
      But, different libraries, usually have different methods. So, the code will be different.
      Regards,
      Sara

      Reply
  46. Is there a current link for the MakerFocus TTGO LoRa32 SX1276 with ESP32 and SSD1306 OLED on Amazon US?
    The current US Amazon link I’m seeing only shows the MakerFocus TTGO LoRa32 SX1276 with ESP32 and SSD1306 OLED without the antennae. If I’m spending money on two units, I want to ensure you get your commission.

    Reply
  47. The red LED is sometimes flashing, sometimes solid, and sometimes off. I’ve tried to correlate this with having the battery connected when the USB is also connected. No clue. What are these modes telling me?

    Reply
  48. Has anyone implemented, or aware of, any library that either enforces our at least allows monitoring of the duty cycle / airtime?
    I am using the 868 modules and there are restrictions on the ISM use.
    I don’t see anything natively in the radio to ensure compliance to these restrictions?

    Reply
    • Hi.
      Why would you want to add another LoRa module to a board that already comes with a LoRa module?
      It should be possible as long as you use different pins for that module you want to use.
      Regards,
      Sara

      Reply
  49. Is there a way to get battery levels from this board? I’m connecting an 18650 battery shield to the battery connector on the back of the board but I cannot find any way to read the voltage from this connector – is this even possible? In some of your responses you mention sending battery levels but I’ve seen no examples of how this is done. I’ve got the almost perfect setup for this device for a remote temperature sensor but I need a way for the device to tell me the battery level so I can change the battery if required.

    Reply
  50. This is a very great project.
    Does anyone know if thee OLED can be turned off/on with a button in coding?
    I have these module in a boc with a clear cover which I want to integrate a REED switch to put the OLED on or off when needed.

    Reply
  51. Sarah, this code works fine on the TTGO LoRa32 board. I’d like to add the MPU6050 gyro, which is also I2C, but when I attach it to pins 4 (SDA) and 15 (SCL), it kills the display. I’ve tried using TwoWire() to compile a second wire() routine to use the default pins 21/22, but I find I don’t quite understand how to make that work. Do you have an example code that allows an additional I2C device to work on the TTGO board?

    Reply
  52. Sara, this board is no longer available. The new LILYGO V2.1_1.6 looks very similar, but the schematics show some conflicts. First, the OLED no longer has a discrete reset pin assignment, it’s just connected to the hardware/switch reset so the OLED_RST variable can’t be assigned. What happens to this line of code? Does the library require a pin number for reset? If not, how does display.clearDisplay() work?

    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

    SDA and SCL revert back to the normal Arduino default I/O pins 21 and 22, no biggee.
    The LoRa reset changes from pin 14 to 23, also no biggee.

    Reply
      • This is how I defined my pins for the V1 and V2 versions:

        //define the pins used by the LoRa transceiver module
        #define SCK 5 // 5
        #define MISO 19 // 19
        #define MOSI 27 // 27
        #define SEL 18 // 18
        #ifdef V2
        #define RST 23
        #else
        #define RST 14 // 23 !! Conflict !! for V2.1
        #endif
        #define DIO0 26 // 26

        #define BAND 915E6 //915E6 for North America

        //OLED pins
        #ifdef V2
        #define OLED_SDA 21
        #define OLED_SCL 22
        #define OLED_RST -1 // Per randomnerd (Sara)
        #else
        #define OLED_SDA 4 // 21 conflict for V2.1
        #define OLED_SCL 15 // 22 conflict for V2.1
        #define OLED_RST 16 // DNE, conflict for V2.1
        #endif

        Reply
  53. Thanks, Sara, no compile errors and code uploads and works.

    The V2 OLED board has some mechanical improvements and the addition of the SD card slot may help some Makers, but the I/O capability compared the the V1 is very limited. So far there’s not a lot of example sketches (like how to use the S_VN and S_VP pins) and whether there are limitations on the SD card pins for external I/O.

    Reply
  54. Hi all,
    I’m currently trying to use “digitalPinToInterrupt” command to do an interrupt request by pressing a pushbutton.
    I cannot find which pin of the TTGO LoRa32 V1.0 can be used as an external IRQ pin.
    Can someone help me please ? Thanks!

    Reply
  55. Hi.
    Thanks for the excellent tutorial and information.

    Looking at the example code you seem to specify the EU frequency as 866MHz.
    Should this not be 868MHZ ?
    I noticed when other devices weren’t receiving packets from the sample sender.
    Changing to 868MHz fixed it.
    —8<———-8<—-
    //433E6 for Asia
    //866E6 for Europe
    //915E6 for North America
    #define BAND 866E6
    —8<———-8<——

    Reply
  56. Great Tutorial ! Great site and superb response / feedback.
    I received a pair of these … and neither can be detected by USB (linux: lsusb) – so I cannot upload from Arduino IDE. My cables are fine for programming ( setup will work with other TTGO OLED dev boards), and the factory default ‘Wifi Scanning’ is visible on the OLED – so it was not completely DOA. Any suggestions – before I trash these and start over ? flash the bootloader?

    Reply
  57. Sara,

    I am using this chip (Version 1) with OLED and LoRa (not wi-fi). Pins 32 and 33 cannot be used as inputs once LoRa begins. They are high impedence (if you set the pinMode to INPUT) until the code gets to the point of starting LoRa. Then they both go into output mode, set at LOW. You don’t mention any special restriction on these pins in this article, or in your ESP32 Pinout Reference article. Is there some kind of port-wide command in the LoRa library that changes a whole port’s pinmode and changes these two by mistake? Is there a work-around for this? Setting the pinmode to INPUT after the LoRa.begin command doesn’t fix the problem, but LoRa still works.

    Reply
    • Note: V2 of this chip (Lilygo ESP32 OLED LoRa with the attached antenna fitting) has fewer GPIO pins, 26 versus 36 for V1. GPI32 and GPI33 are not available on V2.

      Reply
  58. Hello There,

    Awesome Article, but still in dilema, how does the receiving device knows whose data it should receive, since there are many other devices whose data is getting transmitter at same frequency. I don’t see any UNIQUE IDENTIFIER has been used in the code to identify the transmitting device data.

    Regards,
    Sai

    Reply
  59. Hello. I tested this tutorial and it works perfectly. Great.

    Is it possible to obtain an acknowledgement of receipt from the sender? I need to be sure the receiver received a message.

    Thanks !

    Reply
  60. Hi Everyone,
    I recently had problems with the callback examples causing a wdt (watchdog timer) crash. This was caused by the interrupt handler or callback function taking too much time. This can be very simply resolved. Please forgive the poor example. It is here for clarity only:
    Create a global int _packetCount. In the interrupt handler/callback function. Remove all the other code and assign the packetCount to this _packetCount. In the main loop check for _packetCount being greater than 0. If it is call a function to manipulate the incoming data and set _packetCount to 0.
    Hope this helps and saves you some time :).
    Shaun

    Reply
  61. Hey Sara! thanks for this tutorial.

    Could you please help me, I have a project, I have a TTGO LoRa32 SX1276 OLED and I need to transmit motion, sound and light alarms. Do you know how the code can be?

    Reply
  62. Hello Sara,

    I’m using TTGO T-BEAM v1.2 boards for Lora project. I need to calculate RSSI and SNR values. So I tried the code same like the tutorial with some pin changes for OLED. I am unable to get the RSSI values in the end as a result.

    Reply
  63. Hello Sara,

    fantastic tutorial, thank yo. Strange, I posted a comment – and some questions – here last week but it never appeared in this listing. Are you still reading these postings? I would appreciate if you do because I have some question that I would like to ask you related this topic. Looking forward to your response – thank you, kind regards, Berx

    Reply
    • Hi.
      We try to read all the comments. But with so many blog posts, it’s difficult to keep up and respond to all of them.
      I’m sorry if I didn’t see your question.
      Regards,
      Sara

      Reply
  64. Hi Sara,
    is there no way to transmit a struct straight foward without make it so complicatet with the conversation to strings and than back.
    Regards
    Uwe

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.