Re: monitoring Dc help

Howard Dutton

Just wire in the device per the examples on the internet.  The ACS712 seems to have isolation so just wire it right into an unused Mega2560 analog input.

The following code should do the trick (add to Misc.ino)

// converts a raw analog reading into current for STAT_DC_CURRENT_ANALOG and STAT_BATTERY_CURRENT_ANALOG
// return (invalid) if not implemented or if there's an error
#define ACS712_ANALOG_PORT  A0
#define ACS712_mV_PER_A     0.185
double toDCAmps(double d) {
 double V=0;

 for (int i=0; i<25; i++) { V+=(analogRead(ACS712_ANALOG_PORT)/1024.0)*5.0; delay(1); }
 double A = (2.5 - V)/ACS712_mV_PER_A;

return A;

Join to automatically receive all group messages.