ESP32 + ADS1015: Data rate configuration not matching expected SPS
Posted: Mon Sep 08, 2025 7:33 pm
Hi, how are you doing? My name is Emerson, I'm from Brazil and I'm trying to use the ADS1015 conversor circuit using an ESP32 and I²C protocol, my code has a setup as the code below, the trouble I'm having right now is to set the frequency rate, I'm trying to set it to 2400 SPS or 3300 SPS, any of the values as the table indicates on github, but the response time of the circuit is not following the rate configured.
and then in the void loop I'm trying to use this code, to verify the response time for 512 samples, and it's using more time than for the rate configured, it's like 84 SPS for a 3300 SPS configured rate, when using the continuous mode it's like 3400 SPS, but for singled ended mode it's not even close to the frequency rate of setup
Could you help me to solve it? I'm using the ADS1015 to acquire some current and voltage values to provide an harmonic analysis for my graduate research.
Best regards,
Emerson Santos
Code: Select all
/*
Projeto: Conjunto de sensores ZMPT101B - SCT013 e conversor ADC ADS1115 com ESP32
Autor: Emerson Nunes dos Santos
Orientador: Idalmir de Souza Queiroz Júnior
-- Versão 33 -- em teste...
*/
//DECLARAÇÃO DE BIBLIOTECAS
#include <Adafruit_ADS1X15.h>
#include <Arduino.h>
//DEFINES GERAIS
#define PIN_S_TENS 0 //PORTA LEITURA TENSÃO
#define PIN_S_CORR 1 //PORTA LEITURA CORRENTE
//DECLARAÇÃO DE OBJETOS
Adafruit_ADS1015 ads; //OBJETO REFERENTE A LEITURA DAS PORTAS DO SENSOR ADS1115
//FUNÇÃO DE CONFIGURAÇÃO DE CONEXÕES E VARIÁVEIS INICIAIS
void setup(void){
//TEMPO PARA INICIALIZAÇÃO
delay(5000);
//INICIALIZAÇÃO DA TAXA DE TRANSMISSÃO DA COMUNICAÇÃO SERIAL
Serial.begin(RATE_SERIAL);
Serial.println("Serial initiated successfully!");
Serial.println("Using rate = 115200 bits/s for Serial Transmission");
Serial.println("Projeto: Conjunto de sensores ZMPT101B - SCT013 e conversor ADC ADS1015 com ESP32");
Serial.println("Autor: Emerson Nunes dos Santos");
Serial.println("Orientador: Idalmir de Souza Queiroz Júnior");
Serial.println("-- Versão 33 -- em teste...");
Serial.println("Horário sincronizado!");
//INICIALIZAÇÃO DA COMUNICAÇÃO I2C
Serial.println("Initializing I2C Wire configuration");
Wire.begin(21, 22, 400000);
Serial.println("I2C Wire initialized successfully!");
//PRIMEIRO PRINT PARA MOSTRAR A FORM
Serial.println("Initializing ADS1015 ADC Converter");
Serial.println("Getting single-ended readings from AIN0 and AIN1");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
//DEFININDO O GANHO DE CONVERSÃO DO ADS1115
ads.setGain(GAIN_ONE);// 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
//DEFININDO A FREQUÊNCIA DE AQUISIÇÃO DE DADOS DO ADS1115
ads.setDataRate(RATE_ADS1015_3300SPS);
//VERIFICAÇÃO SE INICIALIZAÇÃO FOI UM SUCESSO
if (!ads.begin())
{
Serial.println("Failed to initialize ADS.");
// while (1);
// ESP.restart();
}
// Configura para modo contínuo no canal 0
// ads.startADCReading(ADS1X15_REG_CONFIG_MUX_SINGLE_0, /*continuous=*/true);
Serial.println("ADS1015 initialized successfully!");
delay(2000);
Serial.println("Iniciando medições: ");
Serial.println("-------------------------------------------------");
}Code: Select all
void LEITURA_ADS (){
i = 0;
int64_t t1 = esp_timer_get_time();
// LEITURA DA TENSÃO COM FREQUÊNCIA DE AMOSTRAGEM DE 384 Hz (f_sinal*2 + acréscimo = 60*2 + 264)
while(i < N_AMOSTRAS){
leitura_corr_bin[i] = ads.readADC_SingleEnded(PIN_S_CORR);
i ++;
}
int64_t dt1 = esp_timer_get_time() - t1;
Serial.print("tempo leitura corr: ");
Serial.println(dt1);
delay(2000);
i = 0;
}Best regards,
Emerson Santos