I recently started a project using Arduino UNO and the ADS1115 ADC module (https://learn.adafruit.com/adafruit-4-c ... -breakouts) followed all instructions. Everything worked perfectly according to the documentation provided. I've been able to log (SD loggershield) differential voltages from pressure transducers MPX2010DP using differential channels A0_A1 and A2_A3 with one ADS1115 ADC using default address 0x48 using ADR-GND pins. When trying to read the data from another two pressure transducers with a second ADS11115 ADC unit and setting the address 0x49, using ADR-VDD pins and read with the two differential channels of the second ADS1115 unit A0_A1 and A2_A3. And defining the addresses as with
ads.begin(0x48);
ads.begin(0x49);
according to, (https://learn.adafruit.com/adafruit-4-c ... -2974130-2), quoted in an earlier thread (viewtopic.php?f=25&t=181255&p=881401&hi ... 15#p881401)
The logging collapses after a few minutes of logging
¿How do I specify each ADC unit address and read the data from each distinct ADS1115 unit?
The documentation indicates the possible ADC address setting but no information or code related to several ADS1115 ADC units working a the same time.
I need to log up to eight pressure transducers and I intend to use four ADS1115 modules.
Any help is welcome!!
Best regards
AGT
Code: Select all
#include <SD.h>
#include <Wire.h>
// #include <Time.h>
#include <DS1307RTC.h>
#include <Adafruit_ADS1X15.h>
#include <SPI.h>
/// Time variables
uint32_t UnixTime; // linuxtime RTC
long int YearInMillenium;
long int MonthInYear;
long int DayInMonth;
long int HoursInDay;
long int MinutesInHour;
long int SecondsInMinute;
//long int SecondsInDay;
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
const int chipSelect = 10;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while (1);
}
// RTC and Time
setSyncProvider(RTC.get);
UnixTime = now();
YearInMillenium = year();
MonthInYear = month();
DayInMonth = day();
HoursInDay = hour();
MinutesInHour = minute();
SecondsInMinute = second();
Serial.println("Unixtime (s), Time (Y/M/D H:M:S), Dv1 (mV), Dv2 (mV), Vin");
ads.begin(0x48);
ads.begin(0x49);
} // End setup
// #############################################################
void loop() {
// Reads the clock to the Arduino and calculates time variables
UnixTime = now();
setSyncProvider(RTC.get);
YearInMillenium = year();
MonthInYear = month();
DayInMonth = day();
HoursInDay = hour();
MinutesInHour = minute();
SecondsInMinute = second();
// Starting ADS1115_adc1
ads.begin(0x48);
ads.setGain(GAIN_SIXTEEN); // setting the gain 16x gain for adc1 +/- 0.256V 1 bit = 0.125mV 0.0078125mV
int16_t results;
int16_t results2;
results = ads.readADC_Differential_0_1();
results2 = ads.readADC_Differential_2_3();
delay(250);
// Starting ADS1115_adc2
ads.begin(0x49);
ads.setGain(GAIN_SIXTEEN); // Setting the gain for adc2 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
int16_t results3;
int16_t results4;
results3 = ads.readADC_Differential_0_1();
results4 = ads.readADC_Differential_2_3();
delay(250);
/* Be sure to update this value based on the IC and the gain settings! */
float multiplier = 0.1875F; /* ADS1115 @ +/- 6.144V gain (16-bit results) */
int VoltValue = analogRead(A0);
float VoltDec = (VoltValue/1023)*5;
// Make a string for assembling the data to log:
String dataString = "";
dataString += String(UnixTime);
dataString += ", ";
dataString += String(YearInMillenium);
dataString += "/";
dataString += String(MonthInYear);
dataString += "/";
dataString += String(DayInMonth);
dataString += " ";
dataString += String(HoursInDay);
dataString += ":";
dataString += String(MinutesInHour);
dataString += ":";
dataString += String(SecondsInMinute);
dataString += ", ";
dataString += String(results*multiplier);
dataString += ", ";
dataString += String(results2*multiplier);
dataString += ", ";
dataString += String(results3*multiplier);
dataString += ", ";
dataString += String(results4*multiplier);
// open the file to log and log the data line
File dataFile = SD.open("data.csv", FILE_WRITE);
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
}
else {
Serial.println("data.csv ?");
}
delay(100);
Serial.println(dataString);
delay(5000); /// 5 sec
}