Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAD detected #25

Open
pipesg opened this issue May 25, 2020 · 2 comments
Open

CAD detected #25

pipesg opened this issue May 25, 2020 · 2 comments

Comments

@pipesg
Copy link

pipesg commented May 25, 2020

Hello,
I am using your boards (grasshopper and cricket) to develop an animal tracker by using the LoRa radio not LoRaWAN. To reduce the power consumption from the tracker I will like to use a low energy design provide by Semtech (AN1200.17) using the channel activity detection (CAD) of the radio. I am not very proficient in programming so perhaps I am missing something or doing something incorrect, but I am not able to detect the preambles. I have also asked this in GrumpyOldPizza/ArduinoCore-stm32l0 repository but without replies, so sorry for duplicate the question.
I am using two simple programs, one to send a message with a long preamble (10 seconds) and another implementing the CAD function;
Preamble send
`#include "LoRaRadio.h"
#define myLed 13

void setup( void )
{
Serial.begin(115200);
pinMode(myLed, OUTPUT);
digitalWrite(myLed, LOW);
LoRaRadio.begin(865200000);
LoRaRadio.setFrequency(865200000);
LoRaRadio.setTxPower(14);
LoRaRadio.setPreambleLength (300);
LoRaRadio.setBandwidth(LoRaRadio.BW_125);
LoRaRadio.setSpreadingFactor(LoRaRadio.SF_12);
LoRaRadio.setCodingRate(LoRaRadio.CR_4_5);
LoRaRadio.setLnaBoost(true);
delay (2000);
}

void loop( void )
{
unsigned long previous = millis ();
digitalWrite(myLed, HIGH);
LoRaRadio.beginPacket();
LoRaRadio.write(1);
LoRaRadio.endPacket();
while (LoRaRadio.busy());
unsigned long last = millis ();
last -= previous;
Serial.println (last);
digitalWrite(myLed, LOW);
delay(3000);
}`

CAD
`#include "LoRaRadio.h"
bool CadDone;
bool CadDetected;

void setup( void ){
Serial.begin(115200);
LoRaRadio.begin(865200000);
LoRaRadio.setFrequency(865200000);
LoRaRadio.setTxPower(14);
LoRaRadio.setBandwidth(LoRaRadio.BW_125);
LoRaRadio.setSpreadingFactor(LoRaRadio.SF_12);
LoRaRadio.setCodingRate(LoRaRadio.CR_4_5);
LoRaRadio.setLnaBoost(true);
LoRaRadio.onCad(CADcallback);
}

void loop( void ){
CadDone = false;
CadDetected = false;
Serial.print ("Caddone: "); Serial.println (CadDone);
unsigned long cadinit = millis ();
LoRaRadio.cad ();
while (LoRaRadio.busy());
unsigned long cadend = millis ();
Serial.print ("Caddone: "); Serial.println (CadDone);
Serial.print ("CadDetected: "); Serial.println (CadDetected);
cadend -= cadinit;
Serial.print ("Cad length: "); Serial.println (cadend);
Serial.println ();
delay (1500);
}

void CADcallback (void){
CadDone = true;
CadDetected = LoRaRadio.cadDetected ();
}`

I am quite that the CAD is executing because the the caend-cadinit lenght is the same as the estimated time in the LoRa calculator by Semtech but the program is not able to detect the preambles by using LoRaRadio.cadDetected () function.
Any help would be greatly welcome, thanks in advance!

@kriswiner
Copy link
Owner

kriswiner commented May 25, 2020 via email

@pipesg
Copy link
Author

pipesg commented May 26, 2020

Hi,
Many thanks for your prompt reply.
I am using two grasshoppers two test this example and LoRaRadio seems to work without problems in sending and receiving. I have also tested the sense function and it also works, only cadDetected looks like fail or I am using it incorrectly. Cad and caddone apparently works fine.
Why you say old LoRaRadio, is there another library? Why you think the logic is off?
Regarding the PAboost I have just copied the setup part from one of the examples of the LoRaRadio to test cad, in all of them are enabled.
One last question, is there another method to recover a faulty grasshopper? I have a third grasshopper that is not detected by arduino, it do not appear in the ports section, if I press boot and reset it sound like the board is disconnecting and connecting from windows but it do not appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants