   }
 }
 
+/** Setup method. */
 void setup() {
   while (!Serial);
   delay(500);

  digitalWrite(enable_sensor_pin, LOW);
}

void send_packet(int sample) {
  Serial.print(F("Sending sample: "));
  Serial.println(sample);

  ble.print("AT+BLEUARTTX=");
  ble.print("B");
  ble.print(sample);
  ble.println("E");
  if (!ble.waitForOK())
    Serial.println(F("Failed to send?"));
}

void loop() {
  int samples[NUM_SAMPLES];
  read_sensor(samples);

  for (int i = 0; i < NUM_SAMPLES; i++)
    send_packet(samples[i]);

  delay(30 * 1000);

  if (!ble.isConnected()) {
    Serial.println(F("Disconnected!"));
    connect_to_host();
  }
}


      error(F("Couldn't factory reset"));
    }
  }
  
  pinMode(enable_sensor_pin, OUTPUT);
}

/** Reads samples from the sensor.
 *  
 *  @param samples The array where to store the samples.
 */
void read_sensor(int samples[]) {
  Serial.println(F("-- Enabling sensor and waiting for warm-up --"));
  digitalWrite(enable_sensor_pin, HIGH);
  delay(WARMUP_TIME);
  
  for (int i = 0; i < NUM_SAMPLES; i++) {
    delay(DELAY_BETWEEN_SAMPLES);
    samples[i] = analogRead(sensor_pin);
    Serial.print(F("Sensor value: "));
    Serial.println(samples[i]);
