Using the ADS7830 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller with a potentiometer, installing the Adafruit_ADS7830 library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout VIN.
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector. A potentiometer is connected to analog input 0 (A0):
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout VIN to potentiometer positive (red wire)
- Breakout A0 to potentiometer wiper (green wire)
- Breakout GND to potentiometer negative (black wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout VIN to potentiometer positive (red wire)
- Breakout A0 to potentiometer wiper (green wire)
- Breakout GND to potentiometer negative (black wire)
Library Installation
You can install the Adafruit_ADS7830 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_ADS7830, and select the Adafruit ADS7830 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
#include <Wire.h> #include <Adafruit_ADS7830.h> Adafruit_ADS7830 ad7830; void setup() { Serial.begin(115200); while (!Serial) delay(10); // Wait for console to open Serial.println("Adafruit ADS7830 Test by Limor Fried/Ladyada"); // Possible arguments to begin(): // begin(); // Uses default I2C address 0x48 and Wire // begin(0x49); // Uses I2C address 0x49 and Wire // begin(0x48, &Wire1); // Uses I2C address 0x48 and Wire1 if (!ad7830.begin()) { Serial.println("Failed to initialize ADS7830!"); while (1); } } void loop() { for (uint8_t ch = 0; ch <= 7; ch++) { uint8_t value = ad7830.readADCsingle(ch); Serial.print(value); if (ch < 7) { Serial.print(",\t"); } } Serial.println(); delay(100); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the ADS7830 recognized over I2C. As you turn the potentiometer attached to A0, you'll see the values change.
Text editor powered by tinymce.