Search
  • QME Electronics

ESP32 with External ADC ADS1115 Measuring and Logging Small Signals

An Example Project Using the ESP32 with ADS1115 external with Flowcode ADS1115 Component.


The ADS1115 is a 16Bit ADC with four single ended inputs or two inputs in differential mode, it communicates with the microcontroller through I2C protocol.

ESP32 has inbuilt ADC: “ADC1 and ADC2” each with eight channels, but for some project, those ADCs’ accuracy is not satisfying.Especially when it comes to very small signals in the mV range such as from current sense resistors.Using a ADS1115 with it Programmable Gain makes it ideal for such precise ADC conversions or measurements.



Schematic

ADS1115 uses i2c (inter-integrated circuit). The i2c protocol uses two pins for communication SCL and SDA. Every connected device must have a unique address to identify itself to the host. For the ADS1115 the default address is 0x48 ( this is when the ADDR pin is connected to GND).

  • ADDR → GND : address is 0x48

  • ADDR → SDA : address is 0x4A

  • ADDR → SCL : address is 0x4B

  • ADDR → VDD : address is 0x49

Connect the GND pin of your analog signal to ESP32 GND.


Example Reading Channels AIN0 as the AINp and AIN3 as AINn pin in differential mode.

The Flowcode Component has the following macros to configure and read the different channels and mode of operation of the ADS1115 ADC.(see datasheet for bit fields and properties)



The WriteConfigurationsampleSglEnded the user write the configuration for a Single ended conversion and needs to add the parameters as required by the Component

The same for the WriteConfigurationsampleDiffMode this macro configure the ADS1115 for a Differential Conversion.

The Read Macro's Read the Conversion result 2 parameters are needed the Device I2C Address and the Gain you configured for or are using.


The Component Configures the ADS1115 to trigger the Alert Pin from high state to low state,the user can use this falling edge of the Alert Pin to trigger an Interrupt and then read the new conversion data ,Note, depending on the Sample Rate you are using there is a certain delay before the New Conversion Data is ready so if you are not using the Alert pin you need to wait the Conversion Time before reading the channels.Which is the case with the ESP32 in Flowcode example.


The procedure is

  • Write the configuration

  • Wait for the sample time to pass/ Wait For the Alert pin Interrupt

  • Read the Channel

  • Write the configuration for the next channel

  • Wait for the sample time to pass/ Wait For the Alert pin Interrupt

  • Read the channel as so on

Once you created a new Project in Flowcode place an ADS1115 Component on the 2D panel and Configure the I2C properties



Open the Component Properties and Set the I2C Channel to Software. As below and configure the SCL and SDA pins you want to use on your ESP32 board.



In the Flowchart write the Configuration as needed in our example first call the macro Initialize to initialize the ESP I2C then call the WriteConfigurationXXXX macros to configure the Channel and other properties.

We use the WriteConfigurationsampleDiffMode macro to configure AIN0 and AIN3 to differential mode,Gain 4 = 128 SPS Mode single-shot .ect


Then the code wait the required sampling time and then it reads Channel Voltage and send it out over the Serial USB link to a Plotter program.



Initialize the I2C Properties



If you use Logic Analyser you should see the below signal traces on SCL and SDA.



By changing the Voltage at AN0 and AN3, we plotted the differential Voltage on the Plotter as an example.


Differetial Voltage (AIN0 and AIN3)

Below is the Example Flowcode project files available for download and experimenting or to be used as a starting point.



ADS1115_ADC
.zip
Download ZIP • 1.30MB



10 views0 comments

Recent Posts

See All