Filtering spark plug inductive clamp signal for uC

Hello everybody. I am trying to read some gasoline engine RPM with a cheap spark plug inductive clamp (model BT-705A) and a microcontroller with little results.
Inside the clamp there's a little pcb with few components, i will show you the schematic:


The only 3 known value components are written in the drawing. Still 1 unknown diode (glass one like 4148) and 2 caps (small smd ones).
I don't have an oscilloscope to hook up to the output to see the signal shape.
I need to condition the output to be a 3v3 square wave to a uC, but how?
I have tried to wire the sensor to a LM358P as a comparator with little result but unreliable readings.
I'm pretty strong with programming but not so much on hardware, so any help would be appreciated.

Would a multimeter in DC at 1000vdc to start, with "peak hold" get the amplitude of the output?

With the clamp hooked "the right way"(it has an arrow, it should point the spark plug) max=104mV min=76mV.
With the clamp hooked "backwards" max=164mV min=42mV.

EDIT: I also have another similar clamp (SCT-013 100A>50mA) which could be repurposed for the same reading with the right conditioning if you think that would be easier.

I think you better build an interface/optocoupler (LM393 or 4N35) circuit to protect your Arduino, but if you've already measured its output to be within a few mV, I think you just need to adjust the voltage levels to allow the Arduino's ADC to give you more reliable signals (e.g. raising the signal from a few mV up to around 3.5-4 V or 5 V max).

But check out this "similar" thread:

It seems they solved the problem by using this sensor (its disadvantage seems to be the 12V power requirement, but for automotive applications I guess it won't be a problem):

Think you can build this?
Note: It needs 5V and 3.3V supply

@docdoc Thanks for the links but i already checked the whole forum out before opening a new thread. I also had found a circuit with a 555 to get a Square wave out of a clamp like mine but without the internal filter, but a)i dont have 555s around and b) id like to use the clamp out of the box without removing the internal circuitry because in the future i Will Need to build several of these.

@jim-p Thank you very much, i Will build It asap! I Will use a lm358 instead of the 393 because ive got several 358s lying around.
Just One question:
My uC is 3v3 and not 5v tolerant. (Esp32s3).
If instead of providing 5v to the opamp vcc i provide 3v3, would It work anyway? I guess even if the output would be somewhere lower than 3v3 It would still be a Logic High for and interrupt on my esp, am I right?

Hi, @conny1102

What are 328p?
LM393 is a dual voltage comparator.

Tom.... :smiley: :+1: :coffee: :australia:

The LM393 is not an opamp and I only guarantee that the circuit will work as is. It will also work with a LM339

It may or may not work with Vcc=3.3V so I don't recommend it. However Vcc can be any voltage bewween 3.8V and 36V. So if you have 12V that will also work.

Can you buy parts from Digi-Key, Mouser or another major electronic parts distributor?

@TomGeorge It was a typo, i have got lm358 opamps.

@jim-p okay then i will buy some lm393 and try your circuit on a perfboard. Will update you on the results!

If you can but an MCP6547 you can use it in the same circuit and it will work with Vcc=3.3V

I didn't say that, just use an adapter circuit to protect Arduino and level the voltage up.
Like the one from @jim-p

Hi everybody again. I have not yet realized the suggested comparator (bought the components tho); instead i have put my hands on a usb oscilloscope to visually see what's happening before tinkering with solder. Testing the clamp on cylinder n1 of a renault d4f engine (n4 really, closest to gearbox) , 4 cyl 4 stroke, single (packaged) ignition coil with 4 output HV wires for each cylinder. It should be a wasted spark system with 2 (hidden inside the package) coils, one for each couple of cylinders (14, 23).
Here's what i see ad idle (750rpm):


Until now, you would say: Very much clean spikes, threshold at 400mv and a comparator will square it fine. Unless i tell you that what i'm seeing is all 4 spikes from all 4 cylinders.
Here's a picture at 3000rpm:

The highest spikes (n1 n5 n9) are the one i'm interested in reading, as they are effectively the ones fired for igniting that specific cylinder.
Spikes n3 and n7 are fired from the same (i guess) coil but in the other cylinder, so we see less spiky pulse.
All the other (even numbers) spikes are literally noise from the other coil firing the other 2 cylinders. So instead of seeing 1 spike every 2rpm (or 1sp1rpm would be fine too) i see 4 spikes every 2 rpm.
That wouldnt be a problem either, a comparator should square them all and then with some microcontroller math i should be able to read the correct number.
Unless i finally show you what happens from 4000rpm on:

As you see, when spark happens in cyl n4 (the one i'm analyzing) i don't see a single spike every spark but instead 2 of them in the same 2ms cycle, so even if i set up a carefully calibrated comparator, often, when cruising at high rpm i read 2 spikes for every (real) spark so that fricks up my math. Even if i use heavy software filtering this is not reliable as at 4krpm and above i read double spikes.
If you were me, how would you make this mess be capable of accurately reading the rpms from this signal?
Should i use a very low threshold, count every spike (even the ones in other cylinders) and do the math with software to get my accurate reading?
Should I, instead of a comparator or after it, setup a ne555 as monostable to ignore everything after the first peak for some time?
Thank you in advance for your time and knowledge.

Both are available on the header pins of UNO R3.

Please show a schematic

A SN74221 non-retriggerable one-shot for example.

What is the ground connected to as shown in your schematic inpost #1

to nothing really. in my experiments am hooking it to the same gnd as car,comparators/opamps and esp32. Testing with lm393 in few minutes, i'll update you soon.
edit: also in the oscilloscope graph, + is connected to the probe + and - to the probe gnd, isolated from the car or whatever else.

You have written that you are using an inductive clamp for the signal. But, the scope display shows you also have a capacitive coupled clamp giving the unwanted signals. Is your clamp shielded so it truly can only see inductive pulses?

I am using that inductive clamp i posted on the #1. Inside the clamp, hooked to the secondary coil (the primary Is Just open to put the HV wire into It) there is a small PCB with those components and then It goes to the output wires of the clamps. The scope Is hooked with the probe hook to the Red output wire and the probe gnd to the black output wire.
The "unwanted signals" do exist because of the engine design: in inline 4 engines, specially old cheap ones like this, the ignition is performed by 2 hv coils instead of 4 using the "wasted spark" method, One hooked to cyl1 and cyl4 and the other in 2&3. That means, as long as pistons move in couples, whenever piston 4 is at top dead center in the compression phase, piston 1 is in the exact same position but at the end of exhaust phase. Clever (cheap) engineering suggests you can fire a Spark from hv coil 1 secondary terminal 1>Spark plug in cyl1>gnd>Spark plug in cyl4>hvc1t2. And It will ignite the only cylinder of the two Who effectively has the compressed air-gasoline mixture inside, literally wasting the Spark in the other cylinder whose contents Is smoke.
Unfortunately, that also means that if a single spark plug or hv wire fails, 2 of the 4 cylinders won't work, but it's fair and cheap enough.
Furthermore, in my specific car both the HV coils 14-23 are in the same black plastic packaging, connected to the ECU with a single 4-5-6(dont Remember exactly)pin connector.
Plus that, all 4 hv Spark plug wires are routed with very limited space from One another, 5-10mm at most, in some places touching eachother, so capacitive coupling happens both inside the coil pack and between the wires routed to the Spark plugs, there's little I can do about It. (See picture of you're curious)


In my tests i hook the clamp to the HV wire that goes furthest to the right.

Anyways, that's not an issue for two reasons: the only drawback from having double the signals I Need is i have to make an adjustable variabile to divide the Number of signals per RPM based on how many signals I get per RPM (1SIG1Rpm in a 1cyl 2stroke, 1sig2rpm in a 1cyl4stroke or, like in my case, 2sig1rpm because i read the other cylinders firing.)
In my specific case, that doubles my accuracy in Reading RPM, as long as I manage to Square that spikes for an interrupt.

Yesterday i put the lm393 circuit @jim-p designed on a perfboard and tested It with no results (comparator doesnt trigger), i guess i made some assembly mistake and havent double-checked everything yet, i will double check It asap.

The other issue still-to-be-fixed Is: even if It works, at High revs one every 4 spikes goes 0-3-1-3-0v so It would trigger the comparator twice per single spark. That could be fixed with a monostable o software debouncing at (max square wave pulse width), effectively capping the max readable pulse frequency but enough for my project. As long as I manage to set a working comparator up :rofl:
That wont happen sooner than the up coming monday, so we'll see, i'll keep you updated.

Hi people, i'm still having a headache with this system.
My circuit design is slightly different from @jim-p circuit (no diodes and non-inverting comparator setup), and rn having weird behavior as you'll see in the scope screenshots.
First, this is my current design: sorry if it's messy but it's just a 5min-chaos-drawn comparator just for these tests. Everything is soldered in place in a perfboard.


The most significant changes ive made are: adding a potentiometer instead one of the two resistors of the voltage divider to have a trimmable 0-2.5v threshold and a setup a voltage divider instead of double power 5v/3v3 to have a 3v3ish output.
all external connections are done with dupont females to another really simple perfboard like this:
12v + and - > to the car battery and to a small chinese buck converter set to 5v3A.
5v output from the dcdc and gnd (same as car) hooked to a esp32s3supermini and brought out with two 20cm wires to the comparator board.
gpio8 of the uC > to the out_3v3 pin.

Now, this is what i see with the scope:


ch1 (yellow) is hooked up to the sensor + pin.
ch2(blue) is hoohed up to the output central node of the voltage divider.
ch3(purple) is hooked up to the central pin of the pot (threshold)
all probes gnd to the battery -/car chassis.
Problem: the threshold trimmer doesnt behave as expected. if I set the threshold to 2.3v and below, the "0" level of the sensor shifts up alot, as you can see here:

and the output goes always high.
So i cant do fine adjustments to the threshold, and can capture only really high spikes with very much inconsistency(scope snapshots with input hidden):

While writing this post, i realized i probably hooked up the trimmer in the most random way at 2am after a 12h long shift, so maybe i could fix my mistakes just by rewiring the trimmer like this:


cutting two wires and adding the blue ones.
Does it make sense? please don't judge the beginner mistakes as i'm just learning.
any heads up will be helpful.

Before hooking all up to the car, i hooked this same comparator to a 555 astable square wave generator to test thresholds and everything, and it seemed working quite fine, here's the scope snapshots:



as you can see, during breadboard bench tests, adjusting the threshold as little as 0.06v would shift the output from a clean low to a pretty clean square wave.
What am I getting wrong? would that rewiring of the pot solve my headache? any better ideas?
Appreciate everybody's help as it makes my brain bigger :brain: :smiley: