hwthinker icon

Lora32u4_Sender-433MHz

hwthinker | PRO | 02/01/19 12:43:25 AM UTC | 0 ⭐ | 605 👁️ | Never ⏰ | []
Arduino |

1.36 KB

|

None

|

0 👍

/

0 👎

//modified lora library by Sandeep Mistry for lora32u4 433MHz
// lora Sender modified by HwThinker
// pin OUT ioMAP https://docs.bsfrance.fr/documentation/11296_LORA32U4/LoRa32u4_pinout_diagram.pdf
#include <SPI.h>
#include <LoRa.h>
// GPIO5  -- SX1278's SCK
// GPIO19 -- SX1278's MISO
// GPIO27 -- SX1278's MOSI
// GPIO18 -- SX1278's CS
// GPIO14 -- SX1278's RESET
// GPIO26 -- SX1278's IRQ(Interrupt Request)
 
#define SS      8
#define RST     4
#define DI0     7
#define BAND    433E6  
int counter = 0;
 
void setup() {
  pinMode(25,OUTPUT); //Send success, LED will bright 1 second
  
  Serial.begin(115200);
  //while (!Serial); // disable for LORA32U4
  
  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!");
}
 
void loop() {
  Serial.print("Sending packet: ");
  Serial.println(counter);
 
  // send packet
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();
 
  counter++;
  digitalWrite(25, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(25, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  
  delay(3000);
}

Comments