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 name | ADS1115_WE |
|---|---|
| Author | Wolfgang Ewald |
| Include | #include <ADS1115_WE.h>#include <ADS1015_WE.h> |
| Boards | every board Mokxi compiles for but ATtiny85 |
| In the simulator | Simulated: it runs against the part the way it does on the bench. |
| Parts it drives | Sixteen-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.
- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi
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.
#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
Keep going
Try ADS1115_WE without installing anything
Open the example, change the sketch, and keep your version in a free account.