products:flipper:adc_i2c_arduino

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.

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 ) .

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²
}
  • products/flipper/adc_i2c_arduino.txt
  • Last modified: 2021/04/04 13:12
  • by manu