# Reading oil pressure switch from motorcycle with Teensy (Arduino)

I'm trying to read a oil pressure switch (I'm actually not sure about the sensor type) from my motorcycle (ZX6R) with a Teensy 4 board (Arduino like). Here is a picture from the electrical schematic:

Measuring BL/R to ground with a multimeter it looks like it's a closed circuit when the switch is open while it opens once the bike starts up and therefore there is oil pressure. Hooked it up on a digital pin with pullup and of course I fried the board. Then I hooked up again the multimeter and (with the bike running) I see an AC voltage with freq and amplitude that changes with RPM. Then I measured it with an oscilloscope as differential voltage BL/R to ground and I see a voltage that oscillates symmetrically around zero with a varying amplitude between a few mV and 1.5V (I bet if rev up the engine more the amplitude and frequency will continue to rise almost linearly).

The BL/R wire goes straight to the dash that powers an LED. The stock dash will be removed.

2 questions:

1. any idea of what kind of sensor it is?
2. how do I safely measure it with a Teensy board? (digital is 3.3V tollerant)

As you can see I don't have much clue of what I'm doing but I have tools and willing to figure this out :)

Thank you

1. It's a switch that connects to ground when there's no oil pressure. Measure it with an ohmmeter with the wire disconnected: should show a low-ohm when the engine is stopped, and open when the engine is running.
2. If there's no LED connected to it, in theory you could pull the switch up with a resistor to 3.3V.

The safer way would be to use a diode to isolate the Teensy, as follows:

simulate this circuit – Schematic created using CircuitLab

MORE: The lamp on the dash would have pulled the Teensy pin up to 12V or so, which would have killed it.

As for the ESD protection, I deliberately chose components that are easy to find.

How it works:

• D2 blocks any current in (any voltage higher than 3.3V)
• D3 clamps the input to GND - 0.7V
• Any below-ground fault current is limited by R2.

It's simple and should work fine.

If you want to beef this up even more, you have a couple of options:

• Use a Schottky diode for D3
• Use a Transient Voltage Suppressor (TVS) diode for D3

The Schottky diode has a lower forward voltage (0.3V) and faster response. A TVS is basically fast-acting Zener diode that catch both negative or positive spikes. But, D2 already blocks positive spikes, so that's overkill.

Finally, would a capacitor help? Only if you connect it so that it shunts energy back to the originating source, that is, someplace close to frame ground. If it's to Teensy ground it would actually make things worse as it provides and AC path to the logic ground, then back to the frame.

• I’d add a capacitor for some filtering and ESD protection as well. Mar 25, 2021 at 3:26
• thanks. The Teensy has an internal pullup already, I can't find the actual circuit tho. Being just a switch that connects to ground, what could have fried the Teensy? Would you be able to provide a circuit with a cap and the ESD? Mar 25, 2021 at 8:28
• The pullup is maybe not strong enough to reject noise. That's why I provided an external one. Mar 25, 2021 at 19:25

Vehicles are very electrically noisy places. The wire from the switch will be running in the same loom as a bunch of other wires, and will be capacitively coupled to them. You may also be picking up induced spikes from the ignition system.

As in the answer by hacktastical, you will need diodes to block voltages that are out of range, maybe capacitors too. Make the pull-up resistor relatively low, so that if the switch is off, the line is firmly pulled to your Teensy's supply rail.