DWM1000 and DW1000 compatibility

If you remove the first loop() then loop is only called when serial data is entered.
Try something more like

bool sleepMode = false;
void loop() { 
  if (!sleepMode)
    DW1000Ranging.loop();

  if (Serial.available()) {
    int state = Serial.parseInt();
    if (state == 1) {
      sleepMode = false;
      DW1000.spiWakeup();
      // don't know if some other re-initialisation will also be required here or not.
      // maybe try a short wait and then soft reset if it doesn't work as is.
      Serial.println("ON");
   }
   if (state == 2) {
     sleepMode = true;
     DW1000.deepSleep();
     Serial.println("OFF");
   }  
 }
}
1 Like