I2C communication with an Analog-to-Digital Converter : ADS1015 component
tags: flipper, arduino, ADC, ADS1015, I2C
This is an example of I2C communication with an ADC component.
1. Schematics
For this example we used Sparkfun's ADS1015 Library.
We are using the I2C1 communication bus so we will use Wire1 instance (if we were using I2C0 it would have been Wire instance, see flipper arduino bus references ).
The i2C address of the ADS1015 is 0x48 since we connected ADDR pin to GND (see datasheet ) .
2. Arduino Code
- flipper_ADS1015.ino
#include #include ADS1015 adcSensor; void setup() { Wire1.begin(); Serial.begin(9600); if (adcSensor.begin(0x48, Wire1) == true) // connect to device at address 0x48 { Serial.println("Device found. I2C connections are good."); } else { while(1) { Serial.println("Device not found. Check wiring."); } } } void loop() { uint16_t channel_A0 = adcSensor.getSingleEnded(0); Serial.print("A0:"); Serial.println(channel_A0); delay(50); // avoid bogging up serial monitor² }