logo elektroda
logo elektroda
X
logo elektroda

Arduino, ESP32, XL1278 - How to run a LoRa module using RadioLib and GPIO connections?

Adix3 2601 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20407601
    Adix3
    Level 13  
    Hi. I have a board with an ESP32 processor to which I have connected an XL1278 (LoRa) module. I made the connection between the modules on 7 wires: 3V3, GND, MISO, MOSI, SCLK, RST, NSS. I installed the RadioLib library for Arduino, which I found in the library manager in Arduino. Still about the connection itself I connected the MISO, MOSI, SCLK pins of XL1278 module to corresponding pins of ESP32 board like this:

    MOSI -> GPIO23
    MISO -> GPIO19
    SCLK -> GPIO18


    I connected the NSS and RST signals like this:

    NSS -> GPIO17
    RST -> GPIO16


    I created the example Transmitter code supplied with the library (Examples) in Arduino and it looks like this to me:

    Code: Arduino
    Log in, to see the code



    After uploading the batch to the ESP32 in the terminal I have something like this:

    [SX1278] Initializing ... success!
    [SX1278] Transmitting packet ... timeout!
    [SX1278] Transmitting packet ... timeout!
    [SX1278] Transmitting packet ... timeout!
    [SX1278] Transmitting packet ... timeout!



    That is, the initialisation of the SX1278 chip seems to work, but I have a timeout when sending data. What is the issue? I want to later run a second chip on a separate ESP32 and SX1278 to receive data, but I guess to check if the current one is sending data, I don't need a receiver after all? Because I don't think the transmitter is waiting for an acknowledgement from the receiver?
    I do need those RST, DIO0 and DIO1 signals configured in this function anyway?
    Code: Arduino
    Log in, to see the code

    I guess only the NSS is needed?
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 20407816
    miszcz310
    Level 24  
    I think in the first link I found:
    "NOTES:

    Some boards (like the Arduino Nano), cannot supply enough current for the SX127x in TX mode. This will cause lockups when sending, be sure to use an external 3.3V supply that can provide at least 120mA's when using these boards.
    If your Arduino board operates at 5V, like the Arduino Uno, Leonardo or Mega, you will need to use a level converter for the wiring to the Semtech SX127x module. Most Semtech SX127x breakout boards do not have logic level converters built-in."

    Do you have enough current in your circuit?
  • ADVERTISEMENT
  • #3 20407848
    Adix3
    Level 13  
    I took the power supply for the module directly from the ESP32 board. I disconnected it and connected it to a separate power supply, at the XL1278 module itself I also added a 100uF capacitor. But still the same problem. I noticed that when I unplug the XL1278 module from the power supply while it's running, then in the terminal with ESP32 I have something like this:

    [SX1278] Transmitting packet ... timeout!
    [SX1278] Transmitting packet ... timeout!
    [SX1278] Transmitting packet ... failed, code -16
    [SX1278] Transmitting packet ... failed, code -16



    So it looks like I think the ESP32 communication with the module is working, because after unplugging the power supply to the module some error appears, as if detecting no communication with the module.
  • #4 20412524
    Adix3
    Level 13  
    As I wrote earlier, I did not use the DIO0 and DIO1 signals. After adding the DIO0 connection, the circuit started working correctly and in the terminal I get as below:

    [SX1278] Transmitting packet ...  success!
    [SX1278] Datarate:	568.30 bps
    [SX1278] Transmitting packet ...  success!
    [SX1278] Datarate:	568.28 bps


    I wonder if DIO1 is also needed for something?
  • ADVERTISEMENT
  • Helpful post
    #5 20412675
    miszcz310
    Level 24  
    Oh Lord! So you haven't even gone into the documentation for this library :-) !
    See here: https://github.com/jgromes/RadioLib/wiki/Basics

    "[...]Provide the pin setup to the library.[...]GPIO: this is the fourth possible pin. It's optional for most modules, but may be required for some. SX127x requires additional interrupt pin to perform CAD and blocking receive. SX126x also uses this pin as the BUSY indication pin. If not in use, this pin can be left unassigned, or set to RADIOLIB_NC.[...]"
    It probably follows that the library was waiting for an interrupt from the module (standby notification). Maybe the latter is how it receives some packet, take now read what and how with this your module.
    Good luck!

    Edit: If you go into the datasheet of this chip (https://eu.mouser.com/datasheet/2/761/SEMT_S_A0007665073_1-2575876.pdf) It is there pin no. 20 RXTX/RF_MOD, which switches transmit/receive. The pins from DIO[0:5] are programmable inputs/outputs.... I don't understand a bit, but I don't have time to go into it now.
  • ADVERTISEMENT
  • #6 20414818
    Adix3
    Level 13  
    Fact my mistake, I thought SPI would be enough to support these modules.
    And maybe there is a person here who is well versed in these modules and would be able to tell me what needs to be done to get the greatest range, even at the expense of transmission speed?
  • Helpful post
    #7 20414853
    miszcz310
    Level 24  
    The range question is a slightly different tale. First question, do you have an antenna? Is this antenna somehow matched to this chip (at the frequencies this chip operates at)?
    Read also the datasheet (https://cdn-shop.adafruit.com/product-files/3179/sx1276_77_78_79.pdf)
    There is a section "4.1.1.2. Spreading Factor" As you are not interested in the data rate, you set it to max. Only you have to do it in both, receiver and transmitter. You can also set yourself maximum error detection, only this will also slow down the whole transmission. In general, read the documentation, there are lots of possible combinations there, and just test if it meets your requirements at all.
  • #8 20415627
    Adix3
    Level 13  
    miszcz310 wrote:
    The coverage question is a slightly different tale. The first question is, do you have an antenna? Is this antenna somehow matched to this chip (at the frequencies this chip operates at)?
    The antenna is in the form of a soldered "spring", this was supplied with the module.

    miszcz310 wrote:
    You can also set yourself maximum error detection, only this will also slow down the whole transmission.
    You mean CRC here?
  • Helpful post
    #9 20416306
    miszcz310
    Level 24  
    I rather meant: "4.1.1.3. Coding Rate" and actually this whole section: 4.1.1.6. LoRa TM Packet Structure. There is a CRC there, but there are more myopics here.
  • #10 20426567
    Adix3
    Level 13  
    Thanks for your help :)

    I have a few more questions about the SX1278 chips.

    1. I'm using the "RadioLib" library in Arduino, which has functions for setting various parameters of the chip, such as, transmit power, bandwidth, etc. You can also set parameters such as "preamble length" and "sync word". By default they are set to "0x12" and "8". Can someone explain to me what these are? I know there is documentation on this, but I don't understand what it is. Can someone explain it to me in simple terms?

    2. Does the SX1278 chip have something such that it can wake up the processor after receiving specific information? I'm most interested in something like this, that the processor enters sleep mode, the chip waits until it receives specific data and wakes the processor up.
  • #11 20427067
    miszcz310
    Level 24  
    Adix3 wrote:
    Thanks for your help

    I have a few more questions about the SX1278 chips.

    1. I'm using the "RadioLib" library in Arduino, which has functions to set various parameters of the chip, such as, transmit power, bandwidth, etc. You can also set parameters such as "preamble length" and "sync word". By default they are set to "0x12" and "8". Can someone explain to me what these are? I know there is documentation on this, but I don't understand what it is. Can someone explain it to me in layman's terms?


    Look at the datasheet, page 29. It says that the preamble is used to synchronise the received message. By default you have 12 character monsters. You can change this value from 10 to 65539. It says "nPreamble symbols". Here it doesn't clearly say if it can be one symbol or more, I would bet that it is one byte repeated "over and over". A value of 8, bitwise is 0b00001000, so you are sending a lot of zeros and not many ones. Maybe this makes a difference to power consumption.

    Adix3 wrote:
    2. Does the SX1278 chip have something such that it can wake up the processor when specific information is received? I'm most interested in something like that, the processor enters sleep mode, the chip waits until it receives specific data and wakes up the processor.


    Short answer, yes. For the longer answer, see table 18 on page 46. There it is shown that you can assign different signals to these DIOs. There are signals there that are responsible for receiving and sending data. I just don't know if this is exactly what you wanted.

    If you go to the documentation of this library (https://jgromes.github.io/RadioLib/class_s_x127x.html) there is for example the function:
    int16_t startReceive (uint8_t len=0, uint8_t mode=RADIOLIB_SX127X_RXCONTINUOUS)
    Interrupt-driven receive method. DIO0 will be activated when full valid packet is received. More...

Topic summary

The discussion revolves around connecting an XL1278 LoRa module to an ESP32 board using the RadioLib library for Arduino. Initial issues were encountered with transmission timeouts, which were resolved by connecting the DIO0 pin, essential for interrupt handling. Users discussed power supply concerns, suggesting that the module requires sufficient current, and the importance of using an appropriate antenna for optimal range. The conversation also touched on configuring parameters like preamble length and sync word, as well as the potential for the SX1278 chip to wake the processor from sleep mode upon receiving specific data.
Summary generated by the language model.
ADVERTISEMENT