ADS1015 with ESP8266 for Multiple Analog Sensors, Analog Extender

(Last Updated On: September 14, 2021)

ADS1015 and ESP8266, Description:

ads1015

ADS1015 with ESP8266 nodeMCU- The NodeMCU ESP8266 is no doubt an amazing microcontroller board developed by the Espressif systems. It has multiple digital and PWM pins. You can interface SPI, Serial, I2C, and One-wire supported devices just like the Arduino boards. If you compare the NodeMCU ESP8266 with the ESP32 WiFi + Bluetooth Module and Arduino boards you will find that the NodeMCU ESP8266 WiFi module has got only one Analog Pin A0. While in ESP32 and Arduino boards we have got multiple analog pins. Now you have got three options.

  1. You can use ESP32 WiFi + Bluetooth module which has got multiple Analog pins and you can do all the same things that you can do with the Nodemcu ESP8266.
  2. You can use the ADS1015 or ADS1115 analog to digital converter to increase the number of Analog pins.
  3. You can use Arduino with Nodemcu ESP8266 to increase the number of Analog pins, which I will not recommend. As this will increase the project overall cost and will also increase the coding, and it seems quite impractical unless you are working on a very complicated project.

So, my recommendation is you should use the ESP32 WiFi + Bluetooth module. But if still you want to use the NodeMCU ESP8266 then I highly recommend using the Analog pins extender board like the ADS1015 or the ADS1115. The ADS1015 is a 12-bit Analog to Digital converter while the ADS1115 is a 16-bit Analog to digital converter. It really doesn’t matter whether you want to use the ADS1015 or the ADS1115, both the modules have got the same pins and are programmed in the same exact way.


So, in this tutorial, you will learn how to use the ADS1015 12-bit i2c supported Analog to digital converter with the Nodemcu ESP8266 to increase the number of Analog pins so that multiple analog sensors can be interfaced with the Nodemcu ESP8266. For the demonstration purposes I have connected 3 potentiometers which I am using as the sensors which of course you can replace with other analog sensors. I started with a very basic program and displayed the values of all the three potentiometers on the Serial monitor.

ads1015

I further modified the code and this time I displayed the values of all the three analog sensors on the I2C supported 128×64 Oled Display Module.

ads1015

The ADS1015 and the Oled display module both supports I2C communication, which means using only two pins D1 and D2 of the NodeMCU ESP8266 I can communicate with both the modules.

In this tutorial we will cover,

  1. ADS1015 Analog to digital Converter Pinout and technical specifications.
  2. Complete circuit diagram explanation.
  3. ADS1015 Library installation
  4. Program explanation, and finally
  5. Testing

Without any further delay, let’s get started!!!



Amazon Purchase Links:

 

Nodemcu ESP8266 WiFi Module:

LM7805 Voltage Regulator:

ADS1015 Analog to Digital Converter

SSD1306 128×64 Oled i2c display Module

ESP32 Wifi + Bluetooth Module:

DC Female Power Jack:

Other Tools and Components:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

ADS1015 Analog to Digital Converter, ADC:

ads1015

The ADS1013, ADS1014, and ADS1015 are precision analog to digital converters with 12 bits of resolution used for extending the analog pins. This is an i2c supported device and can be easily operated from a single power supply ranging from 2.0V to 5.5V. Due to this wide range of input voltages the ADS1015 can be easily used with 3.3V and 5V compatible controller boards. The ADS1015 can perform conversions at rates up to 3300 samples per seconds (SPS). It has an onboard PGA that offers input ranges from the supply to as low as ±256mV, this allows both the large and small signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two differential or four single-ended inputs. The ADS1015 can be operated either in continuous conversion mode or in a single-shot mode that automatically powers down after a conversion and greatly reduces the current consumption during idle periods.


ADS1015 Pinout:

ads1015

The ADS1015 has a total of 10 headers clearly labeled as V, G, SCL, SDA, ADDRRESS, ALERT, A0, A1, A2, and A3. So, a total of 4 analog sensors can be connected with this analog to digital converter. Now, let’s take a look at the complete circuit diagram.

Download: ADS1015 Datasheet

ADS1015 Interfacing with NodeMCU ESP8266, Circuit Diagram:

ads1015

The 5V regulated power supply based on the LM7805 voltage regulator is used to power up the NodeMCU ESP8266 WiFi module. The output of the regulator is connected with the VIN pin of the NodeMCU module. J1 is the input female power jack and this is where we connect the voltage source. You can connect any voltage source between 7 to 25 volts. Two 470uf capacitors are connected at the input and output sides of the voltage regulator, these are the decoupling capacitors.

The VDD and GND pins of the ADS1015 are connected with the 3.3V and GND pins of the NodeMCU module. The SCL and SDA pins of the ADS1015 are connected with the D1 and D2 pins which are the SCL and SDA pins. These pins are also connected with the SCL and SDA pins of the Oled display module. So using only two pins D1 and D2 we can communicate with both the modules as both the modules supports I2C communication. The address pin of the ADS1015 Analog to digital Converter module is connected with the ground. The Alert pin is not connected. The Analog pins A0 to A2 are connected with the middle legs of all the three potentiometers.

ads1015

This is the NodeMCU ESP8266 development board which I have been using for making IoT based projects. If you want to learn how to make this development board then watch my tutorial. I also added female headers for connecting the 128×64 SSD1306 Oled display module.  The ADS1015 module is also provided with the male headers. I carefully completed the soldering.

ads1015

I started off by connecting the Oled display module and next I inserted the ADS1015 Analog to digital converter into the breadboard and completed my connections as per the circuit diagram already explained.

ads1015

This is how everything looks after the final connections. Now, we are ready for the programming.


ADS1015 Library installation:

Before you start the programming, you will need to install the Adafruit_ADS1015.h library. While the Arduino IDE is open, click on the Sketch menu > Include Library > Manage Libraries.

ads1015

Once you click on the Manage Libraries then wait for a while, it may take longer if your internet speed is low. Anyhow, after all the loading is done then you can search for the ads and install.

ads1015

Now you can close the Library Manager. Close the Arduino IDE too and then reopen the Arduino IDE this will load the ads1015 library. Our library installation is completed and also our hardware is ready. Now, it’s time to take a look at the programming.

Download: Wire.h library.


ADS1015 ESP8266 Programming:

ADS1015 Code Explanation:

If you are using the ADS1115 then simply uncomment

// Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */

this line and comment this line of code. But as I am using the ADS1015 Analog to digital converter, so I simply selected this

Adafruit_ADS1015 ads; line of code.

The next most important thing is the gain selection.

// ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default

ads.setGain(GAIN_ONE);          // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV                         ads.setGain(GAIN_TWO);              // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV

// ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV

// ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV

// ads.setGain(GAIN_SIXTEEN); // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV

If you are dealing with 5v sensors then select ads.setGain(GAIN_ONE);// 1x gain. If you are dealing with 3.3V sensors then select ads.setGain(GAIN_TWO);. As you can see it’s already selected. Let’s say if you select the 2x gain which can handle voltages between ±2.048 and if you connect the sensor with 3.3V or 5V it will damage the ADS1015. For each gain you can see the voltage range. If you are using a sensor and you are sure its output voltage won’t exceed ±2.048V then go ahead and activate this line of code. But in my case I am powering up the Potentiometers using 3.3Volts and I am sure by rotating the knob of the potentiometer the voltage can be between 0 and 3.3V so for this the best choice is the 1x gain which has the voltage range between ±4.096V.

This is a very basic program; you can read the analog sensors and then display the values on the Serial monitor. For the practical demonstration watch video given at the end of this article. After successfully displaying the values on the Serial monitor. Next, I modified the code.

You will need to download the following three libraries needed for the Oled display module.

Adafruit_GFX.h

Adafruit_SSD1306.h

SimpleTimer.h


ADS1015 and Oled display programming using ESP8266:

This is the same exact program that reads the multiple analog sensors and displays the values on the Serial monitor and also on the Oled display module.


Watch Video Tutorial:

 

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: