Specification
ADS115 아날로그 4채널 (A0 ~ A3) I2C 변환을 지원하는 모듈입니다.
아두이노 기반 기본 예제입니다.
Adafruit 라이브러리를 사용합니다.
#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
// i2c scanner를 이용하여 (0X49) address를 먼저 확인해주시기 바랍니다.
void setup(void)
{
ads1015.begin(); // Initialize ads1015
ads1115.begin(); // Initialize ads1115
}
Case1: Single Ended Conversio
uint16_t readADC_SingleEnded(uint8_t channel);
#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);
}
Case2: Differential Conversio
int16_t readADC_Differential_0_1(void);
Perform a differential analog to digital conversion on the voltage between channels 0 and 1.
int16_t readADC_Differential_2_3(void);
Perform a differential analog to digital conversion on the voltage between channels 2 and 3.
#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);
}