I am working on a device to measure main AC current using an ACS712. I don't need very high accuracy, just to make sure that the current stays in between some values. Outside these values the device switches the AC off. The switching is done with a (12V) relay.
In the first version I used an Omron relay. I found that the output of the ACS which, when measuring AC, should swing proportionally around 0,5 Vcc (2.5V), was off by -100mV. Did not think a lot about that, blamed the opamp circuit that amplified the ACS output and corrected this in firmware.
Then, for my second prototype, I used a Finder relay and the newer ACS723 (with build-in opamp). To my surprise the ACS output was now off by +80mV. I started to blame the ACS. I started to blame the AC line. I started to blame the weather. I started to poke a screwdriver in my PCB to short out the ACS's bandwidth selection pin to see if that made a difference. As soon as I moved the screwdriver next to the ACS the device detected an overcurrent situation and switched off the relay.
Then it occurred to me: the screwdriver is magnetic. But so is a relay coil. The coil of my relay sits 20 mm from the ACS723. Enough to influence the reading of the ACS. One coil is would one way, the other the other way around. So two different offsets. These ACS chips really are sensitive to outside magnetic fields, as stated in the datasheet. RTFM. Time for a tinfoil hat for the relay, or, more likely, a PCB redesign.
The worst thing about all this is that I had already noticed that before the relay was activated the output of the ACS was 2.5V. Only after activating the relay the output was pulled higher or lower depending on which relay I used. I'm getting too old for shit like this
