Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 6d0128f

Browse files
author
Andrew
authored
Merge pull request #17 from anmenaga/FahrenheitParameter
Adding Fahrenheit parameter to BME280 module
2 parents a222c1c + 4afa0a2 commit 6d0128f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: Examples/Microsoft.PowerShell.IoT.BME280/Microsoft.PowerShell.IoT.BME280.psm1

+8-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ function Get-BME280Data
5151
[string] $Mode,
5252

5353
[Parameter(Mandatory=$false)]
54-
[string] $Oversampling
54+
[string] $Oversampling,
55+
56+
[Parameter(Mandatory=$false)]
57+
[switch] $Fahrenheit
5558
)
5659
$Device = CreateDeviceIfNotExist -Device $Device
5760

@@ -74,6 +77,10 @@ function Get-BME280Data
7477

7578
[int] $TFine = Calc-T-Fine $adc_T $script:CalibrationData[$Device]
7679
[float] $Temperature = (($TFine * 5 + 128) -shr 8) / [float]100;
80+
if ($Fahrenheit)
81+
{
82+
$Temperature = $Temperature * 1.8 + 32
83+
}
7784

7885
[float] $Pressure = Compensate_P $adc_P $script:CalibrationData[$Device] $TFine
7986
$Pressure = $Pressure / 100

0 commit comments

Comments
 (0)