 }
 
 void loop() {
-  if (byteCount > 0) {
+  int bc = atomicGet(&byteCount);
+
+  if (bc > 0) {
     // Print data length
     Serial.print("Packet received: ");
-    Serial.print(byteCount);
+    Serial.print(bc);
     Serial.println(" bytes");
     
     // Print data in hexadecimal format
-    for (int i = 0; i < byteCount; i++) {
+    for (int i = 0; i < bc; i++) {
       char hex[4];
       sprintf(hex, "%02X ", buf[i]);
       Serial.print(hex);

    Serial.println();
    Serial.println();
    
    byteCount = 0;
  }
}

void receive() {

byte buf[MRF_MAX_PAYLOAD_SIZE];

// Number of bytes received
volatile int byteCount = 0;

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