arduino four ADS1115 Modules
動機:
我需要使用8通道 16 bit ADS 所以將兩片ADS1115結合軟 體:
1.Arduino IDE 1.8.12.library:https://github.com/adafruit/Adafruit_ADS1X15
準備模組:
1.ads1115模組(使用上要特別注意VCC & GND)使用前請記得去看一下ADS1115的資料手冊
一共有4個address 所以代表最多可以併到4個
接線圖
程式碼
這裡只打上要注意的地方
//********開啟範例後的樣子**********//
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
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, 0.1875mV/ADS1115)");
ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 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);
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_ADS1115 ads1(0x48); /* Use this for the 16-bit version */
Adafruit_ADS1115 ads2(0x49);
Adafruit_ADS1115 ads3(0x4A);
Adafruit_ADS1115 ads4(0x4B);
你好!很高兴看到你的博客,我也喜欢换arduino,esp。希望能和你认识交流!
回覆刪除歡迎交流!
刪除