Skip to main content

Meadow.Foundation.ICs.ADC.Ads7128

Ads7128
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.ICs.ADC.Ads7128

Code Example​

private Ads7128 adc;
private IAnalogInputPort ch0;

public override async Task Initialize()
{
Resolver.Log.Info("Initialize...");

var bus = Device.CreateI2cBus();

adc = new Ads7128(
bus,
Ads7128.Addresses.Default);

ch0 = adc.CreateAnalogInputPort(adc.Pins.AIN0);
}

public override async Task Run()
{
while (true)
{
var voltage = await ch0.Read();

Resolver.Log.Info($"AIN0 voltage: {voltage.Volts:N2}");

await Task.Delay(2000);
}
}

Sample project(s) available on GitHub

API Reference​

Class Ads7128

Controller for the ADS7128 analog-to-digital converter chip that supports individual analog input control and array-based analog input operations.

Assembly: Ads7128.dll​
View Source​
Declaration
public class Ads7128 : IAnalogInputController, IAnalogInputArrayController, IPinController

Implements:
Meadow.Hardware.IAnalogInputController, Meadow.Hardware.IAnalogInputArrayController, Meadow.Hardware.IPinController

Properties​

Pins​

Gets the pin definitions for this ADC controller.

View Source​
Declaration
public Ads7128.PinDefinitions Pins { get; }

ReferenceVoltage​

Gets the reference voltage used by the ADC for conversions.

View Source​
Declaration
public Voltage ReferenceVoltage { get; }

DefaultI2cAddress​

The default I2C address for the peripheral

View Source​
Declaration
public byte DefaultI2cAddress { get; }

CurrrentOversampling​

Gets or sets the current oversampling configuration for the ADC.

View Source​
Declaration
public Ads7128.Oversampling CurrrentOversampling { get; set; }

Fields​

ADCPrecisionBits​

The precision of the ADC in bits.

View Source​
Declaration
public const byte ADCPrecisionBits = 12

Methods​

CreateAnalogInputPort(IPin, Voltage?)​

Creates an analog input port using the specified pin.

View Source​
Declaration
public IAnalogInputPort CreateAnalogInputPort(IPin pin, Voltage? voltageReference = null)
Returns​

Meadow.Hardware.IAnalogInputPort: An instance of Meadow.Hardware.IAnalogInputPort configured for the specified pin.

Parameters​
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to use for analog input.
System.Nullable<Meadow.Units.Voltage>voltageReferenceOptional reference voltage for the analog input. If null, the default reference voltage will be used.

CreateAnalogInputArray(params IPin[])​

Creates an array of analog inputs from the specified pins.

View Source​
Declaration
public IAnalogInputArray CreateAnalogInputArray(params IPin[] pins)
Returns​

Meadow.Hardware.IAnalogInputArray: An instance of Meadow.Hardware.IAnalogInputArray configured with the specified pins.

Parameters​
TypeNameDescription
Meadow.Hardware.IPin[]pinsThe collection of pins to use for the analog input array.

Implements​

  • Meadow.Hardware.IAnalogInputController
  • Meadow.Hardware.IAnalogInputArrayController
  • Meadow.Hardware.IPinController