Home » ESP32 and ADS1015 analog-to-digital converter example

ESP32 and ADS1015 analog-to-digital converter example

by shedboy71

The ADS1015 is a precision analog-to-digital converters (ADCs) with 12 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1015 are designed with precision, power, and ease of implementation in mind. The ADS1015 features an onboard reference and oscillator. Data are transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1015 operate from a single power supply ranging from 2.0V to 5.5V.

The ADS1015-Q1 device can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available that offers input ranges from the supply to as low as ±256 mV, allowing both large and small signals to be measured with high resolution. The ADS1015-Q1 device also features an input multiplexer (MUX) that provides two differential or four single-ended inputs.

The ADS1015-Q1 device operates either in continuous conversion mode or a single-shot mode that automatically powers down after a conversion and greatly reduces current consumption during idle periods

ads1015

ads1015

Parts Required

Here are the parts I used

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

Name Link
ESP32
ADS1015
Connecting cables

Schematics

 

esp32 and ads1015

esp32 and ads1015

 

Code

In this example you need the Adafruit ADS1015 library from https://github.com/adafruit/Adafruit_ADS1X15

 

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1015 ads;     /* Use thi for the 12-bit version */

void setup(void) 
{
  Serial.begin(9600);
  Serial.println("Getting single-ended readings from AIN0..3");
  ads.begin();
}

void loop(void) 
{
  int16_t adc0, adc1, adc2, adc3;

  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);
  Serial.print("AIN0: "); 
  Serial.println(adc0);
  Serial.print("AIN1: "); 
  Serial.println(adc1);
  Serial.print("AIN2: "); 
  Serial.println(adc2);
  Serial.print("AIN3: "); 
  Serial.println(adc3);
  Serial.println(" ");
  
  delay(1000);
}

 

Output

Open the serial monitor and you should see something like this

AIN0: 1101
AIN1: 0
AIN2: 337
AIN3: 609

AIN0: 1101
AIN1: 245
AIN2: 207
AIN3: 165

AIN0: 1101
AIN1: 229
AIN2: 0
AIN3: 669

AIN0: 1101
AIN1: 262
AIN2: 252
AIN3: 358

AIN0: 1102
AIN1: 293
AIN2: 241
AIN3: 0

 

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.