                       0x78, 0xAB, 0xCD, 0xEF};
     state = lora.startTransmit(byteArr, 8);
   */
-  
-  if (state != ERR_NONE) {
-    Serial.print(F("failed, code "));
-    Serial.println(state);
-  }
 }
 
 // flag to indicate that a packet was received
 volatile bool transmittedFlag = false;
 
+// disable interrupt when it's not needed
+volatile bool enableInterrupt = true;
+
+// this function is called when a complete packet
+// is transmitted by the module
+// IMPORTANT: this function MUST be 'void' type
+//            and MUST NOT have any arguments!
 void setFlag(void) {
-  // packet transmission is finished, set the flag
+  // check if the interrupt is enabled
+  if(!enableInterrupt) {
+    return;
+  }
+
+  // we sent a packet, set the flag
   transmittedFlag = true;
 }
 
 void loop() {
   // check if the previous transmission finished
   if(transmittedFlag) {
-    Serial.println(F("transmission finished!"));
+    // disable the interrupt service routine while
+    // processing the data
+    enableInterrupt = false;
 
-    // wait one second before next transmission
+    // reset flag
+    transmittedFlag = false;
+
+    if (transmissionState == ERR_NONE) {
+      // packet was successfully sent
+      Serial.println(F("transmission finished!"));
+
+      // NOTE: when using interrupt-driven transmit method,
+      //       it is not possible to automatically measure
+      //       transmission data rate using getDataRate()
+
+    } else {
+      Serial.print(F("failed, code "));
+      Serial.println(transmissionState);
+
+    }
+
+    // wait a second before transmitting again
     delay(1000);
 
-    // send another packet
+    // send another one
     Serial.print(F("Sending another packet ... "));
 
     // you can transmit C-string or Arduino string up to
     // 256 characters long
-    int state = lora.startTransmit("Hello World!");
-  
+    transmissionState = lora.startTransmit("Hello World!");
+
     // you can also transmit byte array up to 256 bytes long
     /*
       byte byteArr[] = {0x01, 0x23, 0x45, 0x56,

// DIO1 pin:  3
// IMPORTANT: because this example uses external interrupts,
//            DIO0 MUST be connected to Arduino pin 2 or 3.
//            DIO1 MAY be connected to any free pin 
//            or left floating.
SX1278 lora = new LoRa;

void setup() {
  Serial.begin(9600);


  // you can transmit C-string or Arduino string up to
  // 256 characters long
  transmissionState = lora.startTransmit("Hello World!");

  // you can also transmit byte array up to 256 bytes long
  /*
