Skip to main content

Meadow.Foundation.ICs.ADC.Ads1015

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

Code Example

private Ads1015 adc;

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

adc = new Ads1015(
Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.FastPlus),
Ads1x15Base.Addresses.Default,
Ads1x15Base.MeasureMode.Continuous,
Ads1x15Base.ChannelSetting.A0SingleEnded,
Ads1015.SampleRateSetting.Sps3300);

adc.Gain = Ads1x15Base.FsrGain.TwoThirds;

var observer = Ads1015.CreateObserver(
handler: result =>
{
Resolver.Log.Info($"Observer: Voltage changed by threshold; new temp: {result.New.Volts:N2}C, old: {result.Old?.Volts:N2}C");
},
filter: result =>
{
if (result.Old is { } old)
{
// TODO: you can check to see if the voltage change is > your desired threshold.
// here we look to see if it's > 0.5V
return Math.Abs(result.New.Volts - old.Volts) > 0.5d;
}
return false;
}
);
adc.Subscribe(observer);

adc.Updated += (sender, result) =>
{
Resolver.Log.Info($" Voltage: {result.New.Volts:N2}V");
};

await adc.Read();
}

Sample project(s) available on GitHub

Wiring Example

To wire a Ads1015 to your Meadow board, connect the following:

Ads1015Meadow Pin
GNDGND
VCC3V3
SCLD08 (SCL Pin)
SDAD07 (SDA Pin)