ACS712: problem with ESP32

Hello

with a Promicro 5v and : ACS712 ACS(A0, 5, 1023, 100);

I got : No load: analogRead(A0) totalmA 516 - 0.00

With load 551 - 1.94 and 1.89 with multimeter, so it’s OK

but with EPS32 and : ACS712 ACS(34, 3.3, 4095, 100); No load: analogRead(34) totalmA 128 - 0.00

With load 145 - 0.16 here the code:

#include "ACS712.h"

// Arduino UNO has 5.0 volt with a max ADC value of 1023 steps
// ACS712 5A  uses 185 mV per A
// ACS712 20A uses 100 mV per A
// ACS712 30A uses  66 mV per A
/*
Promicro 5V
A0    totalmA
516 - 0.00
551 - 1.94

esp32 3.3V
34  totalmA
128 - 0.00
145 - 0.16


 * 
 */
//ACS712  ACS(A0, 5, 1023, 100);
// ESP 32 example (requires resistors to step down the logic voltage)

with 2x4.7k voltage divider.
 ACS712  ACS(34, 3.3, 4095, 100);

float lastValue = 0;
int nbrsample = 10;

void setup() {

  Serial.begin(115200);
  Serial.println(__FILE__);
  ACS.autoMidPoint();
  

}

void loop() {
  float  totalmA = 0;
  
  for(int nbr =0; nbr < nbrsample; ++nbr){
    totalmA += ACS.mA_DC();
    delay(10);
  }
  totalmA = (totalmA / nbrsample)/1000;

  Serial.print(analogRead(34));Serial.print(" - ");Serial.println(totalmA);


  delay(200);
}

If you could help me, it will be great because I don’t understand. Best regards. Laurent


updated code tags for readability

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

Thanks

tomorrow morning I will test it

Regards