     if (role == role_remote) {
         // Get the current state of buttons, and
         // Test if the current state is different from the last state we sent
-        uint8_t state = ! digitalRead(sensor_pin);
+        delay(5);
+        bool state = !digitalRead(sensor_pin);
         printf("Sensor state: %d\n", state);
         if (state != sensor_state) {
             different = true;
+            send_tries = 500;
             sensor_state = state;
+            led_state = sensor_state;
         }
 
         // Send the state of the buttons to the LED board
-        if (different) {
+        if (send_tries && (different || !send_ok)) {
             printf("Now sending...");
-            led_state = sensor_state;
             digitalWrite(led_pin, led_state);
             radio.powerUp();
-            delay(5);
-            int tries = 50;
-            bool ok = false;
-            while (!ok && tries) {
-                ok = radio.write( &sensor_state, sizeof(uint8_t) );
-                if (ok) {
-                    printf("ok\n\r");
-                } else {
-                    printf("failed\n\r");
-                    digitalWrite(sleep_pin, LOW);
-                    digitalWrite(led_pin, LOW);
-                    delay(50);        
-                    digitalWrite(sleep_pin, HIGH);            
-                    digitalWrite(led_pin, led_state);            
-                }
-                tries--;
+            delay(10);
+            send_ok = radio.write( &sensor_state, sizeof(bool), false );
+            if (send_ok) {
+                printf("ok\n\r");
+            } else {
+                printf("failed\n\r");
+                send_tries--;
+                digitalWrite(sleep_pin, LOW);
+                digitalWrite(led_pin, LOW);
+                delay(50);        
+                digitalWrite(sleep_pin, HIGH);            
+                digitalWrite(led_pin, led_state);            
             }
             radio.powerDown();
             awakems = 0;
         }
 
         awakems += 1;
-        if (awakems > 100) {
-          sleepNow();
-          awakems = 0;
+        if (awakems > 10) {
+            sleepNow();
+            awakems = 0;
         }
     }
 

#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>

#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__)
RF24 radio(3,7);

        GIMSK |= _BV(INT0);                       //enable INT0
        MCUCR &= ~(_BV(ISC01) | _BV(ISC00));      //INT0 on low level
#else
        attachInterrupt(0, wakeATMega, CHANGE);
#endif
    }
    ACSR |= _BV(ACD);                         //disable the analog comparator
