diff --git a/Source/Meadow.Clima/ClimaHardwareV3.cs b/Source/Meadow.Clima/ClimaHardwareV3.cs index a5303c1..0b91fba 100644 --- a/Source/Meadow.Clima/ClimaHardwareV3.cs +++ b/Source/Meadow.Clima/ClimaHardwareV3.cs @@ -6,6 +6,7 @@ using Meadow.Foundation.Sensors.Weather; using Meadow.Hardware; using Meadow.Logging; +using Meadow.Units; using System; #nullable enable @@ -79,6 +80,20 @@ public class ClimaHardwareV3 : IClimaHardware /// protected Logger? Logger { get; } = Resolver.Log; + /// + /// Analog inputs to measure Solar voltage has Resistor Divider with R1 = 1000 Ohm, R2 = 680 Ohm + /// Measured analogue voltage needs to be scaled to RETURN actual input voltage + /// Input Voltage = AIN / Resistor Divider + /// + protected const double SolarVoltageResistorDivider = 680 / (1000 + 680); + + /// + /// Analog inputs to measure Solar voltage has Resistor Divider with R1 = 1000 Ohm, R2 = 680 Ohm + /// Measured analogue voltage needs to be scaled to RETURN actual input voltage + /// Input Voltage = AIN / Resistor Divider + /// + protected const double BatteryVoltageResistorDivider = 2000 / (1000 + 2000); + /// /// Create a new ClimaHardwareV3 object /// @@ -182,7 +197,9 @@ public ClimaHardwareV3(IF7CoreComputeMeadowDevice device, II2cBus i2cBus) try { Logger?.Trace("Instantiating Solar Voltage Input"); - SolarVoltageInput = device.Pins.A02.CreateAnalogInputPort(5); + SolarVoltageInput = device.Pins.A02.CreateAnalogInputPort(5, + AnalogInputPort.DefaultSampleInterval, + AnalogInputPort.DefaultReferenceVoltage / SolarVoltageResistorDivider); Logger?.Trace("Solar Voltage Input up"); } catch (Exception ex) @@ -193,7 +210,10 @@ public ClimaHardwareV3(IF7CoreComputeMeadowDevice device, II2cBus i2cBus) try { Logger?.Trace("Instantiating Battery Voltage Input"); - BatteryVoltageInput = device.Pins.A04.CreateAnalogInputPort(5); + BatteryVoltageInput = device.Pins.A04.CreateAnalogInputPort(5, + AnalogInputPort.DefaultSampleInterval, + AnalogInputPort.DefaultReferenceVoltage / BatteryVoltageResistorDivider); + Logger?.Trace("Battery Voltage Input up"); } catch (Exception ex)