# LoRa getting stuck on LoRa.endPacket(); Does not transmit

**URL:** <https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647>\
**Category:** Sensors\
**Created:** [February 23, 2024, 4:30pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647 "2024-02-23T16:30:06Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 4:30pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/1 "2024-02-23T16:30:06Z")

</div>

Hi! I have recently gotten into an issue where I have attempted to add LoRa communication to my project. When on its own, the LoRa works, but when combined with an SD, BMP280, and Adafruit ultimate breakout GPS, it seems to stop working. I am using a LoRa SX1278 with the LoRa library. I am using an Arduino Uno, and the wiring of the LoRa is shared with the SD card(except for the chip select). What can I do?

Full sketch(I currently don't have the Arduino setup on hand so I can't remember the exact wiring):

```arduino
//BME
#include <avr/pgmspace.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
//GPS
#include <TinyGPS.h>
#include <SoftwareSerial.h>
//SD
#include <SdFat.h>
//LoRa
#include <LoRa.h>

//LoRa
unsigned long dF = 433E6;

 

//SD
SdFat sd;

SdFile file;

const int LoRachipSelect = 4;
const int SDchipSelect = 10;

//BME
Adafruit_BMP280 bmp;

//BMP
SoftwareSerial ss(8,7); //MAYBE IT CANT GET THE PINS CAUSE OF IT BEING PROGMEM(CHECK THAT)
TinyGPS gps;

uint32_t timer = millis();
int temperature, pressure, altitude;

void setup()
{
   Serial.begin(115200);
   ss.begin(9600);  
   
  //BMP
  if (!bmp.begin(0x76)) {
   
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    //while (1);
  }
  Serial.println(F("BMP280 started"));
  //SD
  if (!sd.begin(SDchipSelect)) sd.initErrorHalt();

   //LoRa
 
Serial.println(F("Before LoRa initialization"));
  //Start Lora
  LoRa.setPins(LoRachipSelect);
  delay(10);
    if (!LoRa.begin(dF)) {
    Serial.println(F("Starting LoRa failed!"));
    while (1);
   }
   
 

 
  LoRa.setTxPower(14); // Set the transmit power (from 2 to 17)
//GPS

}
void loop()
{
  //GPS variables
  bool newData = false; //Checks for new data
  unsigned long chars; //Find chars
  unsigned short sentences, failed;

 
 

  Serial.print(F("Temp:"));
  Serial.print(bmp.readTemperature(), 2);
  Serial.print(F(" Press:"));
  Serial.print(bmp.readPressure() / 100, 2);
  Serial.print(F(" Alt:"));
  Serial.println(bmp.readAltitude(1013.25), 2);
  if (!file.open("PMData.txt")) {
    sd.errorHalt(F("opening PMData.txt for write failed"));
   
  } else
  {
    //Chekcs time
    for (unsigned long start = millis(); millis() - start < 1000;)
    {
      while (ss.available()) // Hopefully this is not an endless loop
      {
       
       
        char c = ss.read();
       
        if (gps.encode(c))
        {
          newData = true;
        }
         
      }
    }
    //If there is a fix/new data coming in.
    if (newData)
    {
     
      float flat, flon;
      unsigned long age;
       
      gps.f_get_position(&flat, &flon, &age);
      Serial.print(F("LAT="));
      Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
      Serial.print(F(" LON="));
      Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
      Serial.print(F(" SAT="));
      Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
      Serial.print(F(" PREC="));
      Serial.println(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());

      //File
      file.print(F("Temp:"));
      file.print(bmp.readTemperature(), 2);
      file.print(F(" Press:"));
      file.print(bmp.readPressure() / 100, 2);
      file.print(F(" Alt:"));
      file.println(bmp.readAltitude(1013.25), 2);
      file.print(F("LAT="));
      file.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
      file.print(F("LON="));
      file.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
      //LORA
     
      Serial.println("Saved to file");
      LoRa.beginPacket();
      LoRa.print(F("Temp"));
      LoRa.print(bmp.readTemperature(), 2);
      LoRa.print(F(" Press:"));
      LoRa.print(bmp.readPressure() / 100, 2);
      LoRa.print(F(" Alt:"));
      LoRa.println(bmp.readAltitude(1013.25), 2);
      LoRa.print(F("LAT="));
      LoRa.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
      LoRa.print(F("LON="));
      LoRa.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
      Serial.println("Lora should end");
      LoRa.endPacket();
     
     
     
    }
    else
    {
      file.print(F("Temp:"));
      file.print(bmp.readTemperature(), 2);
      file.print(F(" Press:"));
      file.print(bmp.readPressure() / 100, 2);
      file.print(F(" Alt:"));
      file.println(bmp.readAltitude(1013.25), 2);
    LoRa.beginPacket();
      LoRa.print(F("Temp"));
      LoRa.print(bmp.readTemperature(), 2);
      LoRa.print(F(" Press:"));
      LoRa.print(bmp.readPressure() / 100, 2);
      LoRa.print(F(" Alt:"));
      LoRa.println(bmp.readAltitude(1013.25), 2);
      LoRa.write("Hi");
      delay(100);
    LoRa.endPacket();

      Serial.println(F("NoGPSData-NoFix"));
      file.println(F("NoGPSData-NoFix"));
    }

   

    file.close();

  }
  tone(9, 1000, 250);
 
 
  delay(1000);
 

}

```

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [February 23, 2024, 4:43pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/2 "2024-02-23T16:43:13Z")

</div>

You are likely to be running out of dynamic memory, in which case the fix is to move to an MCU with more memory, or lower the project requirements.

There may also be a conflict with the SD card module and other devices on the SPI bus. A hardware fix has been discussed on this forum. See this post for an example [SPI MISO pin conflict](https://forum.arduino.cc/t/spi-miso-pin-conflict/1191856)

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 4:50pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/3 "2024-02-23T16:50:56Z")

</div>

Would reassigning the pins for either the SD card or the LoRa solve the possible conflict? Also, the SD card does not record any data either.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:02pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/4 "2024-02-23T17:02:51Z")

</div>

Also, if I let the LoRa endpacket() run asynchronously, it doesn't freeze the code, and has only once transmitted a message.

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:05pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/5 "2024-02-23T17:05:01Z")

</div>

> [@shadycrisp](#):
>
> Would reassigning the pins for either the SD card or the LoRa solve the possible conflict?

Depends on the SD card adapter you are using.

The standard one that people use on UNOs only allows one device to work on the SPI bus as suggested by @anon94801460.

Show us a picture\link of your SD card holder.

And what LoRa module are you using and how is it wired ?

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:13pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/6 "2024-02-23T17:13:31Z")

</div>

The sd card holder is: [https://grobotronics.com/adafruit-microsd-card-breakout-board.html?sl=en](https://grobotronics.com/adafruit-microsd-card-breakout-board.html?sl=en)  
The LoRa is the SX1278, LoRa Ra-02. The wiring is  
SCK - 13 (shared with SD)  
MISO - 12 (shared with SD)  
MOSI - 11 (shared with SD)  
NSS/CS - 4  
DIO0 - 2  
(for the LoRa)

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:19pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/7 "2024-02-23T17:19:13Z")

</div>

Dont have any experience of that SD card module.

However LoRa and SD cards, properly designed, should work together. I have a handheld LoRa packet logger with OLED display and SD card, running and working on a Pro Mini on my desk.

And which LoRa module are you using !

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:21pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/8 "2024-02-23T17:21:35Z")

</div>

It's the one I mentioned above. Here is the link I got it from: [https://grobotronics.com/lora-module-433mhz-sx1278.html](https://grobotronics.com/lora-module-433mhz-sx1278.html)

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:25pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/9 "2024-02-23T17:25:32Z")

</div>

Apologies I missed that.

That is a 3.3V logic level LoRa module, and needs logic level conversion circuits to connect it to a 5V logic level Arduino UNO.

Connect that module direct to a UNO and it could be damadged.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:28pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/10 "2024-02-23T17:28:44Z")

</div>

The LoRa module has been working on its own with an Uno before, and I have been using the 3.3V port on the Arduino. How would I convert to 3.3V?

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:33pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/11 "2024-02-23T17:33:12Z")

</div>

Maybe it has worked before, but that does not mean its OK to connect it direct. Besides you now have a problem, so something is wrong ?

A google search on;

Arduino logic level conversion

Should find you lots of examples.

Myself, I would not use a LoRa module on a 5V Arduino, far less bother to just update to 3.3V logic Arduinos.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:38pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/12 "2024-02-23T17:38:48Z")

</div>

Thanks! I found a few tutorials on the logic conversion. I really appreciate the help!

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:44pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/13 "2024-02-23T17:44:57Z")

</div>

Oh, and another thing.

A UNO probably canoot provide enough current on its 3.3V pin to power a LoRa transmitter. Another good reason to use 3.3V logic Arduinos.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:45pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/14 "2024-02-23T17:45:41Z")

</div>

How come? In the future this logic will all be taken to a nano every, which still uses 5v.

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 5:50pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/15 "2024-02-23T17:50:09Z")

</div>

What do you mean how come ?

As I recall some of the 5V logic Arduinos can only provide circa 50mA on the 3.3V pin, which is not really enough for a LoRa transmitter.

The Nano Every is also specified as only providing 50mA on the 3.3V pin, read the docs.

Switch to a 3.3V Arduino, much easier.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 5:56pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/16 "2024-02-23T17:56:21Z")

</div>

I searched through google a little bit and I saw that the uno can provide 100 to 150mA of current on the 3.3v pin, but you are right about the every.

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [February 23, 2024, 6:00pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/17 "2024-02-23T18:00:24Z")

</div>

Arduino UNO R3 specs says 3.3V pin is limited to 50mA.

> **[Arduino Uno Rev3](https://store.arduino.cc/products/arduino-uno-rev3)**
>
> Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an...

But maybe its wrong.

---

<div class="post-metadata">

**Author:** ![shadycrisp](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shadycrisp](https://forum.arduino.cc/u/shadycrisp)\
**Post date:** [February 23, 2024, 6:05pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/18 "2024-02-23T18:05:28Z")

</div>

My bad. I dont see why it would be wrong lol. The LoRa needs more than that though? How come it used to work?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 21, 2024, 6:06pm UTC](https://forum.arduino.cc/t/lora-getting-stuck-on-lora-endpacket-does-not-transmit/1227647/19 "2024-08-21T18:06:15Z")

</div>

Closed on August 21, 2024, 6:06pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
