/*
 * Anatole SCHRAMM-HENRY
 * Tim THUREL
 * Température groupe 3
 * 
 * Test de la bibliothèque permettant de piloter le STS21
 * Capteur de température de la marque SENSIRION
 * Précision : 0.2°C
 */

#include "STS21.h"

STS21 sts21;

void setup()
{
  Serial.begin(115200);
  Serial.println("Starting sts21 test");
  if(sts21.begin())
    Serial.println("Sensor present !");
  else
    Serial.println("Sensor missing !");
  Serial.println("End setup");
  sts21.reset();
  Serial.println("Setting chip heater");
  sts21.enableOnChipHeater(true);
  delay(100);
  Serial.println("Setting chip heater");
  sts21.enableOnChipHeater(false);
  delay(100);
  Serial.println("Setting resolution 12");
  sts21.setResolution(STS21::RES_12);
  delay(100);
  Serial.println("Setting resolution 14");
  sts21.setResolution(STS21::RES_14);
  delay(100);
  Serial.println("Setting resolution 13");
  sts21.setResolution(STS21::RES_13);
  delay(100);
  Serial.println("Setting resolution 11");
  sts21.setResolution(STS21::RES_11);
  delay(100);
  sts21.setResolution(STS21::RES_14);
  delay(100);
}

void loop()
{
  double temp = sts21.getTemperature();
  Serial.printf("No Hold -> temp : %.2f\n",temp);
  temp = sts21.getTemperature(false);
  Serial.printf("Hold -> temp : %.2f, Battery level low : %s\n",temp, sts21.lowBattery() ? "true":"false");

  delay(1000);
}
