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

Dowel pins are precision cylindrical pins used for accurate part alignment in assemblies. They control position, not clamping force. This guide explains tolerances, fits, sizing rules, and design best practices. 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-wea...

Watt Straight-Line Linkage: Analysis and Automotive Uses

Figure 1: Watt's linkage example geometry and path generation. Introduction to Watt's Linkage The Watt's linkage (also known as the parallel motion linkage) is a cornerstone in the history of mechanical engineering. It is a type of four-bar linkage originally invented by James Watt in the late 18th century to solve a critical problem in steam engine design: constraining the piston rod to move in a straight line without using high-friction guideways. Before this invention, engines used chains to connect the piston to the beam, which meant they could only pull, not push. Watt's rigid linkage allowed for double-acting engines (pushing and pulling), doubling the power output. He was immensely proud of this kinematic solution, describing it in a 1784 letter to his partner Matthew Boulton: "I have got a glimpse of a method of causing a piston rod to move up and down perpendicularly by only fixing it to a piece of iron u...

Roberts straight-line mechanism

Figure 1: A modern linear ball slide (like this THK model) is the contemporary solution for precise straight-line motion. Many modern engineering applications require components to move in a precise linear fashion, known as " straight-line motion ". Today, we take this for granted. We can simply purchase an off-the-shelf Linear Motion Guide that moves a device accurately along a rail with low friction. The Historical Challenge: Making a Straight Line However, in the late 17th and early 18th centuries—before the development of high-precision milling machines—it was extremely difficult to manufacture long, perfectly flat surfaces. Creating a sliding joint without significant backlash was nearly impossible. During that era, engineers had to rely on Linkages . Much thought was given to the problem of attaining a straight-line motion using only revolute (hinge) connections, which were much easier to manufacture. The most famous early result was...