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 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.
SYSTEM_MODE(SEMI_AUTOMATIC);
// This #include statement was automatically added by the Particle IDE.
#include "LoRa.h"
#include <SPI.h>
char temp[40];
void setup() {
//LoRa.setSPIFrequency(4e6);
delay(5000); //take a break
Serial.begin(9600);
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)LoRa.read());
temp[i] = spi;
Serial.print(temp[i]);
i++;
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
char buffer[3];
buffer[0] = temp[15];
buffer[1] = temp[16];
buffer[3] = '\0';
int n;
n = atoi(buffer);
Serial.println(n);
}
}
Instead // 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); LoRa.receive();
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 }