118 lines
3.3 KiB
Plaintext
118 lines
3.3 KiB
Plaintext
#include <Wire.h>
|
|
#include <Adafruit_ADS1015.h>
|
|
|
|
Adafruit_ADS1015 ads1015; // Construct an ads1015 at the default address: 0x48
|
|
Adafruit_ADS1115 ads1115(0x49); // construct an ads1115 at address 0x49
|
|
|
|
void setup(void)
|
|
{
|
|
ads1015.begin(); // Initialize ads1015
|
|
ads1115.begin(); // Initialize ads1115
|
|
}
|
|
-----------------------
|
|
#include <Wire.h>
|
|
#include <Adafruit_ADS1015.h>
|
|
|
|
Adafruit_ADS1015 ads1015;
|
|
|
|
void setup(void)
|
|
{
|
|
Serial.begin(9600);
|
|
Serial.println("Hello!");
|
|
|
|
Serial.println("Getting single-ended readings from AIN0..3");
|
|
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
|
|
ads1015.begin();
|
|
}
|
|
|
|
void loop(void)
|
|
{
|
|
int16_t adc0, adc1, adc2, adc3;
|
|
|
|
adc0 = ads1015.readADC_SingleEnded(0);
|
|
adc1 = ads1015.readADC_SingleEnded(1);
|
|
adc2 = ads1015.readADC_SingleEnded(2);
|
|
adc3 = ads1015.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);
|
|
}
|
|
----------------------
|
|
#include <Wire.h>
|
|
#include <Adafruit_ADS1015.h>
|
|
|
|
Adafruit_ADS1015 ads1015;
|
|
|
|
void setup(void)
|
|
{
|
|
Serial.begin(9600);
|
|
Serial.println("Hello!");
|
|
|
|
Serial.println("Getting differential reading from AIN0 (P) and AIN1 (N)");
|
|
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
|
|
ads1015.begin();
|
|
}
|
|
|
|
void loop(void)
|
|
{
|
|
int16_t results;
|
|
|
|
results = ads1015.readADC_Differential_0_1();
|
|
Serial.print("Differential: "); Serial.print(results); Serial.print("("); Serial.print(results * 3); Serial.println("mV)");
|
|
|
|
delay(1000);
|
|
}
|
|
------------------------
|
|
ads1015.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV (default)
|
|
|
|
// ads1015.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
|
|
// ads1015.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV
|
|
// ads1015.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV
|
|
// ads1015.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV
|
|
// ads1015.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV
|
|
// Set the gain to 4x, for an input range of +/- 1.024V
|
|
|
|
// 1-bit = 0.5V on the ADS1015 with this gain setting
|
|
ads1015.setGain(GAIN_FOUR);
|
|
------------------------
|
|
#include <Wire.h>
|
|
#include <Adafruit_ADS1015.h>
|
|
|
|
Adafruit_ADS1115 ads;
|
|
const float multiplier = 0.1875F;
|
|
|
|
void setup(void)
|
|
{
|
|
Serial.begin(9600);
|
|
|
|
// Descomentar el que interese
|
|
// 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.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 * multiplier);
|
|
Serial.print("AIN1: "); Serial.println(adc1 * multiplier);
|
|
Serial.print("AIN2: "); Serial.println(adc2 * multiplier);
|
|
Serial.print("AIN3: "); Serial.println(adc3 * multiplier);
|
|
Serial.println(" ");
|
|
|
|
delay(1000);
|
|
} |