Hi,
I am trying to change the parameters of the ADS1115 to alter the gain and also the samples per second (SPS) by using the "Wire.h" library.
The section of code between the h"hash" marks is how I understand it from the datasheet but it has no effect, also
I have tried other peoples code that uses the same method and it doesn't work for them either I can only assume they didn't check.
After trying proper 8 bits according to the register info I put in random Bytes (frustration) this did nothing. The sketch
works fine if I uncomment the required gain but I also want to change the SPS, I would like to no why this has no effect,
am I using the Wire functions incorrectly or am I oversimplifying it ? what have I missed please?
Andy
[code#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27);
Adafruit_ADS1115 ads;
void setup(void)
{
// ADS1015 ADS1115
// ------- -------
//ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
//ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
//ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
//ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
//ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
//ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
lcd.begin(16, 2);
ads.begin();
lcd.setBacklight(1); // 0 = OFF 1 = ON
//######################## Trying to talk to ADS1115 ####################
Wire.begin();
Wire.beginTransmission(0b10010000);// ADS address
Wire.write(0b00000001);// pointer
Wire.write(0b11001011);// MSB
Wire.write(0b10000011);// LSB
Wire.endTransmission();// send Bytes
//####################### Unsuccessfully #################################
}
void loop(void)
{
int16_t results = 0;
float multiplier = 0.015625; // Set Multiplier according to the chosen gain
results = ads.readADC_Differential_2_3();
lcd.setCursor(0, 0);
lcd.print("Counts : "); lcd.print(results); // Print to LCD the actual counts
lcd.setCursor(0, 1);
lcd.print("current: "); lcd.print(results * multiplier,3); //Print to LCD the actual value determined by gain and multiplier
delay(100);
}]