hwthinker icon

LoraSender_T-Deer-915MHZ

hwthinker | PRO | 09/15/19 08:31:15 AM UTC | 0 ⭐ | 523 👁️ | Never ⏰ | []
Arduino |

1.45 KB

|

None

|

0 👍

/

0 👎

// lora Sender for TTGO TDeer Pro mini lora 915 Mhz modified by HwThinker
// board tool->board arduino mini
#include <SPI.h>
#include <LoRa.h>
#define LEDExternal 3
 
#define SCK     13    // GPIO5 -- lora SCK
#define MISO    12   // GPIO19 -- lora MISO
#define MOSI    11   // GPIO27 -- lora MOSI
#define SS      10   // GPIO18 -- lora CS
#define RST     9   // GPIO9   -- RESET 
#define DI0     2   // GPIO26  -- IRQ(Interrupt Request)
 
#define BAND    915E6
 
int counter = 0;
int state = 0;
 
void setup() {
  // START aktivas Oled
  pinMode(LEDExternal, OUTPUT);
 
  Serial.begin(115200);
  while (!Serial); //If just the the basic function, must connect to a computer
 
  //SPI.begin(SCK, MISO, MOSI, SS);  // disable for AVR
  LoRa.setPins(SS, RST, DI0);
  //  Serial.println("LoRa Sender");
 
  if (!LoRa.begin(BAND)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
 
 
  Serial.println("LoRa Initial OK! Blinky 1.5 second");
  for (int i=0;i<15;i++) {
    digitalWrite(LEDExternal, digitalRead(LEDExternal) ? LOW : HIGH);
    delay(100);
  }
 
 
}
 
void loop() {
 
  Serial.print("Sending packet: ");
  Serial.println(counter);
 
  // send packet
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();
 
  counter++;
  digitalWrite(LEDExternal, (state) ? HIGH : LOW);
  delay(1000);
  state = !state;
  //or   digitalWrite(LEDExternal, !digitalRead(LEDExternal));
}

Comments