Skip to content

Commit

Permalink
Merge pull request #1089 from WildernessLabs/bug/ens-160
Browse files Browse the repository at this point in the history
Fixes for the ENS160
  • Loading branch information
adrianstevens authored Nov 10, 2024
2 parents c238368 + 53828b5 commit 126afe4
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ public Ens160(II2cBus i2cBus, byte address = (byte)Addresses.Default)
CurrentOperatingMode = OperatingMode.Standard;
}

/// <summary>
/// Create a new ENS160 object
/// </summary>
/// <remarks>
/// The constructor sends the stop periodic updates method otherwise
/// the sensor may not respond to new commands
/// </remarks>
/// <param name="i2cBus">The I2C bus</param>
/// <param name="address">The I2C address</param>
public Ens160(II2cBus i2cBus, Ens160.Addresses address = Addresses.Default)
: base(i2cBus, (byte)address, readBufferSize: 9, writeBufferSize: 9)
{
Initialize().Wait();

CurrentOperatingMode = OperatingMode.Standard;
}

/// <summary>
/// Initialize the sensor
/// </summary>
Expand Down Expand Up @@ -175,7 +192,7 @@ public UBAAirQualityIndex GetAirQualityIndex()
{
var value = BusComms.ReadRegister((byte)Registers.DATA_AQI);

var aqi = value >> 5;
var aqi = value & 0b0111;

return (UBAAirQualityIndex)aqi;
}
Expand Down

0 comments on commit 126afe4

Please sign in to comment.