diff --git a/src/devices/Shtc3/Shtc3.cs b/src/devices/Shtc3/Shtc3.cs
index 9ad994d3d43ef89725d2c9c3a052a651efdd26eb..b29f8998464c01f763058124eb62ccf434998e60 100644
--- a/src/devices/Shtc3/Shtc3.cs
+++ b/src/devices/Shtc3/Shtc3.cs
@@ -35,17 +35,13 @@ namespace Iot.Device.Shtc3
{
_i2cDevice = i2cDevice ?? throw new ArgumentNullException(nameof(i2cDevice));
- Wakeup();
-
Reset();
}
- private Status _status;
-
///
- /// Set Shtc3 state
+ /// Current state of Shtc3 sensor
///
- internal Status Status => _status;
+ private Status _status = Status.Unknown;
private static Register GetMeasurementCmd(bool lowPower, bool clockStretching)
{
@@ -122,10 +118,7 @@ namespace Iot.Device.Shtc3
/// True if operation was successful
public bool TryGetTemperatureAndHumidity(out Temperature temperature, out RelativeHumidity relativeHumidity, bool lowPower = false, bool clockStretching = false)
{
- if (Status == Status.Sleep)
- {
- Wakeup();
- }
+ Wakeup();
Register cmd = GetMeasurementCmd(lowPower, clockStretching);
@@ -174,14 +167,12 @@ namespace Iot.Device.Shtc3
///
public void Sleep()
{
- if (Status == Status.Sleep)
+ if (_status != Status.Sleep)
{
- return;
- }
+ Write(Register.SHTC3_SLEEP);
- Write(Register.SHTC3_SLEEP);
-
- _status = Status.Sleep;
+ _status = Status.Sleep;
+ }
}
///
@@ -189,9 +180,12 @@ namespace Iot.Device.Shtc3
///
private void Wakeup()
{
- Write(Register.SHTC3_WAKEUP);
+ if (_status != Status.Idle)
+ {
+ Write(Register.SHTC3_WAKEUP);
- _status = Status.Idle;
+ _status = Status.Idle;
+ }
}
///
@@ -199,10 +193,7 @@ namespace Iot.Device.Shtc3
///
public void Reset()
{
- if (Status == Status.Sleep)
- {
- Wakeup();
- }
+ Wakeup();
Write(Register.SHTC3_RESET);
}
@@ -217,10 +208,7 @@ namespace Iot.Device.Shtc3
///
private int? ReadId()
{
- if (Status == Status.Sleep)
- {
- Wakeup();
- }
+ Wakeup();
Write(Register.SHTC3_ID);
diff --git a/src/devices/Shtc3/Status.cs b/src/devices/Shtc3/Status.cs
index 58d59d73a6b6a333d2f9788196cd0a8e0d129f52..91420693b2c55834f72b669a9be239f6e44f09a3 100644
--- a/src/devices/Shtc3/Status.cs
+++ b/src/devices/Shtc3/Status.cs
@@ -8,6 +8,11 @@ namespace Iot.Device.Shtc3
///
internal enum Status
{
+ ///
+ /// Sensor in an unknown state
+ ///
+ Unknown = 0,
+
///
/// Sensor ready to use
///