Last active
June 24, 2022 01:41
-
-
Save jones2126/b2b0ee2174f1c9057692f9ca60b75efc to your computer and use it in GitHub Desktop.
TTGO Semtech SX1276 ESP32 LoRa board using Radio Head RH_RF95. This program is used to test getting the LoRa service to initialize.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ttgo_RH_RF95_init This program is used to test getting the LoRa service to initialize on a TTGO ESP32 LoRa board | |
ref: https://microcontrollerslab.com/ttgo-lora32-sx1276-oled-board-pinout-getting-started-with-arduino-ide/ | |
*/ | |
#include <SPI.h> | |
#include <RH_RF95.h> | |
#include <RHReliableDatagram.h> | |
// LoRa pins for TTGO Semtech SX1276 | |
#define LORA_MISO 19 | |
#define LORA_MOSI 27 | |
#define LORA_SCK 5 | |
#define LORA_SS 18 | |
#define LORA_IRQ 26 | |
#define LORA_RST 14 | |
#define LORA_BAND 915E6 // LoRa Band 915E6 for North America | |
#define TxPower 20 // defaults to 17; 20 is highest | |
#define CLIENT_ADDRESS 1 | |
int counter = 0; | |
RH_RF95 rf95; | |
RHReliableDatagram manager(rf95, CLIENT_ADDRESS); | |
void startLoRA(){ | |
pinMode(LORA_RST, OUTPUT); | |
delay(10); | |
digitalWrite(LORA_RST, LOW); | |
delay(10); | |
digitalWrite(LORA_RST, HIGH); | |
delay(10); | |
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS); //SPI LoRa pins | |
while (!manager.init() && counter < 10) { | |
Serial.print("."); | |
counter++; | |
delay(500); | |
} | |
if (counter == 10) { | |
Serial.println("Starting LoRa failed!"); | |
} else { | |
pinMode(2, OUTPUT); //turn on the onboard LED | |
digitalWrite(2, HIGH); | |
Serial.println("LoRa Initialization OK!"); } | |
delay(2000); | |
} | |
void setup(){ | |
Serial.begin(115200); | |
Serial.print("In Setup"); | |
startLoRA(); | |
} | |
void loop(){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment