Skip to content

Commit d92f72c

Browse files
committed
Add Example05
1 parent 7732e96 commit d92f72c

File tree

6 files changed

+86
-9
lines changed

6 files changed

+86
-9
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ SparkFun ADS1219 Arduino Library
1010
</tr>
1111
</table>
1212

13+
This is an Arduino Library for the ADS1219 24-bit 4-channel ADC from TI. It allows you to fully configure the ADC.
14+
Examples are provided to show how to use: single-shot vs. continuous mode; the input multiplexer; gain;
15+
different sample rates; and alternate I2C addresses. You can read the ADC voltage in millivolts (compensated for gain)
16+
or as the raw signed value.
17+
18+
Note: this library needs the [SparkFun Toolkit](https://github.com/sparkfun/SparkFun_Toolkit).
19+
1320
Repository Contents
1421
-------------------
1522

@@ -19,6 +26,7 @@ Repository Contents
1926

2027
Documentation
2128
--------------
29+
2230
* **[Hardware Repository](https://github.com/sparkfunX/SparkX_ADC_ADS1219)** - Hardware repository for the SparkX 24-Bit 4-Channel ADC - ADS1219 (Qwiic).
2331

2432
License Information

examples/Example01_SingleShot/Example01_SingleShot.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ SfeADS1219ArdI2C myADC;
2828

2929
void setup()
3030
{
31-
3231
delay(1000); // Allow time for the microcontroller to start up
3332

3433
Serial.begin(115200); // Begin the Serial console
3534
while (!Serial)
3635
{
3736
delay(100); // Wait for the user to open the Serial Monitor
38-
};
37+
}
3938
Serial.println("SparkFun ADS1219 Example");
4039

4140
Wire.begin(); // Begin the I2C bus

examples/Example02_Continuous/Example02_Continuous.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ SfeADS1219ArdI2C myADC;
2828

2929
void setup()
3030
{
31-
3231
delay(1000); // Allow time for the microcontroller to start up
3332

3433
Serial.begin(115200); // Begin the Serial console
3534
while (!Serial)
3635
{
3736
delay(100); // Wait for the user to open the Serial Monitor
38-
};
37+
}
3938
Serial.println("SparkFun ADS1219 Example");
4039

4140
Wire.begin(); // Begin the I2C bus

examples/Example03_InputMultiplexer/Example03_InputMultiplexer.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ SfeADS1219ArdI2C myADC;
3131

3232
void setup()
3333
{
34-
3534
delay(1000); // Allow time for the microcontroller to start up
3635

3736
Serial.begin(115200); // Begin the Serial console
3837
while (!Serial)
3938
{
4039
delay(100); // Wait for the user to open the Serial Monitor
41-
};
40+
}
4241
Serial.println("SparkFun ADS1219 Example");
4342

4443
Wire.begin(); // Begin the I2C bus

examples/Example04_DataReadyInterrupt/Example04_DataReadyInterrupt.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Hardware Connections:
1818
IoT RedBoard --> ADS1219
1919
QWIIC --> QWIIC
20-
Connect an interrupt-capable IO pin to the DRDY breakout pad, using a jumper wire.
20+
Use a jumper wire to connect the DRDY breakout pad to an interrupt-capable I/O pin
2121
2222
Open the serial monitor at 115200 baud to see the voltage.
2323
@@ -46,14 +46,13 @@ void dataReadyISR(void)
4646

4747
void setup()
4848
{
49-
5049
delay(1000); // Allow time for the microcontroller to start up
5150

5251
Serial.begin(115200); // Begin the Serial console
5352
while (!Serial)
5453
{
5554
delay(100); // Wait for the user to open the Serial Monitor
56-
};
55+
}
5756
//Serial.println("SparkFun ADS1219 Example"); // Commented for the Serial Plotter
5857

5958
Wire.begin(); // Begin the I2C bus
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Using alternate I2C addresses for the ADS1219 ADC.
3+
4+
This example shows how to use an alternate address for the ADC.
5+
6+
The ADS1219 has two address pins: A1 and A0. These can be tied to
7+
SCL, SDA, VDD or DGND to provide 16 possible I2C addresses (0x40 - 0x4F).
8+
On the SparkX Qwiic ADS1219, split-pad jumpers make this easy.
9+
The A0 jumpers are labelled 0,1,2,3. The A1 jumpers are labelled 0,4,8,C.
10+
To set the address to 0x4F: open both 0 jumpers, solder 3 and C closed.
11+
12+
By: Paul Clark
13+
SparkFun Electronics
14+
Date: 2023/12/11
15+
SparkFun code, firmware, and software is released under the MIT License.
16+
Please see LICENSE.md for further details.
17+
18+
Hardware Connections:
19+
IoT RedBoard --> ADS1219
20+
QWIIC --> QWIIC
21+
22+
Open the serial monitor at 115200 baud to see the voltage.
23+
24+
Feel like supporting our work? Buy a board from SparkFun!
25+
https://www.sparkfun.com/products/23455 - Qwiic ADS1219 1x1
26+
*/
27+
28+
// You will need the SparkFun Toolkit. Click here to get it: http://librarymanager/All#SparkFun_Toolkit
29+
30+
#include <SparkFun_ADS1219.h> // Click here to get the library: http://librarymanager/All#SparkFun_ADS1219
31+
32+
SfeADS1219ArdI2C myADC;
33+
34+
void setup()
35+
{
36+
delay(1000); // Allow time for the microcontroller to start up
37+
38+
Serial.begin(115200); // Begin the Serial console
39+
while (!Serial)
40+
{
41+
delay(100); // Wait for the user to open the Serial Monitor
42+
}
43+
Serial.println("SparkFun ADS1219 Example");
44+
45+
Wire.begin(); // Begin the I2C bus
46+
47+
bool begun;
48+
begun = myADC.begin(Wire, 0x4F); // Initialize the ADC - using a custom bus and address - see notes above
49+
begun = myADC.begin(0x4F); // This is also possible. It defaults to Wire
50+
51+
if (!begun)
52+
{
53+
Serial.println("ADC not detected! Please check the address and try again...");
54+
while (1); // Do nothing more
55+
}
56+
57+
Serial.println("Reading the differential voltage between AIN0 (+) and AIN1 (-)");
58+
}
59+
60+
void loop()
61+
{
62+
myADC.startSync(); // Start a single-shot conversion.
63+
64+
while (myADC.dataReady() == false) // Check if the conversion is complete. This will return true if data is ready.
65+
{
66+
delay(10); // The conversion is not complete. Wait a little to avoid pounding the I2C bus.
67+
}
68+
69+
myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.
70+
int32_t sample = myADC.getConversionRaw(); // Get the raw ADC value. Note: this is NOT adjusted for gain.
71+
Serial.print("Raw ADC value: ");
72+
Serial.println(sample); // Print the raw ADC value
73+
}

0 commit comments

Comments
 (0)