Hi, I am trying to write code for fireBeetle esp32 on arduino ide. There is a problem that I cannot solve even though I have installed the necessary library for ADS1256. I am sharing the part of the code I am trying to write about ADS. Can you say something about the codes below and the reason for the kata code?
#include <Wire.h>
#include <SPI.h>
#include <ads12xx.h>
#include <LiquidCrystal_I2C.h>
const int START = 18; //start pin
const int CS = 22; //clock pin
const int DRDY = 26; //data ready pin
float samplingfreq; //
ads12xx ADS; //initialize ADS as object of the ads12xx class
#define true 1
#define false 0
LiquidCrystal_I2C lcd(0x38,20,4);
void setup()
{
//set up high baud rate for high data rates
Serial.begin(115200);
const byte CS_pin = 22; //goes to CS on ADS1256
const byte DRDY_pin = 26; //goes to DRDY on ADS1256
}
void loop() {
ADS.begin(CS, START, DRDY); //initialize ADS as object of the ads12xx class
ADS.Reset(); //Reset the AD chip. Every time you see the message on the Serial Terminal, everything is set to default!
delay(10); //wait a moment
//preconfig
ADS.SetRegisterValue(STATUS, B00110100); //Autocal is ON
ADS.SetRegisterValue(MUX, B00001000); //
ADS.SetRegisterValue(ADCON, B00000000); //
ADS.SetRegisterValue(DRATE, B11010000); //7500 SPS
ADS.SetRegisterValue(IO, B11101111); //
ADS.SendCMD(SELFCAL); //run self calibration
double startTime = millis();
if (Serial.available()) {
ADS.SendCMD(SELFCAL); //Self calibration
delay(200); //wait a little
ADS.SetRegisterValue(MUX, B00000001);//AIN0+AIN1 -- CH0
//printing the result
Serial.println(ADS.GetConversion());
//----------------DIFFERENTIAL CHANNEL ------------------------------------------------------------
samplingfreq = Serial.parseFloat();
//ADS.SetRegisterValue(DRATE, B11010000); //7500 SPS// for 1 sample / second on the PC
ADS.SetRegisterValue(DRATE, B01100011);
ADS.SendCMD(SELFCAL); //Self calibration
delay(200); //wait a little
int o=0;
//calibration!
while ( o = 3 ) { //while we don't stop manially by sending N through the terminal....
//Elapsed time since the sw is started
double elapsedTime = millis() - startTime;
//prints time since program started
Serial.print(elapsedTime);
Serial.print("\t");
//Switch on the first channel
ADS.SetRegisterValue(MUX, B00000001);//AIN0+AIN1 -- CH0
Serial.print(ADS.GetConversion());
pop[o]=ADS.GetConversion(); // saving signal value to a variable array
Serial.print("\t");
delay(samplingfreq);
} o++;}
}
error codes:
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:3:27: error: 'HIGH' was not declared in this scope
volatile int DRDY_state = HIGH;
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In function 'void waitforDRDY()':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:11:16: error: 'noInterrupts' was not declared in this scope
noInterrupts();
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:12:16: error: 'HIGH' was not declared in this scope
DRDY_state = HIGH;
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:13:14: error: 'interrupts' was not declared in this scope
interrupts();
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In function 'void DRDY_Interuppt()':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:17:38: error: 'LOW' was not declared in this scope
void DRDY_Interuppt() { DRDY_state = LOW; }
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'void ads12xx::begin(int, int, int)':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:23:15: error: 'OUTPUT' was not declared in this scope
pinMode(CS, OUTPUT); // set the slaveSelectPin as an output:
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:23:21: error: 'pinMode' was not declared in this scope
pinMode(CS, OUTPUT); // set the slaveSelectPin as an output:
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:24:20: error: 'HIGH' was not declared in this scope
digitalWrite(CS, HIGH); // CS HIGH = nothing selected
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:24:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(CS, HIGH); // CS HIGH = nothing selected
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:27:17: error: 'INPUT' was not declared in this scope
pinMode(DRDY, INPUT); // DRDY read
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:32:12: error: 'delay' was not declared in this scope
delay(500);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:36:65: error: 'FALLING' was not declared in this scope
attachInterrupt(digitalPinToInterrupt(_DRDY), DRDY_Interuppt, FALLING);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:36:72: error: 'attachInterrupt' was not declared in this scope
attachInterrupt(digitalPinToInterrupt(_DRDY), DRDY_Interuppt, FALLING);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'long int ads12xx::GetContConversion(int32_t*, uint16_t)':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:44:47: error: 'MSBFIRST' was not declared in this scope
SPI.beginTransaction(SPISettings(SPI_SPEED, MSBFIRST, SPI_MODE1));
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:46:21: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW); // Pull SS Low to Enable Communications with
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:46:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW); // Pull SS Low to Enable Communications with
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:49:23: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10); // RD: Wait 25ns for ADC12xx to get ready
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:63:21: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'long int ads12xx::GetConversion()':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:71:47: error: 'MSBFIRST' was not declared in this scope
SPI.beginTransaction(SPISettings(SPI_SPEED, MSBFIRST, SPI_MODE1));
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:72:21: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW); // Pull SS Low to Enable Communications with
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:72:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW); // Pull SS Low to Enable Communications with
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:74:23: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10); // RD: Wait 25ns for ADC12xx to get ready
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:86:21: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'void ads12xx::SetRegisterValue(uint8_t, uint8_t)':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:102:3: error: 'Serial' was not declared in this scope
Serial.print("Previous val ");
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:103:31: error: 'HEX' was not declared in this scope
Serial.println(regValuePre, HEX);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:106:25: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:109:20: error: 'MSBFIRST' was not declared in this scope
SPI_SPEED, MSBFIRST,
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:111:23: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:111:26: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:118:23: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'long unsigned int ads12xx::GetRegisterValue(uint8_t)':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:136:18: error: 'MSBFIRST' was not declared in this scope
SPI_SPEED, MSBFIRST,
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:139:21: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:139:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:140:23: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:147:21: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'void ads12xx::SendCMD(uint8_t)':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:160:18: error: 'MSBFIRST' was not declared in this scope
SPI_SPEED, MSBFIRST,
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:162:21: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:162:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:163:23: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:166:21: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp: In member function 'void ads12xx::Reset()':
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:173:18: error: 'MSBFIRST' was not declared in this scope
SPI_SPEED, MSBFIRST,
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:175:21: error: 'LOW' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:175:24: error: 'digitalWrite' was not declared in this scope
digitalWrite(_CS, LOW);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:176:23: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(10);
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:178:10: error: 'delay' was not declared in this scope
delay(2); // Minimum 0.6ms required for Reset to finish.
^
C:\Users\Hp\Desktop\arduino-1.8.19\libraries\ADS12xx-Library-master\ads12xx.cpp:181:21: error: 'HIGH' was not declared in this scope
digitalWrite(_CS, HIGH);
^
Multiple libraries were found for "Wire.h"
Used: C:\Users\Hp\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\Wire
Not used: C:\Users\Hp\Desktop\arduino-1.8.19\libraries\Wire
Multiple libraries were found for "SPI.h"
Used: C:\Users\Hp\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SPI
Not used: C:\Users\Hp\Desktop\arduino-1.8.19\libraries\SPI
exit status 1
Error compiling for board FireBeetle-ESP32.