A little help using this arduino AC current sensor / current transformer

Thread Starter

zirconx

Joined Mar 10, 2010
130
I am trying to have my raspberry pi detect when my sump pump is running. I ordered one of these current transformer sensors: https://www.ebay.com/itm/5A-Sensor-...ent-Sensor-Module-For-Arduino-lu/353264309642
Here are the specs if the link doesn't work:
Product Description:

1. On-board micro-precision current transformer
2. Onboard sampling resistor
3. Modules 5A can be measured within an alternating current, the analog output corresponding to 5A/5mA
4. Rated input current: 5A
5. Rated output current: 5mA
6. Change: 1000: 1
7. The linear range: 0 ~ 10A (100 ohm)
current-transformer-sensor.jpg


I think some of those specs are wrong, the auction title says 5A but the specs there say 10A. And I don't know what it means by "100 ohm". I see a SMD resistor in the photo labeled "102", when I look that up I get 1k ohm. It says "output current 5ma", but if it has an onboard resistor already, wouldn't I just be measuring the voltage directly on the two pins? I don't need to add a resistor and then measure the voltage across it, correct? So I'm just looking for a little guidance on how to use it.

Forget the pi for a moment, I think I can just read the voltage and that will give me an indication of current, right? Also, assuming it is a 5A max sensor, what happens if I run 10A though it? Will it just lose resolution above 5A?

My goal is only to know if the sump pump is on, not to measure how much current is flowing. Knowing that, I should be able to devise a circuit so I could read the output of this sensor on a digital GPIO pin? Use a zener or a voltage divider to limit the voltage to 3v? I do have an open input on my ads1115, but if I can just a GPIO pin directly that would be better.

Thanks for any help.
 

MisterBill2

Joined Jan 23, 2018
9,025
The first thing is to be able to connect it to your meter, which you should set for AC and ten volts, or something like that. Then only one of the AC mains leads of the sump pump should pass through the coil. You will read a voltage when the motor draws current.
Usually the range given is the linear range, in which the output will accurately follow the input. Above that point you still get an output, but it will not give an accurate reading. With a current transformer there is not likely to be any damage, though.
The output will be AC and so to use it as a pump-on detector you will need to rectify the voltage so that you have DC for the input.
 

Reloadron

Joined Jan 15, 2015
5,997
It looks like a small current transformer with a 100 Ohm burden resistor. So if the CT is a 5 Amp / 5.0 mA with a 100 Ohm burden at full scale of 5 Amps you will get about 0.5 VAC out. The Raspberry Pi does not have an onboard A/D converter so you will need to add one. Look at your sump pump(s) and note the normal current and locked rotor current to see what current you can expect. Anyway do as Mr. Bill suggest and measure the AC voltage off the CT you have. The pump will also have a Start Current which can be 5x or 10x the normal run current but it only does this briefly.

Next problem is you have an AC signal so you will need to add on board A/D for your Pi and one with a good low voltage range. Again, measure the AC voltage out on normal run. If you scroll down your link you will see plenty of references to an ACS 712 and an ACS 712 module would have been a much better choice and still inexpensive. I use two pumps in case one fails or we get a deluge. All I use is a few of these I bought for $10 USD each. I just extended the LED leads. I have used the ACS 712 modules with an Arduino with good results. With what you have you will need the added module for an analog input to the Pi and then try and code in Python to measure what you get. Good luck on that.

Ron
 

MisterBill2

Joined Jan 23, 2018
9,025
There is another option to increase the sensitivity which is to use an external transformer to increase the voltage. If the only goal is to verifythe pump running or off, then an analog input is not needed.
 

ronsimpson

Joined Oct 7, 2019
1,319
Product Description:

1. On-board micro-precision current transformer
2. Onboard sampling resistor
3. Modules 5A can be measured within an alternating current, the analog output corresponding to 5A/5mA
4. Rated input current: 5A
5. Rated output current: 5mA
6. Change: 1000: 1
7. The linear range: 0 ~ 10A (100 ohm)
8. Linearity: 0.2%
9. Precision rating: 0.2
10. Uses isolation voltage: 3000V Measurement
11. Sealing material: epoxy resin
12. Operating temperature: - 40 Celsius - + 70 Celsius
There is data missing.
It appears the resistor is 1k, so 5A-->5mA (1k)--->5V. (5V seems large but maybe)
Also 10A__10mA, 100 ohms,--->1V
I am thinking it works to 5A with 1k and 10A with 100 ohms.
-------------
I have not been able to get 5V out of small CTs. I can get 0.5V. The core saturates long before 5V.
Please measure the current of a lamp. Measure the output voltage with a meter and report back.
 

MisterBill2

Joined Jan 23, 2018
9,025
If magnetic saturation limits the output then a step-up transformer to increase the voltage will be OK. the alternative is to use multiple turns of the power wire through the opening. If only 2 turns of wire will pass through, then use a voltage tripler, while if thrr turns can ass through the coil then only a voltage doubler would be needed. No additional active circuits needed. Just a small ripple filter.
 

ronsimpson

Joined Oct 7, 2019
1,319
the alternative is to use multiple turns of the power wire through the opening. If only 2 turns of wire will pass through
One of the complaints on a forum about this CT is that extension cord wire will not pass through the CT. The hole is too small. (1 turn) Adding turns increases the output voltage at low current. It will not increase the voltage at high current because we are up against the (volts * time) limit on the core, saturation.
link

1609682244465.png
 
Last edited:

MisterBill2

Joined Jan 23, 2018
9,025
Because lamp-cord wires will not work, suitable wires with much thinner insulation must be used, OR a totally different device. There are commercially available current sensor modules, complete with an internal relay and an adjustable setpoint, that would be powered by 24 volts AC. These modules meet all of the applicable code requirements and are simple to use. Available from Grainger and other suppliers.
 

Reloadron

Joined Jan 15, 2015
5,997
If you really want a reliable and accurate commercial type solution you can look to manufacturers like CR Magnetics. You can get about anything you want as to range and output. Under a heading of Current Transducer you convert what you have to what you want. Zero to full scale will give you a scaled DC output such as 0 to 20 mA, 4 to 20 mA, 0 to 10 VDC or even 2 to 10 VDC. Current output versions allow you to place a resistor in the loop for example 250 or 500 ohms (precision resistor) and most are powered by an external 24 VDC supply or loop powered. Just be aware these are not the cheap stuff from Flea Bay, they are commercial transducers. They do not cost $2 USD. Here is a good example with a $100 USD price tag. If you just want to know if the pump is drawing current I would just use one of the LED lamps I linked to but if you want to actually read current be it average or true RMS things get a little more complex and expensive.

The circuit Ron Simpson posted above is a good circuit for sensing AC current. R6 is a 33 Ohm burden resistor while R7 and R8 form a voltage divider to get the AC out at a level of 2.5 VDC. Common problem is most A/D converters will not accept a negative input (when the sine wave goes below zero) so we set the output on a 2.5 VDC offset. You still need to write code to get anything useful from the AC. Cheap and simple I would look towards an ACS 712 Module where some of the work is done for you.

Ron
 

Reloadron

Joined Jan 15, 2015
5,997
If you really want a reliable and accurate commercial type solution you can look to manufacturers like CR Magnetics. You can get about anything you want as to range and output. Under a heading of Current Transducer you convert what you have to what you want. Zero to full scale will give you a scaled DC output such as 0 to 20 mA, 4 to 20 mA, 0 to 10 VDC or even 2 to 10 VDC. Current output versions allow you to place a resistor in the loop for example 250 or 500 ohms (precision resistor) and most are powered by an external 24 VDC supply or loop powered. Just be aware these are not the cheap stuff from Flea Bay, they are commercial transducers. They do not cost $2 USD. Here is a good example with a $100 USD price tag. If you just want to know if the pump is drawing current I would just use one of the LED lamps I linked to but if you want to actually read current be it average or true RMS things get a little more complex and expensive.

The circuit Ron Simpson posted above is a good circuit for sensing AC current. R6 is a 33 Ohm burden resistor while R7 and R8 form a voltage divider to get the AC out at a level of 2.5 VDC. Common problem is most A/D converters will not accept a negative input (when the sine wave goes below zero) so we set the output on a 2.5 VDC offset. You still need to write code to get anything useful from the AC. Cheap and simple I would look towards an ACS 712 Module where some of the work is done for you.

I also assume these pump(s) run on 220 VAC or 120 VAC 50/60 Hertz. Also my pumps run on 120 VAC and are 3/4 HP a typical pump running under full load will draw about 13 amps and at 230 volts about 6.9 Amps. Same pump with a 1/2 HP motor will draw about 9.8 amps at 120 VAC and 4.9 amps at 230 VAC service. I suggest as I mentioned earlier you check the name plate data on your pump(s).

Ron
 
Last edited:

MisterBill2

Joined Jan 23, 2018
9,025
Going back to post #1, the TS wants to be able to verify that the sump pump is operating. There is no need to read the current. So now a quite different idea comes to mind, which is to use a reed switch with a few turns of wire sized to carry the load of the motor. So probably #16 would work fairly well. Of course, the wire should first be wound on a solid form of a similar diameter, then slid over the reed switch, because a glass reed switch is rather fragile. That would be the least complex method and would not take a lot of extra electronics. In addition it is well isolated from the AC mains. The complex portion of the project would be creating the series connection for the sump pump power, but that can be done with a simple plug and socket pair, similar to building an extension cord.
 

Reloadron

Joined Jan 15, 2015
5,997
Going back to post #1, the TS wants to be able to verify that the sump pump is operating. There is no need to read the current. So now a quite different idea comes to mind, which is to use a reed switch with a few turns of wire sized to carry the load of the motor. So probably #16 would work fairly well. Of course, the wire should first be wound on a solid form of a similar diameter, then slid over the reed switch, because a glass reed switch is rather fragile. That would be the least complex method and would not take a lot of extra electronics. In addition it is well isolated from the AC mains. The complex portion of the project would be creating the series connection for the sump pump power, but that can be done with a simple plug and socket pair, similar to building an extension cord.
That or just spend $13 for the LED arrangement I mentioned. Just a matter of if someone actually wants to see a number or not. Then too, just because a pump is drawing current does not mean it is moving water. So yeah. roll your own using a small coil around a reed switch, use a small coil with a built in diode and LED or whatever trips your trigger depending on what works for you. If we don't want or need numbers things get real simple. :)

Ron
 

Thread Starter

zirconx

Joined Mar 10, 2010
130
Thanks for all the feedback. I did consider an ACS712 module, but I want my sump pump to be absolutely reliable, and from what I can tell on the ACS712 module, the current flows through a semiconductor. So there is a greater risk of something going wrong, vs a simple current transformer. Perhaps I'm wrong, if so I might be open to using that. Still there are the screw terminals that could come loose over time.

Yes I only need to know if it's running. And I don't want to purchase a $100 a commercial device (CR Magnetics).

I have tried a reed switch - I modified a power strip to have an loop (only the hot wire - photo attached) inside which I inserted a reed switch. But when measuring continuity across the reed switch, my DVM made a ton of noise, a screeching noise. I think it may have been picking up noise from the AC circuit? I was worried this "noise" would damage the raspberry pi.

I've also tried this non-invasive current sensor from Modern Device which you position on the outside of the power wire. But I could not get it to work reliably.

Thank you for the CR2550 $13 led suggestion, that would let me know the pump is running, but I need my software to know. And Reloadron you are right that just because the pump is drawing current, doesn't mean it is pumping (my last pump failed that way - constantly on, swirling water, but not pumping it out). But I also have a fluid level sensor in the sump pit. So if the pump fails, I should get an alert when water rises above a certain level.

So my plan will be to put my DVM on the current transformer outputs and measure an AC voltage when the pump (or a similar load, I believe it's around 8A 120v) is running. Then I hope to devise a circuit that can trigger an input pin. Maybe there will be enough current (after I rectify it) to switch on a small transistor? Or I also have an optocoupler I could use.

I am looking at the circuit Reloadron posted, I don't fully understand it. There's a voltage divider, sending 2.5v to the current transformer board? Then I don't follow the rest of it, sorry.

Thanks again for all the feedback.
 

Attachments

Reloadron

Joined Jan 15, 2015
5,997
OK to answer a few questions. Most A/D converters won't take a signal going below 0.0 volts, unless the A/D is designed for it driving the analog input below zero will destroy the unit. The Raspberry Pi does not have an onboard A/D converter so you need to add an A/D module. I know an Arduino can't be driven below zero. This is a problem since we are dealing with an AC signal from the Current Transformer. The sine wave goes positive and then negative in alternate half cycles. Thus what we normally do is offset the AC signal so the entire signal (positive and negative peaks) remain above zero volts. The circuit I posted is just a simple common example of how that can be done. So if for example we have a 2.5 VDC offset and our signal is 100 mV/Amp (Sensitivity) with a +/- 20 amp sensor with 20 amps AC applied the output will swing between 0.5 Volts and 4.5 Volts. This way we remain above that 0.0 volt we can't go below. As designed using just a plain current transformer the AC signal is going to go below 0.0 volts so we use some offset. Next, while I am far from a Python or Raspberry Pi type I know the Raspberry Pi does not have onboard A/D conversion so you need a module.

The common module here is an example of an external ADC (such as the MCP3008) can be used, along with some SPI code in Python to read external analog devices. Here is a link to some additional information. The Pi does have DI (Digital Inputs) which since you only want to know if there is or is not current possibly can be done easily. Rather than a LED like I linked to just use an AC type opto-coupler which are common and inexpensive. That is just an opto-coupler with internal back to back LEDs so they conduct on alternate half cycles of the AC waveform developed across your burden resistor of the current transformer. AC type opto-couplers are very common and with a Google you may even find some as complete modules and they are very inexpensive typically under$5 USD. This would give you a simple basic Yes/No as to current on the pump. It would also allow for a simple digital input to your Pi. Throughout all of this keep in mind you are still dealing with an AC signal. You need to allow for that in your code. Here is an example of a pretty common AC opto-coupler. Note the use of the back to back LEDs in the data sheet. The output side pin 5 the collector would go to VCC through a 10K resistor and pin 4 the emitter to your DC common. The input side would use a current limiting resistor based on whatever output you read from your current transformer. This is likely the simplest way to get a yes or no as to current flow using your CT. :)

I merely tossed out the more expensive methods to let you know they were out there.

Make sense?

Ron
 

MisterBill2

Joined Jan 23, 2018
9,025
One really cheap way to verify that it is actually pumping water would be to tape a cheap crystal microphone to the discharge pipe just past an elbow in the pipe, where the flow would be noisy. Then have a bit of amplification followed by a rectifier and iit would be the noise of rushing water that triggers the processor board to know the pump is working.
 

Thread Starter

zirconx

Joined Mar 10, 2010
130
One really cheap way to verify that it is actually pumping water would be to tape a cheap crystal microphone to the discharge pipe just past an elbow in the pipe, where the flow would be noisy. Then have a bit of amplification followed by a rectifier and iit would be the noise of rushing water that triggers the processor board to know the pump is working.
Heh, I did actually try that. I used this sensor: https://usa.banggood.com/Microphone...etection-Module-Whistle-Module-p-1235446.html
I had to add some external circuity and a bit of code to make it work. I thought the sensor would trigger when there is sound. Instead it continuously toggles the digital output when there is sound. It also picks up false signals from kids jumping around in the room above the sump pit room. I never did get it working reliably.

OK to answer a few questions. Most A/D converters won't take a signal going below 0.0 volts, unless the A/D is designed for it driving the analog input below zero will destroy the unit. The Raspberry Pi does not have an onboard A/D converter so you need to add an A/D module. I know an Arduino can't be driven below zero. This is a problem since we are dealing with an AC signal from the Current Transformer. The sine wave goes positive and then negative in alternate half cycles. Thus what we normally do is offset the AC signal so the entire signal (positive and negative peaks) remain above zero volts. The circuit I posted is just a simple common example of how that can be done. So if for example we have a 2.5 VDC offset and our signal is 100 mV/Amp (Sensitivity) with a +/- 20 amp sensor with 20 amps AC applied the output will swing between 0.5 Volts and 4.5 Volts. This way we remain above that 0.0 volt we can't go below. As designed using just a plain current transformer the AC signal is going to go below 0.0 volts so we use some offset.
Ok I think I get it now, thank you.

Next, while I am far from a Python or Raspberry Pi type I know the Raspberry Pi does not have onboard A/D conversion so you need a module.
Correct. I do have an ADS1115 wired up to the pi. So if necessary I can read the signal from there.

The common module here is an example of an external ADC (such as the MCP3008) can be used, along with some SPI code in Python to read external analog devices. Here is a link to some additional information. The Pi does have DI (Digital Inputs) which since you only want to know if there is or is not current possibly can be done easily. Rather than a LED like I linked to just use an AC type opto-coupler which are common and inexpensive. That is just an opto-coupler with internal back to back LEDs so they conduct on alternate half cycles of the AC waveform developed across your burden resistor of the current transformer. AC type opto-couplers are very common and with a Google you may even find some as complete modules and they are very inexpensive typically under$5 USD. This would give you a simple basic Yes/No as to current on the pump. It would also allow for a simple digital input to your Pi. Throughout all of this keep in mind you are still dealing with an AC signal. You need to allow for that in your code. Here is an example of a pretty common AC opto-coupler. Note the use of the back to back LEDs in the data sheet. The output side pin 5 the collector would go to VCC through a 10K resistor and pin 4 the emitter to your DC common. The input side would use a current limiting resistor based on whatever output you read from your current transformer. This is likely the simplest way to get a yes or no as to current flow using your CT. :)

I merely tossed out the more expensive methods to let you know they were out there.

Make sense?

Ron
Yes, and I do have some optocouplers, I will investigate this.

Thanks!!
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
23,363
For simple detection for presence of current MicroSwitch/Honeywell have a wide range such as the CSDA1DC version etc.
Very simple to interface.
Max.
 

MisterBill2

Joined Jan 23, 2018
9,025
OK, back to using that simple current transformer to provide a digital input. Once the output voltage from that CT is understood, and since it is still AC at that point, a very small step-up transformer followed by a rectifier and filter can provide the logic-level signal needed.That is about as simple as it can get. It might even be that with that "102" SMT resistor removed that the voltage would be high enough without a separate transformer.That should be simple enough to measure. A higher resistor value will allow a higher voltage, and so replacing the 100 ohm resistance with a 1000 ohm resistor would be a good start. Since the need is only for an on/off indication the lack of accuracy would not matter.
 

Thread Starter

zirconx

Joined Mar 10, 2010
130
Ok I've received the sensor. I tested my pump, it draws 4A. I don't have a 120v AC device that draws 4A load to test with (the pump is located far from my work bench so I can't easily use it for testing), but I do have a 120VAC heater that draws 5.3A, so I've been using that for testing.

With 5.3A drawn, I get 2.9v (AC) out of the sensor. With two turns through the transformer (it was very tight, I could not fit more than two turns) I get 3.5v. This was RMS voltage shown on my DMM.

I wanted to see if I could use the output to turn on a transistor or optocoupler, so to approximate that I added a diode & 100R resistor in series with the sensor output and measured the current: 3.5ma @ .3v. I doubt I could turn on a transistor or optocoupler with that.

So my next plan is to remove the 100R burden resistor, and add a much higher value one. Hopefully I can get the sensor output voltage high enough to rectify it, and use it directly as a logic signal. But how will I limit voltage spikes? The pump likely draws much more than 4A when starting up. I would feel safer using a transistor or optocoupler. Maybe a zener to ground will limit voltage spikes? But that might not be fast enough? And I believe I need a series resistor also when using a zener for voltage protection, I don't know if I have enough current available to get adequate voltage after the series resistor.

It's starting to look like simply rectifying this and hooking it up to one of my open ADC channels on my ADS1115 might be the best option.
 

MikeA

Joined Jan 20, 2013
257
With 5.3A drawn, I get 2.9v (AC) out of the sensor. With two turns through the transformer (it was very tight, I could not fit more than two turns) I get 3.5v. This was RMS voltage shown on my DMM.
Is "the sensor" here the current clamp shown in the picture above?

It's 1000:1.

100 Ohms ÷ 1000 turns × 5.3A = 0.53V AC * 0.707 = 0.3535V AC RMS

You should see 0.3535V AC RMS with a 5.3A load, and exactly double with 2 turns.
 
Top