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

#### 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)

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,017
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.

Joined Jan 15, 2015
5,996
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.

Ron

#### 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

• 1.4 MB Views: 8
• 1 MB Views: 8

Joined Jan 15, 2015
5,996
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,017 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:

Joined Jul 18, 2013
23,357
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,017
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.

#### 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.