I have a D-1085 ( 50Amp model) from CHZ Labs:
https://images-na.ssl-images-amazon.com ... dlqZML.pdf
It is connected to Pin 34 on an ESP32 Thing from sparkfun. It is also wired backwards (from IP- to IP+). So, with no load, it should be sitting at 2.5v and at full 50Amps it should be at 0v.
here is my function:
Code: Select all
void updateAmps() {
unsigned long currentMillis = millis();
if (currentMillis - previousAmpSampleMillis >= interval)
{
previousAmpSampleMillis = currentMillis;
double oldAmpValue = amps;
rawAmpValue = analogRead(AMMETER_PIN);
voltage = (rawAmpValue / 1023.0) * 5.00;
amps = ((voltage - acsOffset) / mVperAmp);
if (oldAmpValue != amps)
{
char buf[3];
char command[20] = {0};
itoa(amps, buf, 10);
tAmps.setValue(buf);
}
}
}
Code: Select all
//Ammeter
#define AMMETER_PIN 34
int mVperAmp = 40;
double acsOffset = 2.5;
int rawAmpValue = 0;
double voltage = 0;
double amps = 0;
long previousAmpSampleMillis = 0;
long interval = 1000;
I would show an example output printing the rawampvalue and voltage, but i physically broke my esp32 so I can't hook my usb cable to it anymore.