Arduino library · Sensors

ADS1115_WE: an example that runs

Yes. You can use the ADS1115_WE library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Sixteen-bit ADC, ADS1115). The example below, "Two inputs of an ADS1115 in single-shot mode with ADS1115_WE", runs on the Arduino Uno R3.

Built in on Mokxi: #include <ADS1115_WE.h> and it builds, with nothing to install. Free, and no account needed.

What ADS1115_WE does

The ADS1115 and ADS1015 by channel pair, range and rate: setCompareChannels(), startSingleMeasurement(), isBusy(), getResult_V(), the auto range and the remembered channel ranges. That is what ADS1115_WE, by Wolfgang Ewald, covers. The sketch below uses it on the Arduino Uno: “Two inputs of an ADS1115 in single-shot mode with ADS1115_WE”.

Wolfgang Ewald's ADS1115_WE library, for the ADS1115 sixteen-bit ADC and the twelve-bit ADS1015.

In ADS1115_CONTINUOUS mode setCompareChannels() waits for two conversions on the new channel, as upstream does, so getResult_V() right after it is that channel's. A result in volts is the count over 32768 times the range.

The calls follow release 1.5.8 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.

Library Manager nameADS1115_WE
AuthorWolfgang Ewald
Include#include <ADS1115_WE.h>
#include <ADS1015_WE.h>
Boardsevery board Mokxi compiles for but ATtiny85
In the simulatorSimulated: it runs against the part the way it does on the bench.
Parts it drivesSixteen-bit ADC, ADS1115

Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <ADS1115_WE.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "ADS1115_WE" by Wolfgang Ewald from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add ADS1115_WE to lib_deps in PlatformIO. Mokxi follows the calls of release 1.5.8, so a sketch written here builds there too.

What to know in the simulator: The alert settings reach the chip; the part does not drive ALRT. The part is an ADS1115, so ADS1015_WE reads its sixteen-bit counts.

The calls you will use

In the order a sketch meets them.

ADS1115_WE adc

Makes adc, the ADS1115_WE object the calls below are made on.

adc.setCompareChannels(channel)

Sets the compare channels to the value you pass in.

adc.isBusy()

Returns true or false for "is busy".

adc.getResult_V()

Returns Result_V as a decimal number.

adc.init()

Starts it up and returns true if it started, false if it did not. Call it once in setup().

Example: Two inputs of an ADS1115 in single-shot mode with ADS1115_WE

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3
#include <ADS1115_WE.h>
#include <Wire.h>

#define I2C_ADDRESS 0x48

ADS1115_WE adc = ADS1115_WE(I2C_ADDRESS);

float readChannel(ADS1115_MUX channel) {
  adc.setCompareChannels(channel);
  adc.startSingleMeasurement();
  while (adc.isBusy()) {}
  return adc.getResult_V();
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
  if (!adc.init()) {
    Serial.println("ADS1115 not connected!");
  }
  adc.setVoltageRange_mV(ADS1115_RANGE_6144);
  Serial.println("ADS1115 Example Sketch - Single Shot Mode");
}

void loop() {
  Serial.print("Channel 0 [V]: ");
  Serial.println(readChannel(ADS1115_COMP_0_GND), 3);
  Serial.print("Channel 1 [V]: ");
  Serial.println(readChannel(ADS1115_COMP_1_GND), 3);
  delay(1000);
}

Wiring

  • Arduino Uno R3 A4 to Sixteen-bit ADC, ADS1115 SDA
  • Arduino Uno R3 A5 to Sixteen-bit ADC, ADS1115 SCL
  • Arduino Uno R3 5V to Sixteen-bit ADC, ADS1115 VDD
  • Arduino Uno R3 GND to Sixteen-bit ADC, ADS1115 GND
  • Arduino Uno R3 3V3 to Sixteen-bit ADC, ADS1115 A0
  • Arduino Uno R3 GND to Sixteen-bit ADC, ADS1115 A1

Open it in the editor, wired and ready to run

Try ADS1115_WE without installing anything

Open the example, change the sketch, and keep your version in a free account.