AD Converter ADS1115


The Analog Digital Converter ADS1115 is a template class, that you can use in your own Java-project. The ADS1115 device is a precision, low-power, 16-bit, I2C-compatible, analog-to-digital converter (ADCs). The ADS1115 device incorporates a low-drift voltage reference and an oscillator as well as a programmable gain amplifier (PGA) and a digital comparator. These features, along with a wide operating supply range, makes the ADS1115 well suited for power- and space-constrained, sensor measurement applications.

The ADS1115 performs conversions at data rates up to 860 samples per second (SPS). The PGA offers input ranges from ±256 mV to ±6.144 V, allowing precise large- and small-signal measurements. The ADS1115 features an input multiplexer (MUX) that allows two differential or four single-ended input measurements. Use the digital comparator for under- and overvoltage detection.

The ADS1115 operates in either continuous-conversion mode or single-shot mode. The device is automatically powered down after one conversion in single-shot mode. Therefore, power consumption is significantly reduced during idle periods.

The Template Class gives you the possibility of a single shot recording, or to measure it continuously.


ADS1115 Layout


A simple example on how to use the AD converter from the Hardware-Catalog :

The PI4J-Context must add the LinuxFsI2CProvider.newInstance() Provider, which is explained under LinuxFS

pi4j = Pi4J.newContextBuilder()
	.add(new RaspberryPiPlatform() {
		protected String[] getProviders() {
			return new String[]{};

When the right context is loaded, you can use the ADS1115 like following:

System.out.println("ADS1115 test started ...");
System.out.println("read all channels in continuous mode");
//initialize the component
ADS1115 ads1115 = new ADS1115(pi4j, 0x1, ADS1115.GAIN.GAIN_4_096V, ADS1115.ADDRESS.GND, 4);

// Register event handlers to print a message on value change
ads1115.setConsumerSlowReadChannel0((value) -> {
	System.out.println("The actual value from channel 0 is: " + String.format("%.3f", value) + "voltage.");
ads1115.setConsumerSlowReadChannel1((value) -> {
	System.out.println("The actual value from channel 1 is: " + String.format("%.3f", value) + "voltage.");
ads1115.setConsumerSlowReadChannel2((value) -> {
	System.out.println("The actual value from channel 2 is: " + String.format("%.3f", value) + "voltage.");
ads1115.setConsumerSlowReadChannel3((value) -> {
	System.out.println("The actual value from channel 3 is: " + String.format("%.3f", value) + "voltage.");

//start continuous measuring
ads1115.startSlowContinuousReadingAllChannels(0.1, 10);

// Wait while handling events before exiting

//stop continuous measuring

//deregister all handlers


//end test
System.out.println("ADS1115 test done");

Further application

The class is implemented in the sample project Theremin.

Further project ideas

  • An application, which detects the deflection of an analog joystick.
  • An application, that determines the current position of a potentiometer.