From 4afa0a20cc77c6f6f1818ab39eecdcaa11f00db5 Mon Sep 17 00:00:00 2001 From: Andrew Menagarishvili Date: Fri, 6 Apr 2018 14:15:29 -0700 Subject: [PATCH] Adding Fahrenheit parameter to BME280 module --- .../Microsoft.PowerShell.IoT.BME280.psm1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Examples/Microsoft.PowerShell.IoT.BME280/Microsoft.PowerShell.IoT.BME280.psm1 b/Examples/Microsoft.PowerShell.IoT.BME280/Microsoft.PowerShell.IoT.BME280.psm1 index d4f72ef..2709747 100644 --- a/Examples/Microsoft.PowerShell.IoT.BME280/Microsoft.PowerShell.IoT.BME280.psm1 +++ b/Examples/Microsoft.PowerShell.IoT.BME280/Microsoft.PowerShell.IoT.BME280.psm1 @@ -51,7 +51,10 @@ function Get-BME280Data [string] $Mode, [Parameter(Mandatory=$false)] - [string] $Oversampling + [string] $Oversampling, + + [Parameter(Mandatory=$false)] + [switch] $Fahrenheit ) $Device = CreateDeviceIfNotExist -Device $Device @@ -74,6 +77,10 @@ function Get-BME280Data [int] $TFine = Calc-T-Fine $adc_T $script:CalibrationData[$Device] [float] $Temperature = (($TFine * 5 + 128) -shr 8) / [float]100; + if ($Fahrenheit) + { + $Temperature = $Temperature * 1.8 + 32 + } [float] $Pressure = Compensate_P $adc_P $script:CalibrationData[$Device] $TFine $Pressure = $Pressure / 100