Busca en nuestro Blog. Encontrarás múltiples aplicaciones, soluciones, ejemplos de código. Navega utilizando la nube de etiquetas o busca utilizando criterios específicos
Analogical - Digital Converter board for industrial Arduino
ADS1115 16 bits ADC precision analog-to-digital converter with 16-bits of resolution
Introduction
In this post we talk about the Analogic-Digital Converter (ADC) 16-bits module ADS1115 for Arduino industrial automation controller. You will find some information about the module and the way to connect with Arduino automation and read analog values.
Requeriments
M-Duino >> or Ardbox >> family
ADS1115
The ADS1115 is a precision analog-to-digital converter with 16-bits of resolution offered in an ultra-small, leadless WFN_10 package or an MSOP-10 package. It is designed with precision, power and ease of implementation in mind. Data are transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected.
Technical features
Parameter | Value | Conditions |
Power-Supply Voltage | 2.0 to 5.5 V | - |
Storage Temperature | -60 to +150 ºC | - |
Specified Temperature | -40 to +125 ºC | - |
Analog Input Voltage | GND to VCC V | - |
Resolution | 16 Bits | - |
Data Rate (DR) | 8, 16, 32, 64, 128, 250, 475, 860 SPS | - |
Data Rate Variation | -10 to 10 % | All data rates |
Supply Current | 150 - 200 uA | Operating current at 25 ºC |
Power dissipation | VDD = 5.0, 3.3, 2.0 V | 0.9, 0.5, 0.3 mW |
Connections
According to Hardware Configuration (page 11) of the ADS115 Datasheet. The connections are the following:
Arduino Mega
M-Duino PLC
Arduino PLC Ethernet >>
Library
To be able to read the Analog Pins values in a more confortable and easy way, we advice to use the Adafruit ADS1115 library. Here you gave the link: Adafruit_ADS1115.
Once you have downloaded the .zip file, in the Arduino IDE go to Sketch -> Include Library -> Add .ZIP Library... You will find the .zip file Adafruit_ADS1X15-master in the Downloads folder. Now we can include the Adafruit_ADS1015.h header in our programs in oder to use the functions that we have available.
Code
The same code for Arduino Mega or M-Duino.
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads;
const float multiplier = 0.0001875F;
void setup() {
Serial.begin(9600);
// There are different GAINs
// ads.setGain(GAIN_TWOTHIRDS); +/- 6.144V 1 bit = 0.1875mV (default)
// ads.setGain(GAIN_ONE); +/- 4.096V 1 bit = 0.125mV
// ads.setGain(GAIN_TWO); +/- 2.048V 1 bit = 0.0625mV
// ads.setGain(GAIN_FOUR); +/- 1.024V 1 bit = 0.03125mV
// ads.setGain(GAIN_EIGHT); +/- 0.512V 1 bit = 0.015625mV
// ads.setGain(GAIN_SIXTEEN); +/- 0.256V 1 bit = 0.0078125mV
ads.setGain(GAIN_TWOTHIRDS);
ads.begin();
}
void loop() {
int16_t adc0;
adc0 = ads.readADC_SingleEnded(0);
Serial.print("Analog 0: ");
// Read value from 0 to 32767 from 16 bits register, so it's necessary to convert to real value
// by multiplying by 0.0001875 (GAIN)
Serial.println(adc0 * multiplier);
delay(1000);
}
// There are different GAINs // ads.setGain(GAIN_TWOTHIRDS); +/- 6.144V 1 bit = 0.1875mV (default) // ads.setGain(GAIN_ONE); +/- 4.096V 1 bit = 0.125mV // ads.setGain(GAIN_TWO); +/- 2.048V 1 bit = 0.0625mV // ads.setGain(GAIN_FOUR); +/- 1.024V 1 bit = 0.03125mV // ads.setGain(GAIN_EIGHT); +/- 0.512V 1 bit = 0.015625mV // ads.setGain(GAIN_SIXTEEN); +/- 0.256V 1 bit = 0.0078125mV
ads.setGain(GAIN_TWOTHIRDS); ads.begin(); } void loop() { int16_t adc0; adc0 = ads.readADC_SingleEnded(0); Serial.print("Analog 0: ");
// Read value from 0 to 32767 from 16 bits register, so it's necessary to convert to real value
// by multiplying by 0.0001875 (GAIN)
Serial.println(adc0 * multiplier); delay(1000); }
To test the program we connected the Power Supply to A0 at 2.5 V. That's the result in the Serial Monitor:
With multiplier = 1. Decimal value of the 16 bit register.
With Multiplier = 0.0001875F. Decimal value of the 16 bit register multiplied by the appropriate multiplier to get the real value representation in V units.
It is also possible to use the the module ADS1115 to Raspberry Pi.