-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoRa_Initialize_Test
49 lines (37 loc) · 1000 Bytes
/
LoRa_Initialize_Test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// test connection between ESP#@ and LoRa-02 module
#include <SPI.h>
#include <RH_RF95.h>
#define RFM95_CS 4 //NSS
#define RFM95_RST 5 //Reset
#define RFM95_INT 2 //DIO0
//Change to 433.0 or other frequency, must match RX's freq!
#define RF95_FREQ 433.0
//Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
void setup(){
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
Serial.begin(115200);
while (!Serial);
delay(100);
//Manual Reset
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
while (!rf95.init()) {
Serial.println(">> LoRa radio initialization failed.");
while (1);
}
//Defaults after init are 433.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(RF95_FREQ)) {
Serial.println(">> Set frequency failed.");
while (1);
}
rf95.setTxPower(18);
Serial.println(">> LoRa radio initialized successfully.");
}
void loop()
{
delay(1000);
}