Package com.diozero.devices
Class Ads1x15
java.lang.Object
com.diozero.internal.spi.AbstractDeviceFactory
com.diozero.devices.Ads1x15
- All Implemented Interfaces:
DeviceInterface
,AnalogInputDeviceFactoryInterface
,DeviceFactoryInterface
,AutoCloseable
public class Ads1x15 extends AbstractDeviceFactory implements AnalogInputDeviceFactoryInterface, DeviceInterface
ADS1115 Datasheet: https://www.ti.com/lit/ds/symlink/ads1115.pdf ADS1015
Datasheet: https://www.ti.com/lit/ds/symlink/ads1015.pdf
Device | Resolution | Max Sample Rate | # Channels | Interface | Features ADS1115 | 16 | 860 | 2 (4) | I2C | Comparator ADS1114 | 16 | 860 | 1 (1) | I2C | Comparator ADS1015 | 12 | 3300 | 2 (4) | I2C | Comparator ADS1014 | 12 | 3300 | 1 (1) | I2C | Comparator ADS1118 | 16 | 860 | 2 (4) | SPI | Temp. sensor ADS1018 | 12 | 3300 | 2 (4) | SPI | Temp. sensorWiring:
A3 | A2 | A1 | A0 | ALERT | ADDR | SDA | SCL | G | VADDR (In) - I2C slave address select ALERT (Out) - Comparator output or conversion ready (ADS1114 and ADS1115 only) ADDR - can be connected to GND, VDD, SDA, or SCL, allowing for four different addresses to be selected
GND | 0b01001000 (0x48) VDD | 0b01001001 (0x49) SDA | 0b01001010 (0x4a) SCL | 0b01001011 (0x4b)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Ads1x15.Address
I2C address configurationstatic class
Ads1x15.Ads1015DataRate
Number of samples per secondstatic class
Ads1x15.Ads1115DataRate
Number of samples per secondstatic class
Ads1x15.ComparatorMode
static class
Ads1x15.ComparatorPolarity
static class
Ads1x15.ComparatorQueue
Comparator queue configurationstatic class
Ads1x15.Mode
Read mode - continuous or singlestatic class
Ads1x15.Model
static class
Ads1x15.PgaConfig
Programmable Gain Amplifier configuration. -
Field Summary
Fields inherited from class com.diozero.internal.spi.AbstractDeviceFactory
closed, deviceStates
-
Constructor Summary
Constructors Constructor Description Ads1x15(int controller, Ads1x15.Address address, Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1015DataRate ads1015DataRate)
Ads1x15(int controller, Ads1x15.Address address, Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1115DataRate adsDataRate)
Ads1x15(Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1015DataRate dataRate)
Ads1x15(Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1115DataRate dataRate)
-
Method Summary
Modifier and Type Method Description void
close()
Close this device factory including all devices that have been provisioned by it.AnalogInputDeviceInterface
createAnalogInputDevice(String key, PinInfo pinInfo)
BoardPinInfo
getBoardPinInfo()
Get information about pins that can be provisioned by this device factory.int
getDataRate()
float
getLastResult()
Ads1x15.Model
getModel()
String
getName()
Get the name of this device factoryAds1x15.PgaConfig
getPgaConfig()
float
getValue(int adcNumber)
float
getVRef()
static void
main(String[] args)
protected void
setConfig(int adcNumber)
void
setContinousMode(DigitalInputDevice readyPin, int adcNumber, FloatConsumer callback)
void
setDataRate(Ads1x15.Ads1015DataRate ads1015DataRate)
void
setDataRate(Ads1x15.Ads1115DataRate ads1115DataRate)
void
setSingleMode(int adcNumber)
Methods inherited from class com.diozero.internal.spi.AbstractDeviceFactory
createI2CKey, createPinKey, createSerialKey, createSpiKey, deviceClosed, deviceOpened, getDevice, isClosed, isDeviceOpened, reopen
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.diozero.internal.spi.AnalogInputDeviceFactoryInterface
provisionAnalogInputDevice
Methods inherited from interface com.diozero.internal.spi.DeviceFactoryInterface
createI2CKey, createPinKey, createSerialKey, createSpiKey, deviceClosed, deviceOpened, getDevice, isClosed, isDeviceOpened, reopen, start
-
Constructor Details
-
Ads1x15
- Parameters:
pgaConfig
- Programmable Gain Amplifier configuration - make sure this is set correctly and that the ADC input voltage does not exceed this valuedataRate
- Data read frequency (Hz)
-
Ads1x15
public Ads1x15(int controller, Ads1x15.Address address, Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1115DataRate adsDataRate) -
Ads1x15
-
Ads1x15
public Ads1x15(int controller, Ads1x15.Address address, Ads1x15.PgaConfig pgaConfig, Ads1x15.Ads1015DataRate ads1015DataRate)
-
-
Method Details
-
getName
Description copied from interface:DeviceFactoryInterface
Get the name of this device factory- Specified by:
getName
in interfaceDeviceFactoryInterface
- Returns:
- the name of this device factory
-
getBoardPinInfo
Description copied from interface:DeviceFactoryInterface
Get information about pins that can be provisioned by this device factory.- Specified by:
getBoardPinInfo
in interfaceDeviceFactoryInterface
- Returns:
- board pin info instance for this device factory
-
createAnalogInputDevice
- Specified by:
createAnalogInputDevice
in interfaceAnalogInputDeviceFactoryInterface
-
getVRef
public float getVRef()- Specified by:
getVRef
in interfaceAnalogInputDeviceFactoryInterface
-
close
public void close()Description copied from interface:DeviceFactoryInterface
Close this device factory including all devices that have been provisioned by it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceFactoryInterface
- Specified by:
close
in interfaceDeviceInterface
- Overrides:
close
in classAbstractDeviceFactory
-
getModel
-
getPgaConfig
-
getDataRate
public int getDataRate() -
setDataRate
-
setDataRate
-
setContinousMode
-
getLastResult
public float getLastResult() -
setSingleMode
public void setSingleMode(int adcNumber) -
getValue
public float getValue(int adcNumber) -
setConfig
protected void setConfig(int adcNumber) -
main
-