0
\$\begingroup\$

I am looking for a solution to detect de presence of mains current with the Arduino. I came across a few solutions but I think all of them have some serious drawback for this case:

I have 8 power sockets supplied by mains voltage that are controlled by an Arduino (Mega 2560 - if it is important, but if not suitable, can be changed with something else) with relays. In those sockets I plug different power consumers (a 300w heater, some pumps, some solenoids) - for an aquarium. I want to be able to detect if current is flowing (not interested by the value!) to check if the relay switched correctly and the thing that is plugged in the socket is operating.

At present I have 8 "donuts" which are non contact sensors (which is nice!) but there is heavy interference. So much that I cannot assert the state of a circuit with this solution.

I thought about using ACS712 current sensors instead. But I read that being hall effect, they pretty much suffer from the same limitations that I now have with the current transformers.

Is there any other (preferably simple) way to detect the current presence for each socket, that doesn't suffer from interference from the adjacent circuits?

\$\endgroup\$
17
  • \$\begingroup\$ do you want to know if the connected appliance draws current or if the relay works and there is voltage? \$\endgroup\$
    – Juraj
    Sep 1, 2021 at 18:28
  • \$\begingroup\$ I need to see if the appliance draws current (if YES the relay also works). If NO I have either relay failure or appliance failure (not important to detect which one actually failed). \$\endgroup\$
    – popliviustefan
    Sep 1, 2021 at 18:37
  • 2
    \$\begingroup\$ "300w heater, some pumps, some solenoids", we are talking about some ampere to some miliampere, 1:1000 range. So it can't be solved with the same setup. "hey pretty much suffer from the same limitations that I now have with the current transformers", current transformers are very, very accurate. \$\endgroup\$ Sep 1, 2021 at 19:33
  • 6
    \$\begingroup\$ A current transformer is a perfectly good solution to your problem. If it's not working for you, you should debug your circuit (CT, burden resistor, layout, interface circuitry, cabling, etc.) and not abandon the CT for a different method. \$\endgroup\$
    – John D
    Sep 1, 2021 at 20:03
  • 1
    \$\begingroup\$ I am very much surprised that you are having difficulty with current transformers. Are they adequately rated? Could you post datasheet? \$\endgroup\$ Sep 1, 2021 at 21:31

2 Answers 2

1
\$\begingroup\$

Here is part of a circuit that I used, which can both detect the presence of A/C but also measure the current flowing through an AC line. The particular device had 4 AC inputs which were multiplexed to 4 outputs via relays, but also measured current on any input and could tell if AC was plugged in on any of the inputs. Several of these units were fielded so I know it works.

A few notes on its operation.

Detection of AC used the MID400 chip, which is designed specifically for detecting AC. I investigated multiple other solutions, including the resistor-capacitor-opto route but this was the most reliable way to do it. If you only need detection, that should work fine.

For current sensing, I'm using the ACS722, at a maximum current of 40A. It also worked very well, however, you will be reading a sinusoidal signal, not a fixed analog. The software on the microcontroller that the ACS722 was feeding monitored the analog signal and identified the high/low value of the signal and then calculated the RMS value of current, this was accurate to about 0.5A.

So the microcontroller, at any given time, knows if there is power on the AC input, and if there is power, it can tell how much RMS current flows to the load.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

So, after some time, I finally got the time to try to tackle this problem and I think I figured it out:
1st issue: I used an electronic ballast to power 2 fluorescent tubes. It was a quality one, but apparently it was responsible for the interference I got.
2nd issue: I didn't sample correctly / interpreted the data correctly.
3rd issue: The "donuts" that I have have a small potentiometer that controls how big the sensitivity of the sensor is. Donut I use.

So, I got the information I was after: "is there something that draws power from the socket?" At this point I am not interested to calculate the actual power draw.
The solutions to my problems:
1st problem: I replaced the fluorescent tubes with LED based lamps (better, cooler, more economical, more lifespan).
2nd problem: My sampling is now as follows:
a) read 100 measurements from the analog pin where the sensor is connected, no delay between measurements, average the measurements and store the value in a 20 elements fixed size FIFO queue.
b) repeat (a) for each of the 8 sensors and store the value in its respective queue.
c) repeat above every 100ms.
d) Each time I want to get the state of the sensor I get the min and max of all 20 elements in the queue; the difference (max - min) is evaluated against a threshold: if higher, appliance is considered ON, if lower, is considered OFF.
3rd problem: I reset the sensitivity of all the potentiometers in their default center position. The tunning is accomplished on the software side by that threshold I am evaluating against.

I hope this benefits someone in my situation.
The other solutions are good as well, but all implied changing the hardware, which is also time consuming and adds cost.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.