     // Battery voltage should not drop too much
     if (selftest.batteryVoltageMv < conf.alertBatteryVoltage) {
       selftest.passed = false;
-      sprintf(buf, PSTR((char*)pgm_read_word(&(str_Weak_battery_dmV))), selftest.batteryVoltageMv);
+      sprintf(buf, PSTR("Weak battery: %dmV"), selftest.batteryVoltageMv);
       raiseAlert(DcPumpMalfunction, buf);
       return;
     }
     // Determine if water level was reduced enough
     if (selftest.startingHeight - selftest.endingHeight < 5) {
       selftest.passed = false;
-      sprintf(buf, PSTR((char*)pgm_read_word(&(str_DC_Pump_failure_dCM_pumped_in_d_sec))), (selftest.startingHeight - selftest.endingHeight), (int)selftest.testLength);
+      sprintf(buf, PSTR("DC Pump failure: %dCM pumped in %d sec."), (selftest.startingHeight - selftest.endingHeight), (int)selftest.testLength);
       raiseAlert(DcPumpMalfunction, buf);
       return;
     }

// Buffer for char conversions
char buf [100];

// PROGMEM string declarations
const char str_alertPresent[] PROGMEM = "alertPresent";
const char str_alarmPresent[] PROGMEM = "alarmPresent";
const char str_YES_Ack_ed[] PROGMEM = "YES, Ack'ed";
const char str_YES[] PROGMEM = "YES";
const char str_NO[] PROGMEM = "NO";
const char str_alertReason[] PROGMEM = "alertReason";
const char str_getDistance[] PROGMEM = "getDistance";
const char str_getPressure[] PROGMEM = "getPressure";
const char str_getBattVoltage[] PROGMEM = "getBattVoltage";
const char str_dmV[] PROGMEM = "%dmV";
const char str_getAcPumpOnTime[] PROGMEM = "getAcPumpOnTime";
const char str_d[] PROGMEM = "%d";
const char str_getLastSelfTest[] PROGMEM = "getLastSelfTest";
const char str_forceAlert[] PROGMEM = "forceAlert";
const char str_Force_command[] PROGMEM = "Force command";
const char str_OK[] PROGMEM = "OK";
const char str_resetAlert[] PROGMEM = "resetAlert";
const char str_startSelfTest[] PROGMEM = "startSelfTest";
const char str_set[] PROGMEM = "set";
const char str_debug[] PROGMEM = "debug";
const char str_Unrecognized_command[] PROGMEM = "Unrecognized command";
const char str_setAlertBatteryVoltage[] PROGMEM = "setAlertBatteryVoltage:";
const char str_ERROR[] PROGMEM = "ERROR";
const char str_setAlertWaterLevel[] PROGMEM = "setAlertWaterLevel:";
const char str_setBaudRate[] PROGMEM = "setBaudRate:";
const char str_setAcPumpOnThreshold[] PROGMEM = "setAcPumpOnThreshold:";
const char str_setAlertPressureLevel[] PROGMEM = "setAlertPressureLevel:";
const char str_setAcPumpOnTimeWarning[] PROGMEM = "setAcPumpOnTimeWarning:";
const char str_setSelftestTimeBetween[] PROGMEM = "setSelftestTimeBetween:";
const char str_setSelfTestTimeLimit[] PROGMEM = "setSelfTestTimeLimit:";
const char str_setSelfTestMinDepth[] PROGMEM = "setSelfTestMinDepth:";
const char str_setSelfTestDepthDiff[] PROGMEM = "setSelfTestDepthDiff:";
const char str_setDepthMeasureTime[] PROGMEM = "setDepthMeasureTime:";
const char str_setBuzzerEnabled[] PROGMEM = "setBuzzerEnabled:";
const char str_setZeroPressure[] PROGMEM = "setZeroPressure:";
const char str_setPointsPerCm[] PROGMEM = "setPointsPerCm:";
const char str_setDcPumpOnTimeWarning[] PROGMEM = "setDcPumpOnTimeWarning:";
const char str_ERROR_1_3600_expected[] PROGMEM = "ERROR: 1-3600 expected.";
const char str_time_lu[] PROGMEM = "time=%lu";
const char str_rangeLH_0_d_d[] PROGMEM = "rangeLH[0]=%d,%d";
const char str_rangeLH_1_d_d[] PROGMEM = "&rangeLH[1]=%d,%d";
const char str_DcHeight_d_d[] PROGMEM = "&DcHeight=%d,%d";
const char str_pressure_d[] PROGMEM = "&pressure=%d";
const char str_AcPumpCycles_d[] PROGMEM = "&AcPumpCycles=%d";
const char str_lastAlertTime_lu[] PROGMEM = "&lastAlertTime=%lu";
const char str_rawDepthPressure_d[] PROGMEM = "&rawDepthPressure=%d";
const char str_timeSince_lu[] PROGMEM = "timeSince=%lu&";
const char str_cyclesSince_d[] PROGMEM = "cyclesSince=%d&";
const char str_voltage_d[] PROGMEM = "voltage=%d&";
const char str_length_d[] PROGMEM = "length=%d&";
const char str_pumpedHeight_d[] PROGMEM = "pumpedHeight=%d&";
const char str_result_d[] PROGMEM = "result=%d";
const char str_Weak_battery_dmV[] PROGMEM = "Weak battery: %dmV";
const char str_DC_Pump_failure_dCM_pumped_in_d_sec[] PROGMEM = "DC Pump failure: %dCM pumped in %d sec.";
const char str_DC_Pump_ON[] PROGMEM = "DC Pump ON";
const char str_DC_pump_ON_too_long[] PROGMEM = "DC pump ON too long";
const char str_Battery_voltage[] PROGMEM = "Battery voltage";
const char str_Water_level_d[] PROGMEM = "Water level: %d";
const char str_High_pressure[] PROGMEM = "High pressure";
const char str_AC_pump_ON_for_too_long[] PROGMEM = "AC pump ON for too long";

void setup()
{
  readConfig();

    ) {
      conf.baudRate = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
      Serial.end();
      Serial.begin(tmp);
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setAcPumpOnThreshold:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp > 0 && tmp < 1025) {
      conf.acPumpOnThreshold = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setAlertPressureLevel:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp > 0 && tmp < 1025) {
      conf.alertPressureLevel = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setAcPumpOnTimeWarning:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp > 0 && tmp < 30000) {
      conf.acPumpOnTimeWarning = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setSelftestTimeBetween:"), buf)) {
    long tmp = strtol(buf, NULL, 10);
    if (tmp > 0 && tmp < 1000000L) {
      conf.selftestTimeBetween = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setSelfTestTimeLimit:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    // More than 6 seconds, as we're checking that DC pump is on at 6 second mark.
    if (tmp > 6 && tmp < 200) {
      conf.selfTestTimeLimit = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setSelfTestMinDepth:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp > -100 && tmp < 100) {
      conf.selfTestMinDepth = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setSelfTestDepthDiff:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp > 0 && tmp < 100) {
      conf.selfTestDepthDiff = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setDepthMeasureTime:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp >= 0 && tmp < 120) {
      conf.depthMeasureTime = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setBuzzerEnabled:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp == 1 || tmp == 0) {
      conf.buzzerEnabled = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setZeroPressure:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp >= 0 && tmp < 1023) {
      conf.zeroPressure = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setPointsPerCm:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp >= -1024 && tmp < 1024) {
      conf.pointsPerCm = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR"));
    }
  } else if (net.assertCommandStarts(PSTR("setDcPumpOnTimeWarning:"), buf)) {
    int tmp = strtol(buf, NULL, 10);
    if (tmp >= 1 && tmp < 3600) {
      conf.dcPumpOnTimeWarning = tmp;
      saveConfig();
      net.sendResponse(PSTR("OK"));
    } else {
      net.sendResponse(PSTR("ERROR: 1-3600 expected."));
    }
  } else {
    net.sendResponse(PSTR("Unrecognized command"));
  }
}

void sendDebugResponse()
{
  sprintf(buf, PSTR("time=%lu"), now());
  net.responseSendPart(buf);
  sprintf(buf, PSTR("rangeLH[0]=%d,%d"), range.lows[0], range.highs[0]);
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&rangeLH[1]=%d,%d"), range.lows[1], range.highs[1]);
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&DcHeight=%d,%d"), selftest.startingHeight, selftest.endingHeight);
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&pressure=%d"), analogRead(PRESSURE_SENSOR_PIN));
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&AcPumpCycles=%d"), acpump.onCycles);
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&lastAlertTime=%lu"), alert.timeTriggered);
  net.responseSendPart(buf);
  sprintf(buf, PSTR("&rawDepthPressure=%d"), analogRead(DEPTH_PRESSURE_SENSOR_PIN));
  net.responseSendPart(buf);
//  sprintf(buf, );
//  net.responseSendPart(buf);
