ADS1220 on ESP32 compiling error

Hi
This code causes an error,

#include <SPI.h>
#include <ADS1220.h>
#include <ADS1220_WE.h>

//#define CS_PIN 9
//#define DRDY_PIN 1

#define CS_PIN 9
#define DRDY_PIN 19

ADS1220 ads(CS_PIN, DRDY_PIN);

void setup() {
  Serial.begin(115200);
  SPI.begin();
  ads.begin();
  
  // Set Gain (e.g., 1) and Data Rate (e.g., 20 SPS)
  ads.setGain(ADS1220_GAIN_1);
  ads.setDataRate(ADS1220_DR_20SPS);
}

void loop() {
  // 1. Read Differential Channel 1: AIN1 - AIN0
  ads.setMultiplexer(ADS1220_MUX_AIN1_AIN0);
  while(!ads.isDataReady()); // Wait for conversion
  long diff1 = ads.read();
  float voltage1 = ads.toVoltage(diff1);
  
  // 2. Read Differential Channel 2: AIN3 - AIN2
  ads.setMultiplexer(ADS1220_MUX_AIN3_AIN2);
  while(!ads.isDataReady()); // Wait for conversion
  long diff2 = ads.read();
  float voltage2 = ads.toVoltage(diff2);
  
  Serial.print("Ch 1 (V): "); Serial.print(voltage1, 6);
  Serial.print(" | Ch 2 (V): "); Serial.println(voltage2, 6);
  
  delay(500);
}

error

  11 | ADS1220 ads(CS_PIN, DRDY_PIN);
      | ^~~~~~~
      | ADS1220_H
ADS_one_IC_2_inputs:13:6: error: conflicting declaration of 'void setup()' with 'C' linkage
   13 | void setup() {
      |      ^~~~~
In file included from sketch\ADS_one_IC_2_inputs.ino.cpp:1:
C:\Users\Galinka\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:155:6: note: previous declaration with 'C++' linkage
  155 | void setup(void);
      |      ^~~~~
ADS_one_IC_2_inputs:23:6: error: conflicting declaration of 'void loop()' with 'C' linkage
   23 | void loop() {
      |      ^~~~
C:\Users\Galinka\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:156:6: note: previous declaration with 'C++' linkage
  156 | void loop(void);
      |      ^~~~
C:\Users\Galinka\Documents\Arduino\ADS_one_IC_2_inputs\ADS_one_IC_2_inputs.ino: In function 'void setup()':
ADS_one_IC_2_inputs:16:3: error: 'ads' was not declared in this scope; did you mean 'abs'?
   16 |   ads.begin();
      |   ^~~
      |   abs
ADS_one_IC_2_inputs:20:19: error: 'ADS1220_DR_20SPS' was not declared in this scope; did you mean 'ADS1220_DR_LVL_6'?
   20 |   ads.setDataRate(ADS1220_DR_20SPS);
      |                   ^~~~~~~~~~~~~~~~
      |                   ADS1220_DR_LVL_6
C:\Users\Galinka\Documents\Arduino\ADS_one_IC_2_inputs\ADS_one_IC_2_inputs.ino: In function 'void loop()':
ADS_one_IC_2_inputs:25:3: error: 'ads' was not declared in this scope; did you mean 'abs'?
   25 |   ads.setMultiplexer(ADS1220_MUX_AIN1_AIN0);
      |   ^~~
      |   abs
ADS_one_IC_2_inputs:25:22: error: 'ADS1220_MUX_AIN1_AIN0' was not declared in this scope; did you mean 'ADS1220_MUX_1_AVSS'?
   25 |   ads.setMultiplexer(ADS1220_MUX_AIN1_AIN0);
      |                      ^~~~~~~~~~~~~~~~~~~~~
      |                      ADS1220_MUX_1_AVSS
ADS_one_IC_2_inputs:31:22: error: 'ADS1220_MUX_AIN3_AIN2' was not declared in this scope; did you mean 'ADS1220_MUX_3_AVSS'?
   31 |   ads.setMultiplexer(ADS1220_MUX_AIN3_AIN2);
      |                      ^~~~~~~~~~~~~~~~~~~~~
      |                      ADS1220_MUX_3_AVSS
C:\Users\Galinka\Documents\Arduino\ADS_one_IC_2_inputs\ADS_one_IC_2_inputs.ino: At global scope:
ADS_one_IC_2_inputs:40:2: error: expected '}' at end of input
   40 | }
      |  ^
In file included from C:\Users\Galinka\Documents\Arduino\ADS_one_IC_2_inputs\ADS_one_IC_2_inputs.ino:2:
C:\Users\Galinka\Documents\Arduino\libraries\ADS1220-master/ADS1220.h:35:12: note: to match this '{'
   35 | extern "C" {
      |            ^
exit status 1
'ADS1220' does not name a type; did you mean 'ADS1220_H'?

You have more than one copy of a sketch in the same sketch folder.

Or...

You pasted the same code, twice, into the same sketch.

This is one ADS with reading from 2 differential inputs.

You were referring to the sketch.

original on the link

Google Search

Paste your code, here.
Then you have two copies of (probably the same) code in one folder.

= post #1


Not a surprise considering where you got it from.

Do you want to use an ADS12220 IC or some module?
Which ESP32 do you have?

ADS1220 IC + ESP32C6

Do you understand the difference between an IC and a module?


= IC

So please show the schematic of your circuit.
Let's first make sure your hardware is correct before we start trying to debug software.

The compiler can't see the schematic. The title of this thread is "ADS1220 on ESP32 compiling error". Has that "compiling error" been resolved?

Not yet but it will be.

If you are using the ESP 3V3(out) for both AVDD and DVDD, then DGND need to be connected to AVSS.

Which board do you have selected in the IDE?