Reading from a CT Sensor pin affected by Seven Segment Displays switching on and off

The control unit I’ve designed for my workshop, powers up a dust extractor when a saw is switched on and powers down when switched off.
Two 3-digit seven segment displays are connected to a clone Arduino Nano through a Max7219. The output of a CT sensor (ZMCT103C module) attached to the saw is displayed on one 3-digit seven segment display. A threshold voltage, when the extractor turns on and off, is displayed on the other. A trim pot is used to adjust this threshold voltage. This calibration is necessary to account for variation in background noise and CT output voltage variations between different saws. The displays are normally dormant and come on for 15min when the pot is adjusted, allowing for calibration of the threshold value. All this works well. The issue I have discovered though, is that when the displays are on the background reading from the analog pin (A5) is about 180mV higher than when the displays are off, typically around 200mV instead of 20mV. To 100% confirm it isn’t an issue with the code, I validated the serial monitor output with multi-meter and found that all the analog pins are affected similarly.
Given that the calibration is done with the displays on, the threshold value will not truly reflect what happens during normal operation, when the displays are off.
Is there a way to isolated the analog pin so it isn’t subject voltage variation, when the displays are switched on and off?
I’m pretty sure I’ve narrowed down to the problem, so to keep it simple, am only showing the part of the circuit related to the displays and calibration of the sensor. If this doesn’t explain the problem fully, happy to provide the code and the rest of the circuit.

The schematic looks like it could be good. However it is really too small to be readable.
What is the origin of the 5 volts? Via the Nano's USB cable ?

If the power consumption of the Current Transformer module is less than 20mA at 5 volts, you could try powering it instead through a Nano digital pin, defined as OUTPUT and switched HIGH.

That is one of the fun things with A/D converters, they are very sensitive to any voltage change on the Aref pin and electrical noise. It appears you have the display powered from the Nano and when the LEDs turn on the voltage of the board drops a bit and when that does the Aref also drops. Using an external power supply to power the LEDs will help.

NM I overlooked something...

Sounds like a build problem.
The pot must have it's own (not shared with the display) supply and ground wires to the Nano.
The display supply must be decoupled with a 100n ceramic and 100uF electrolytic, close to the chip.
If that doesn't work, then you could try a rotary encoder instead of a pot.

Sorry about the size of the image. This is my first time posting on this forum and wasn’t quite sure the best way post an image. This time I’ve attached the image as a file and included the rest of the schematic. Maybe this is clearer.

Good feedback with a few options to try.

Using a digital pin as a power supply for the displays sounds like an easy fix, so I’ll try that first and then work through the other suggestions.

Thanks for the help.

There is a lot wrong with that diagram.

Unreadable, because conventions (supply up, ground down, signal left to right) are not followed.

D2 is doing nothing there, should go across the solenoid.
The opto or transistor could fail, because there is no base resistor.
The switch should not be connected to V-in.
The 5volt regulator output feeds into a 12volt-12volt DC/DC converter (makes no sense).
VCC and Iset of the MAX7219 are swapped.
There might be more.


Being self-taught with a lot to learn I’m not surprised that I’ve transgressed many schematic conventions. Thanks for the tip.

The connection of the diode D2 doesn’t reflect the actual circuit, which is as you suggest, so just sloppy on my part.

The Base on the 4N35 is not connected, so I’m not sure what you mean about a Base Resistor. From what I’ve seen, the Base is usually left unconnected in this situation. Should I connect the base to GND with a resistor? 4.7K? Or are you suggesting I need a resistor between Pin 5 on the 4N35 and 12V or both?

I used the MEE3S1212SC symbol because it has the right footprint for the 5V to 5V DC converter / isolator I’m using. Again, soppy and misleading on my part.

Maybe not the best response, but the switch works OK connected to VIN. I presume you would recommend connecting it 5V instead. Can you explain the concern?

I looked at the MAX7291 datasheet again and think what you are saying is that the R2 50K resistor should be between 5V and ISET, rather than 5V and VCC. Is this correct?

Back to the original issue I have, which is the seven-segment display affecting the voltage output of the pin connected to the CT Sensor.

I’ve tried using a digital pin, defined as OUTPUT and switched HIGH as a power supply as suggested. Tested the output and it gives 4.7V, but no luck getting it to power the display.

Tried different decoupling caps without any change, and suspect this is not the solution, given that the display changes the voltage at the CT Sensor pin with a constant voltage increase, which incrementally gets bigger as I switch on more LEDs in the display. As I understand this constant interference is not the sort of noise decoupling caps address.

Disconnected the pot altogether. This had no effect, so is not the cause of the problem.

Powered the display with a completely independent 5V source – another Nano, and this, not surprisingly, eliminated the problem. This is not a practical permanent solution though. Does using another 5V to 5V DC DC converter / isolator Free Ship 10pcs/lot Hi Link 1W 5V 200mA output DC DC converter module HLK 1D0505|Home Automation Kits| - AliExpress between the Nano GND / 5V and the display an option?

Thanks again for the feedback. As I say this is my first post to this forum and it’s helped to better formulated my future questions and above all to ensure my schematic accurately reflect my actual circuit.


An opto coupler is like a switch. You can't just switch/connect the base of the TIP120 to 12volt. The base of the TIP120 must have a current limiting resistor. 1k to 2k2 would do.

Can't have a 12>5volt linear regulator and a 5volt switching regulator in series.
Use one or the other. A switching one is of course more efficient (no heat).

Back-powering the 5volt regulator of the Nano is bad (5volt, to V-in, to the switch).
Just connect the switch between pin and ground (like you already did with the rotary encoder),
and enable internal pull up on the pin with pinMode (no 2k2 resistor needed).

VCC is 5volt power for the MAX7219.
Iset sets the LED current (with a resistor between VCC and Iset).

Not sure which ZMCT103C module you have. You seem to use it's analogue (not the digital) output. Not sure why you think it needs a 50k resistor. Don't know how you are sampling this (AC) output. It may need thousands of samples per second, and peak detection.
Show your code.


Thanks again for the feedback.

The power input is the one part of the circuit I haven’t tested fully yet. My objective is to provide the Nano with an isolated and regulated supply, in particular, to protect the CT Sensor pin from any extraneous voltage. I’ve used a L7805 connected to 5V and it works OK, but doesn’t isolate the Nano from the 12V supply. I’ve used a 12V to 5V DC DC converter / isolator (20pcs/lot free ship 12v ac to 12v dc converter HLK 1D1212 1W 12V 84mA output variable dc dc converter isolated module|Home Automation Modules| - AliExpress ) and this works OK connected to both Vin and 5V. The problem with connecting to Vin is that 5V input is outside the voltage spec for that pin. The problem with connecting to 5V is that that pin is unregulated. I am reluctant to use a 12V to 12V DC DC converter / isolator connected to Vin, as I am concerned that the 80mA current may not be quite enough in all circumstances. I thought, obviously erroneously, that connecting the voltage regulator and converter in series would achieve the desired outcome. Do you have any suggestion on how to get both regulated voltage and isolation?

See link for an example of the ZMCT103C module 5A Range Single Phase AC Active Output Onboard Precision Micro Current Transformer Module Current Sensor For Arduino ZMCT103C|Integrated Circuits| - AliExpress. I’d previous used a TA12-100 (Analog Current Meter Module AC 0~5A Ammeter Sensor Board for Arduino Based On TA12 100 3PIN Interface Sensor Brick 5V I/O DIY|Integrated Circuits| - AliExpress ) but switched to the ZMCT103C because it provides an amplified signal and the potential to calibrate the output voltage across devices.

The R3 50K resistor is to pull the pin to ground, otherwise the CT reading floats all over the place. I just played around until I found a value (50K) that seemed to work best. See attached code for the CT Sensor (I haven’t attached the code for the full system, as the latest version relating to this hardware setup is still a WIP and I expect would only confuse matters)

I’ve tested the sampling quite a bit to get optimum readings. My main issue has been random voltage spikes. I’m trying to overcome this through isolating the supply and also with the code. You will notice that the code returns the second highest reading in a sample set. This seems to be a pretty effective way of bypassing momentary spikes in voltage.


The sketch below is designed to sample a CT sensor output to determine when a device is on or off.
It does this by taking a series of samples for a period of time and returning the maximum value for
that sample set. This is repeated a set number of times to return multiple maximum values.
The second highest maximum value is selected and compared with a threshold voltage reading to
determine the device’s status. The selection of the second highest maximum ensures that only a
sustained increase in voltage greater than the sample period is used and transitory peaks are
excluded. As such, external voltage spike commonly seen in this type of set up are excluded.

float Voltage_Threshold = 0.12; // returned maximum values above this indicate the device is on

int ZMCT103C = A1;

float CT_Data;

void setup()

void loop()
Serial.print("Voltage_Threshold : ");Serial.println(Voltage_Threshold);


float get_CT_Data()
unsigned int i = 0;
const int Num_Sample_Sets=5; // number of sample sets
int Sample_Period = 100; //sample perod in millisecs
int Max_Values[Num_Sample_Sets]; // Array to store maximum values from sampling

for (int z=0; z < Num_Sample_Sets; z++) // resets the maximum value array
{Max_Values[z]= 0;}

float result;

for (i=0; i<5; i++)

int readValue; // stores individual CT sensor values
uint32_t start_time = millis();
while((millis()-start_time) < Sample_Period) //sample time millisecs
readValue = 1024-analogRead(ZMCT103C); // change this for different CT Sensors
if (readValue > Max_Values[i]) // sets the newest maximum value
Max_Values[i] = readValue; //returns the maximum sensor value
} // repeats the sampling i times

// Bubble sort maximum sample values from lowest to highest

for (int x = 0; x < Num_Sample_Sets; x++){
for(int y = 0; y < Num_Sample_Sets-1; y++){
if (Max_Values[y] >Max_Values[y+1]){
int tmp = Max_Values[y+1];

// prints the sample set
for (int i=0; i < Num_Sample_Sets; i++)
if(i < (Num_Sample_Sets-1)){Serial.print(',');}

//Serial.print("The second highest value in the array is: ");Serial.print(Max_Values[3]);

// selects the second highest maximum and converts the CT sensor value to an approx. voltage
result = (Max_Values[3] * 5.0)/1024.0;

Serial.print("CT_Data : ");Serial.println(result);
return result;


Please explain.
A current transformer already provides isolation between current-carrying wire and Arduino.
A solenoid is basically also isolated by design.
Why the double isolation.

THAT module only has a digital output.
You can't adjust current threshold with the Arduino, only with the trimpot on that board.

Thanks Leo, that was a quick response!

Re: Power Supply

I’m not 100% sure what you are saying. If you are referring to the Hi-Link DC DC converter as the current transformer, I agree it provides an isolated supply. But, if I use a 5V unit on the 5V pin the supply will not be regulated. If I use a 12V unit on the Vin, I’m concern I will not have sufficient current. If you are referring to something else then I’ve misunderstood.

Re: CT Sensor Reading

I’m not trying to adjust a threshold onboard the sensor. I take the reading from the sensor and compare this to an adjustable voltage threshold defined by the Arduino code. If the reading is higher than the threshold, I assume the saw is turned on and switch on the dust extraction system. If lower I switch the dust extractor off.

The reality is that this setup is in a workshop with lots of machinery and consequent random voltage spikes, which regularly trigger the dust extraction system to turn on. I’ve also found that the reading from the CT pin is polluted when the seven digit display is switch on.

My objective is to get a reliable, clean signal from the CT sensor.


No, I was referring to the current transformer on the current sensor module.
The wire you thread through that transformer hole is not in contact with the rest of the module.

You seem to have a digital module that outputs HIGH/LOW with current/no current.

If you want to set the threshold with the Arduino, then you should use a bare current transformer, without the parts on the module. And code that samples the sensor often.

Maybe I got this all wrong. Most of these sensors have a digital output, but this one could be different. I saw another post somewhere that claimed the sensor had an AC (sinewave) output, not just a DC voltage. That would require frequent sampling and peak detection.
Maybe time to connect a scope to the output of the sensor.

Thanks Leo,

I have already hooked the sensor up to scope and it produces a half sine wave as you would expect for a DC output. I’ve played around with the sensor quite a bit. As I previously stated, I’ve use used a TA12-100 for quite a while, which, apart from an onboard sampling resistor, is a bare current transformer. This works but I think the ZMCT103C module gives a cleaner more definitive output. I really don’t think I have an issue with the sensor output or sampling in isolation (on the test bench). I do have an issue with noise in the real world (the workshop) though.

So, back to the to power supply. If I use a 12V DC to 12V DC converter (10pcs/lot free ship HLK 1D1212 1W 12V 84mA output 12V DC DC converter module Isolated power supply|Home Automation Modules| - AliExpress) connected to Vin, I’ll have an isolated supply with regulated voltage. The current rating for this is 84mA. This is very close to my requirement of approx. 20mA for the Nano and 10mA for each of the six displays. I don’t think I have anything else in the circuit that will draw current. I’ve confirmed the requirement, when measuring the current draw it’s around 70mA. This seems a bit close for comfort. Am I worrying unduly and should I use this device? Otherwise what do you recommend to get the outcome I’m after? Also how do I best isolate the CT Sensor pin from the displays to avoid the voltage overlay, I’ve previously mentioned, when the displays are on?


Wouldn't a 12V to 5V converter make more sense? The Nano and the displays run on 5V. Converters also have regulation, so it wouldn't be "unregulated".

If you want to isolate ADC readings, use the internal voltage reference instead of the Vcc reference.

Also, with interference, substantial analysis and testing is required to confidently identify the source. It's premature to point the finger at components, when the layout and wiring can make a big difference.

If you know that the displays are generating interference, you should begin at the display and try to reduce the emission, rather than try to shield other parts of the circuit from it.

You've shown us a schematic and written a lot of comments about the circuit, but we've never seen any images or details about how it is implemented.

Hi Aarg,

Thanks for the feedback.

I have done extensive investigation and have found the other devices in my workshop being switched on and off generate significant voltage spikes, causing the dust extraction system to switch on. I also suspect there’s noise comimg from activity in adjacent premises, but this is very difficult to confirm. This noise can be picked up by the CT Sensor or via the Arduino supply.

I’ve try many different hardware / circuits setups to suppress the spikes coming through the sensor with only limited success, but I think I’ve solved the problem with the sampling technique in the code. I’m now looking at how I can ensure a clean supply voltage.

Unfortunately, I’ve looked at a number of different sources and the output for this type of converter is unregulated (clearly stated in the specs). I’ve tested the 12V-5V one I have and confirmed that voltage does vary significantly when I vary the current.

The constant overlay of 10-20mV from the displays, when switched on is a relatively minor noise problem, recently encountered, when I added the displays as an enhancement. It’s obvious that this is an internal circuitry issue.

When I’m at the workshop next I’ll take a couple of pics and upload them with my next post.


Sure, the CT sensor is a coil, it will pick up any changing magnetic field in its vicinity. But I've dealt with similar issues many times and found that it is not one but many things that cause it. When a motor starts or something like that, there are multiple paths to a circuit such as you describe. With noise and interference issues, a deep dive is necessary to get real answers.

For the images, try to expose details of the wiring and housing etc.

Hi Aarg,

It’s too difficult to get a photo of the actual CT sensors in situ as they are inside each of the devices they’re sensing. The live 240V mains is simply threaded through the donut of the sensor. I’m aware that the proximity of the sensor to other wiring will influence its behaviour, so have tried to locate sensor away from other wiring in the device. Not always possible though.

I have a controller for a sander, dropsaw, tablesaw router, bandsaw and jointer. It's important to note that the physical setup for each device is different and my objective is to design a sensor / controller setup that will work in a variety of environments.

The attached photos show a typical setup.

Each device has a controller. The photo of the sander controller with the cover off shows the 12V input, the sensor input from the sander and the 12V output to the solenoid opening and closing the blastgate. An onboard RF module on the Nano sends a signal to a Nano connected to a relay, which switches the dust collector on and off.

I’ve also taken a photo of a test setup, connected to a new version of the controller. The pot and displays allows for independent (from a laptop) calibration of the voltage threshold. You’ll notice I have both a TA12-100 and a ZMCT103C sensor connected to the test rig. This setup allows me to compare the performance of two sensors in almost identical conditions.


I’m not sure that your algorithm here, which appears to be a “peak detection” type, is really suitable for this application. It will be very prone to spurious spike effects. Maybe you should look at an algorithm which uses a current transformer For energy measurement type applications. These will continually integrate samples with respect to time and should deliver a much more stable result of the power provided to the device (circular saw etc.).

Here is one library which may be useful:


Can't you get a complete sine wave like say in this picture (taken from Blog of Wei-Hsiung Huang: Working with Current Transformer (CT) sensors ) ?


This has a DC offest applied so that it can be read by the ADC which cannot tolerate the negaive component. You can remove this bias when taking the analog samples by subtracting 511 (10 bit ADC).