Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <Adafruit_ADS1015.h>
- int r1 = 20000;
- int r2 = 5000;
- float Voltage;
- float supply;
- Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
- 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, 0.1875mV/ADS1115)");
- // ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
- ads.begin();
- }
- void loop(void)
- {
- float results;
- float multiplier = 0.1875F; /* ADS1115 @ +/- 6.144V gain (16-bit results) */
- results = ads.readADC_Differential_0_1();
- Voltage = results * multiplier;
- supply = (Voltage*(r1+r2))/r2;
- Serial.print("Differential: ");
- Serial.print(results);
- Serial.print("(");
- Serial.print(Voltage);
- Serial.println("mV)");
- Serial.println(supply);
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement