FluxBench.AIShared project · read-only

ADS1115 Precision Voltmeter

ESP32 DevKit (WROOM-32)·Arduino C++·Updated Jul 27, 2026·by FluxBench TeamIncludes Lab + Schematic

A 16-bit bench voltmeter: an ADS1115 precision ADC is read over I2C with the Adafruit ADS1X15 library (GAIN_ONE, 125 microvolts per bit), and the voltage on channel A0 is shown in big digits on a 128x64 OLED with a live bar graph and a LOW / OK / HIGH zone word. Click the ADS1115 on the bench and drag its A0 slider while the sketch runs: the display follows in real time, and the red LED on GPIO 4 lights as an over-voltage warning above 3.00 V.

sketch.ino
// ADS1115 Precision Voltmeter - a 16-bit bench voltmeter you can drive by hand.
// Click the ADS1115 on the bench and drag its A0 slider while the sketch runs -
// the OLED shows the voltage in big digits with a bar graph, and the red LED
// on GPIO 4 lights above 3.00 V as an over-voltage warning.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_ADS1X15.h>

#define WARN_PIN 4
#define WARN_VOLTS 3.0   // over-voltage warning threshold

Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_ADS1115 ads;

void setup() {
  Serial.begin(115200);
  pinMode(WARN_PIN, OUTPUT);
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.display();
  if (!ads.begin()) {
    Serial.println("ADS1115 not found - check wiring");
  }
  ads.setGain(GAIN_ONE);  // +/-4.096 V range, 125 uV per bit
  Serial.println("Voltmeter ready - drag the ADS1115 A0 slider");
}

void loop() {
  int16_t raw = ads.readADC_SingleEnded(0);
  float v = ads.computeVolts(raw);

  bool warn = v > WARN_VOLTS;
  const char* zone = "OK";
  if (v < 0.5) zone = "LOW";
  else if (warn) zone = "HIGH";
  digitalWrite(WARN_PIN, warn ? HIGH : LOW);

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.print("ADS1115 VOLTMETER");
  display.setTextSize(3);
  display.setCursor(0, 12);
  display.print(v, 2);
  display.setTextSize(1);
  display.print(" V");
  int bar = (int)(v / 3.3 * 128.0);
  if (bar > 128) bar = 128;
  if (bar < 0) bar = 0;
  display.fillRect(0, 42, bar, 8, SSD1306_WHITE);
  display.drawRect(0, 42, 128, 8, SSD1306_WHITE);
  display.setCursor(0, 54);
  display.print(zone);
  if (warn) display.print("  OVER-VOLTAGE!");
  display.display();

  Serial.print("raw=");
  Serial.print(raw);
  Serial.print("  ");
  Serial.print(v * 1000.0, 0);
  Serial.print(" mV  ");
  Serial.println(zone);
  delay(500);
}

Built with FluxBench.AI — the AI workbench for embedded projects.