Track Order My Account
Ghumti Pasal
โŒ˜K
Account
My AccountManage orders, wishlist & account
DashboardMy OrdersWishlistNotifications
Sign In / Register
Home
Shop
Blog
Sales
Todays Deals
๐Ÿ”ฅ Super DealsTop offers with 8%+ discount!
Resistive Film Pressure Sensor Probe RFP602 1KG Compatible with FSR402 Piezoresistive Pressure Switch Long Tailโˆ’16%
Resistive Film Pressure Sensor Probe RFP602 1KG Compatible with FSR402 Piezoresistive Pressure Switch Long Tail
NPRย 756NPRย 900
BMP280 5V Digital Barometric Pressure Altitude Sensor I2C/SPI High Precisionโˆ’15%
BMP280 5V Digital Barometric Pressure Altitude Sensor I2C/SPI High Precision
NPRย 298NPRย 350
Module MQ 2 Smoke methane gas liquefied flammable gas sensor moduleโˆ’10%
Module MQ 2 Smoke methane gas liquefied flammable gas sensor module
NPRย 315NPRย 350
Ultra-thin speaker 8 ohms 0.5 watt 0.5W 8R speaker Diameter 40MM 4CM thickness 5MMโˆ’16%
Ultra-thin speaker 8 ohms 0.5 watt 0.5W 8R speaker Diameter 40MM 4CM thickness 5MM
NPRย 84NPRย 100
View All Deals (52 items) โ†’
Account
Ghumti Pasal

Ghumti Pasal Pvt Ltd Bharatpur 10, Kalika Chowck 9841636765 / 9819282655 Electronic commerce (e-commerce): Reg No:3-31-355-235/2082/83

Join our newsletter

New arrivals, offers and restock alerts โ€” straight to your inbox.

Shop

All ProductsBlog

Company

AboutContact

Help

Shipping & ReturnsPrivacy Policy
info@ghumtipasal.com.np9841636765Bharatpur 10
HomeShopSaleCartAccount
โ† Back to All Maker Guides
๐Ÿ› ๏ธ MAKER GUIDEJul 15, 2026โ€ขโฑ๏ธ 3 min readโ€ข๐Ÿ‡ณ๐Ÿ‡ต Tested in Nepal

Industrial Sensors: Interfacing NPN Proximity Switches with Microcontrollers

Detect metal targets safely. Learn how to connect 12V LJ12A34Z NPN proximity sensors to 5V Arduino boards using optocouplers.

๐Ÿ“กRF & DRONE TECH

Industrial Sensors: Interfacing NPN Proximity Switches with Microcontrollers

Ghumti Pasalโ€ขEngineering Project
๐Ÿ› ๏ธ BILL OF MATERIALS (BOM)

Required Hardware & Component Checklist

Curated components verified for this project. Check the items you need, adjust quantities, and add straight to cart:

Estimated Total (3/3 items):
NPRย 1,670
โœ“ Cash on Delivery across Nepal
All parts selected
1
NPRย 1,200
1
NPRย 200
1
NPRย 270
๐Ÿ’ฌ Order Kit on WhatsApp
Browse All Store Products โ†’

Industrial Sensors: Interfacing NPN Proximity Switches with Microcontrollers

Inductive proximity sensors are the workhorses of factory automation. Unlike mechanical switches, they detect the presence of metal targets without any physical contact, meaning they never wear out. The LJ12A34Z/BX inductive sensor is commonly used in CNC routers, 3D printers, and conveyor lines.

However, industrial sensors usually require 6Vโ€“36V DC to operate. Connecting the output signal of a 12V sensor directly to a 5V Arduino or 3.3V ESP32 pin will instantly destroy the chip. This guide explains how to interface them safely using a 4N35 optocoupler.


Featured Circuit Diagram (Optocoupler Isolation)

       12V VCC โ”€โ”€[ 1k Ohm Resistor ]โ”€โ”€ Pin 1 (Anode)
                                        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       Sensor Black (Signal) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Pin 2 (Cathode)
                                        โ”‚  4N35   โ”‚
       Arduino Pin 2 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Pin 5 (Collector)
                                        โ”‚         โ”‚
       Arduino GND โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Pin 4 (Emitter)
                                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Featured Components

  • Proximity Sensor: LJ12A34Z/BX Proximity Switch Photoelectric Switch Sensor NPN
  • Isolation IC: 4N35 Optocoupler IC
  • Switches: Tact Switch Push Button 6x6mm DIP Series
  • Wiring Tool: ESD Anti-Static Precision Tweezers Kit

Understanding NPN Open-Collector Outputs

The LJ12A34Z/BX is a 3-wire NPN normally open (NO) sensor:

  • Brown Wire: VCC (Positive power, e.g. 12V).
  • Blue Wire: GND (Common ground).
  • Black Wire: Signal Output.

Because it is an NPN sensor, its output acts as a switch to ground. When no metal is near, the black wire floats. When metal is detected, the black wire is connected to GND.


Safe Isolation Using the 4N35 Optocoupler

An optocoupler uses an internal LED and photo-transistor to transmit signals using light. This completely isolates the high-voltage 12V sensor circuit from your 5V microcontroller.

Wiring Diagram:

  1. Sensor Side: Connect the sensor's Brown wire to 12V VCC, and Blue wire to 12V GND. Connect a 1k Ohm resistor from 12V VCC to Pin 1 (Anode) of the 4N35. Connect the sensor's Black signal wire to Pin 2 (Cathode) of the 4N35.
  2. Microcontroller Side: Connect Pin 4 (Emitter) of the 4N35 to Arduino GND. Connect Pin 5 (Collector) of the 4N35 to Arduino Pin 2.
  3. Pull-Up: Configure Arduino Pin 2 as INPUT_PULLUP in code.

Arduino Processing Code

This script detects when a metal target passes in front of the sensor:

const int SENSOR_PIN = 2; // Connected to Optocoupler Pin 5
int detectCount = 0;
bool lastState = HIGH;

void setup() {
  Serial.begin(9600);
  pinMode(SENSOR_PIN, INPUT_PULLUP); // Keeps input stable at 5V
  Serial.println("Inductive Sensor Monitor Online!");
}

void loop() {
  bool currentState = digitalRead(SENSOR_PIN);
  
  // Detect falling edge (transition to GND when metal is detected)
  if (currentState == LOW && lastState == HIGH) {
    detectCount++;
    Serial.print("Metal Target Detected! Total: ");
    Serial.println(detectCount);
    delay(200); // Debounce delay
  }
  
  lastState = currentState;
}

Applications in Robotics

Inductive sensors are highly reliable limit switches. Unlike optical sensors, they are unaffected by dust, sawdust, or ambient lighting, making them the best choice for CNC home switches or metal sorting mechanisms in student projects.

๐Ÿ“ฃ Share this Project Guide:๐Ÿ’ฌ WhatsAppFacebook๐• / Twitter
โ† Previous Guide
High-Performance Soldering & Rework: Kailiwei T12 Digital Station Guide
Next Guide โ†’
Non-Contact Digital Tachometer RPM Speed Counter for Motors & Fans

More Practical STEAM & IoT Guides

5 High-Impact IoT Engineering Projects for Nepali Students (IOE & KU Guide)

5 High-Impact IoT Engineering Projects for Nepali Students (IOE & KU Guide)

IoT Weather Reporting System with Arduino & Raspberry Pi LoRa Gateway

IoT Weather Reporting System with Arduino & Raspberry Pi LoRa Gateway

IoT IV Bag Monitoring & Alert System for Healthcare Facilities

IoT IV Bag Monitoring & Alert System for Healthcare Facilities