Skip to main content

Featured Post

Why I Wrote The Sheet Mechanic (And Why Calculations Aren’t Enough)

For engineers who already know the math—but still lose projects. For the last few years, I’ve been sharing technical guides here on Mechanical Design Handbook —how to size a motor, how to calculate fits, and (as you recently read) how to choose between timing belts and ball screws. But after 25 years in industrial automation, I realized something uncomfortable: Projects rarely fail because the math was wrong. They fail because: The client changed the scope three times in one week. A critical vendor lied about a shipping date (and no one verified it). The installation technician couldn’t fit a wrench into the gap we designed. University taught us the physics. It didn’t teach us the reality. That gap is why I wrote my new book, The Sheet Mechanic . This is not a textbook. It is a field manual for the messy, political, and chaotic space between the CAD model and the factory floor. It captures the systems I’ve used to survive industrial projec...
NEW RELEASE: Stop trying to be a Hero. Start being a Mechanic. Get "The Sheet Mechanic" on Amazon »
Disclosure: As an Amazon Associate, I earn from qualifying purchases.

LJ12A3 Sensor Wiring: Safely Connecting 12V/24V to 5V Logic

The Failure Scenario: You bought an LJ12A3 sensor because it's cheap and industrial. You hook it up to your 12V or 24V power supply. Then, you connect the signal wire directly to your 3D printer mainboard (which runs on 5V or 3.3V).

Result: You just fried your microcontroller. The sensor sent 12V straight into a pin designed for 5V.

Inductive sensors typically require 6V–36V to operate, but most controllers (Arduino, ESP32, STM32) can only handle 3.3V or 5V signals. You need a "Logic Level Shifter." This guide shows you the three safest ways to fix this.

Advertisement

1. The Voltage Mismatch Problem

Most industrial sensors (like the LJ12A3) are designed for 24V PLC systems. While they *might* turn on at 5V, they become unreliable and prone to false triggers.

To get stable readings, you must power them with 12V or 24V. But this means the signal output will also be 12V or 24V. To read this safely on a 5V Arduino or 3.3V ESP32, you must step down the voltage.

2. Method A: The Voltage Divider (Resistors)

This is the classic electrical engineering solution. By using two resistors in series, you can split the voltage to a safe level.

  • For 12V Sensor -> 5V Board: Use R1 = 10kΩ, R2 = 6.8kΩ. (Result: ~4.8V)
  • For 24V Sensor -> 5V Board: Use R1 = 39kΩ, R2 = 10kΩ. (Result: ~4.9V)

Engineering Note: Ensure your microcontroller input is set to High Impedance (standard GPIO). Do not use this method on pins with internal pull-down resistors enabled, as it will skew the voltage reading.

Voltage divider wiring diagram for LJ12A3 sensor to Arduino
Figure 1: A simple resistor divider drops the high sensor voltage (Vin) to a safe level (Vout) for the microcontroller.

3. Method B: The Diode Trick (BAT85)

Common in the 3D printing community (Voron/Prusa), this method uses a Schottky Diode (like a BAT85). This only works with NPN Sensors.

How it works: The diode blocks the high voltage from entering the board, but allows the sensor to pull the pin to Ground (Signal Low) when triggered.

Requirement: You must enable the Internal Pull-Up Resistor on your microcontroller input for this logic to work.

4. Method C: The Optocoupler (Industrial)

The most robust method. An Optocoupler (like the PC817) uses light to transmit the signal, keeping the high-voltage sensor circuit completely electrically isolated from your delicate controller. This also prevents electrical noise from the motors affecting your sensor readings.

Advertisement

5. Summary: Which to Choose?

Method Complexity Safety Best For
Voltage Divider Medium (2 Resistors) Good General Hobby Projects
Diode (BAT85) Simple (1 Component) Good 3D Printers (NPN Only)
Optocoupler Board Easy (Plug & Play) Excellent (Isolated) CNC / Noise Prone Areas

Recommended Components


Burning a board costs $50. Burning a client relationship costs your career.

You know how to use an Optocoupler to isolate electrical noise. But do you know how to use a "Scope of Work" to isolate project noise? The Sheet Mechanic teaches you the project management protection circuits you need to survive engineering.

The math makes the machine work.
The Sheet Mechanic makes the project work.

About the Author:
This article is written by a mechanical design engineer specializing in industrial automation, sensor selection, and closed-loop control systems.

As an Amazon Associate, I earn from qualifying purchases.

Comments

Popular posts from this blog

Dowel Pins & Locating Pins: The Basics of Fixture Design

Figure 1: A typical fixture setup. Notice how dowel pins (silver) provide precise location, while bolts (not shown here) provide the clamping force. In the world of Precision Engineering , the difference between a high-quality product and a scrap part often comes down to microns. While bolts hold parts together, they are terrible at positioning them. This is where Dowel Pins and Locating Pins become essential components in industrial tooling . Advertisement What is a Dowel Pin? Dowel pins are precision-ground fasteners used to secure the relative position of two parts. They are typically machined to extremely tight tolerances (often within 0.0001 inches) and are available in materials like: Hardened Steel: For high-wear applications in CNC fixtures . Stainless Steel: For corrosion resistance in medical or food processing machinery. Plastic (Thermoplastic): For lightweight, non-conductive, low-load alignment. The ...

Engineer's Guide to Ball Detent Torque Limiters

Figure 1: The ball detent mechanism provides precise overload protection by disengaging instantly when the torque limit is exceeded. The First Line of Defense: Overload Clutches In high-speed automation and heavy industrial machinery, a "jam" is not a matter of if , but when . Whether it is a cardboard box getting stuck in a packaging machine or a tool crashing in a CNC lathe, the resulting torque spike can destroy gearboxes, twist shafts, and burn out expensive servo motors in milliseconds. A torque limiter (or overload clutch) is the mechanical fuse of the drive system. While electronic monitoring (current limiting) is common, it is often too slow to prevent physical damage from the massive kinetic energy stored in the system inertia. A mechanical torque limiter provides a physical disconnect that operates in a fraction of a second. Search for Torque Limiters & Safety Couplings Advertisement Why Choose ...

Stress Analysis Explained: Mohr's Circle, Tresca, and Von Mises

The German engineer Otto Mohr (1835-1918) developed a useful pictorial interpretation of the equations for finding principal stresses and maximum shearing stress at a point in a stressed member. Advertisement This method, commonly called Mohr's Circle , involves constructing a circle where the coordinates of each point represent the normal and shearing stresses on a specific plane. The angular position of the radius gives the orientation of that plane. Understanding the Plot Figure 1: The geometric relationship between Normal Stress (σ) and Shear Stress (τ). Coordinate Rules: Normal Stresses (σ): Plotted on the horizontal axis. Tensile (+) is right; Compressive (-) is left. Shearing Stresses (τ): Plotted on the vertical axis. Clockwise rotation is above the axis; Counter-clockwise is below. The results obtained from Mohr's circle are identical to the equations derived from the free-body diagram. ...