Particle with LoRa & Sleep mode

Hey Everyone!

I’m looking for some advice for a project I’m working on.

I have an Electron connected to a LoRa module. (sx1276) operating as a Callback receiver.

The Electron waits for a signal from DIO0 on the LoRa which is connected to D2 on the Electron to begin the data RX.

The issue I am having is that I also want the Electron to wait on this signal to wake up from sleep mode. ie. System.sleep(D2, RISING);

The issue I am having is that when D2 goes high, the Electron wakes up but I’m not getting the data from the LoRa module. I think the reason is that both System.sleep and the SPI code for LoRa are looking for the rising edge however only the System.sleep part is able to see it.


I’m not sure I understand exactly what you’re doing but I have the RFM95w LoRa radios working with the Photon.

Can you add a delay between waking up the Electron and starting the process of receiving the LoRa TX info on the Electron RX line?


I do have the LoRa working,I am running into issues because I am trying to reduce the power consumption.

I am trying to sleep the Particle until there is data incoming. The way i am trying to do this is to listen for the preamble on D2.

The problem is that when I put in the function System.sleep(D2, RISING); The preamble signal on D2 from the LoRa stops being generated.


@PeaTearDial, which LoRa module are you using exactly?

Hey im using a DRF1276G.

@PeaTearDial, which DIO pin on the module are you using for the PreAmble detect?

Hey, I’m using DIO0.

I believe when RISING is selected, the INPUT_PULLDOWN pinMode is selected, which the LoRa module might not like ( which is surprising). Setting the interrupt to CHANGE will leave the pin floating (like a typical input). I believe the LoRa module is already driving the DIO0 pin LOW anyway so a pull-down is not necessary. The interrupt will fire on the first change on DIO0 so it should work.

Hey, thanks for the info. Unfortunately it didn’t work. if I leave out the sleep command I can see the change on DIO0 with the my scope. When I put in the sleep command, the signal disappears.

// This #include statement was automatically added by the Particle IDE.
#include "LoRa.h"

#include <SPI.h>
char temp[40];

void setup() {
  delay(5000); //take a break

  delay(1000); //take a break

  Serial.println("LoRa Receiver");

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

void loop() {
    System.sleep(D2, CHANGE);
    // try to parse packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    // received a packet
    Serial.print("Received packet '");

    // read packet
    int i = 0;
    while (LoRa.available()) {
      char spi = ((char); 
      temp[i] = spi;
    // print RSSI of packet
    Serial.print("' with RSSI ");
    char buffer[3];
    buffer[0] = temp[15];
    buffer[1] = temp[16];
    buffer[3] = '\0';

    int  n;
    n = atoi(buffer);



@PeaTearDial, comment out the sleep and at the end of setup() add pinMode(D2, INPUT); and see if the DIO0 signal remains.

Hey, yes the DIO0 signal is still there…

What other pins/power do you have connected between the Electron and the LoRa module?

Hey, I am connected to the following pins.

SCK – A3
NSS – A2
RST – D0
3.3V – 3V3

// try to parse packet
int packetSize = LoRa.parsePacket();
I have used directly
// try to check available
int packetSize = LoRa.available();
And then it works.

But an important thing that I have used for my LoRa Ra-02 (433 Mhz) after
if (!LoRa.begin(433E6)) while(1);
I have added continous reading command for trigger interrupt else to me not works
if (!LoRa.begin(433E6)) while(1);

Then I have some problems to perform this method ever, so I repeat begin and receive in loop cicle inside the code if (packetSize) { at bottom of code before the closing bracket }