69 lines
1.1 KiB
Arduino
Raw Normal View History

2021-09-27 20:51:23 +02:00
//
// FILE: SHT2x_heater.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo heater functions
// URL: https://github.com/RobTillaart/SHT2x
2021-09-29 13:21:17 +02:00
// WARNING: NOT TESTED FOR SHT2x - UNDER DEVELOPMENT
2021-09-27 20:51:23 +02:00
#include "Wire.h"
#include "SHT2x.h"
SHT2x sht;
uint8_t status;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("SHT2x_LIB_VERSION: \t");
Serial.println(SHT2x_LIB_VERSION);
sht.begin();
sht.setHeatTimeout(30); // heater timeout 30 seconds, just for demo.
status = sht.getStatus();
printHeaterStatus(status);
sht.heatOn();
while (sht.isHeaterOn())
{
status = sht.getStatus();
printHeaterStatus(status);
sht.read();
Serial.println(sht.getTemperature());
delay(10000);
}
Serial.println("switched off");
}
void loop()
{
// forced switch off
sht.heatOff();
delay(1000);
}
void printHeaterStatus(uint8_t status)
{
Serial.print(millis());
Serial.print("\tHEATER: ");
2021-09-29 13:21:17 +02:00
if (status == 0x00) // TODO - elaborate
2021-09-27 20:51:23 +02:00
{
Serial.println("ON");
} else {
Serial.println("OFF");
}
}
// -- END OF FILE --