hi, i have smal problem with my project.
I want to use 2 analog input channels on the ads1115 module with different voltages on the two analog inputs, but from the input channel it emits the same voltage, how to write the code so that A0 with A1 is different voltage?
- note: not differential
please correct my proogram :
#include <MQ135.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 or 0x3f for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48);
#define RL 47
#define m -0.263
#define b 0.42
#define RO 20
void setup(void){
Wire.begin(D2, D1);
lcd.begin();
Serial.begin(115200);
ads.begin();
lcd.home();
lcd.print("TESTING");
}
void loop(void){
//MQ_135
int16_t adc0 = ads.readADC_SingleEnded(0); // 16 bits ADC read of input A0
float voltage = (adc0 * 0.1875)/1000; //convert adc to voltage in ads1115
float RS = ((3.0/voltage) - 1) * RL;
//float RO = RS / 3.6;
float ratio = RS/RO;
float ppm = pow (10, ((log10(ratio)-b)/m));
//TDS
int16_t adc1 = ads.readADC_SingleEnded(1);
float voltage1 = (adc0 * 0.1875)/1000;
float usiemens = (adc1*0.2142) + 494.93;
float tds = (adc1 * 0.3147) + 281.08;
Serial.print("AIN0: ");Serial.print(adc0); Serial.print("\tAIN1: "); Serial.println(adc1);
Serial.print("Voltage: ");Serial.print(voltage, 7); Serial.print("\tVoltage 1: "); Serial.println(voltage1, 7);
Serial.print ("Ratio: ");Serial.print(ratio); Serial.print("\tUSIEMENS: "); Serial.println(usiemens);
Serial.print ("PPM: ");Serial.print(ppm); Serial.print("\tTDS: "); Serial.println(tds);
Serial.println();
delay(1500);
}