Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Industrial Automation

Photoelectric Sensor Wiring: NPN vs PNP Output Types

Photoelectric Sensor Wiring: NPN vs PNP Output Types

March 11, 2026 /Posted byJayesh Jain / 0

Understanding photoelectric sensor NPN PNP wiring is essential for every automation engineer and maker working with industrial sensors. Connecting the wrong output type to a PLC input card or Arduino can damage the sensor, give incorrect readings, or cause circuit damage. This guide explains the difference between NPN (sinking) and PNP (sourcing) outputs, how to wire each type correctly, and how to choose the right output type for your PLC or microcontroller.

Table of Contents

  • NPN vs PNP: The Key Difference
  • Wiring NPN (Sinking) Sensors
  • Wiring PNP (Sourcing) Sensors
  • Connecting to PLC Input Cards
  • Connecting to Arduino and ESP32
  • Selecting the Right Output Type for India
  • Frequently Asked Questions

NPN vs PNP: The Key Difference

The NPN/PNP nomenclature comes from the type of transistor used in the sensor’s output stage. This determines how the output terminal behaves when the sensor detects an object:

  • NPN (Sinking/Negative Switching): When activated, the output terminal connects to the negative supply (0V/GND). The output "sinks" current from the load. The current flows from the load → sensor output → GND.
  • PNP (Sourcing/Positive Switching): When activated, the output terminal connects to the positive supply (Brown wire, typically 24V). The output "sources" current to the load. The current flows from 24V → sensor output → load → GND.

Both NPN and PNP sensors are available in Normally Open (NO) and Normally Closed (NC) configurations:

  • NO (Normally Open): Output is inactive (open circuit) when no object is detected. Activates when object is sensed.
  • NC (Normally Closed): Output is active when no object is detected. Opens when object is sensed.

So a complete sensor designation might be: PNP NO — positive switching, activates on detection.

Recommended: 5V Modbus RTU 4-Channel Relay Module for Arduino — Use relay modules as interface buffers between industrial NPN/PNP sensors and 5V microcontrollers.

Wiring NPN (Sinking) Sensors

NPN sensors typically have three wires with standard colour coding (IEC 60947-5-2):

  • Brown wire (+): Connect to positive supply (24V DC for industrial, 12V for some models)
  • Blue wire (-): Connect to 0V / GND
  • Black wire (output): The switching output — connects to GND when activated
// NPN (Sinking) Sensor Wiring
//
//          +24V ─────────────── Brown (sensor +)
//                                    │
//          LOAD (PLC input)     Sensor    
//          or resistor ──────── Black (output)
//                                    │
//          0V/GND ─────────────── Blue (sensor -)
//                      │
//                     (0V also connects to PLC 0V)
//
// When sensor activates: Black shorts to 0V (GND)
// Current flows: +24V → LOAD → Black → 0V
// PLC input sees: LOW (0V) = sensor active

For PLC wiring, connect the Black wire to the PLC digital input terminal. Connect the PLC’s COM terminal to 0V. The PLC input detects a LOW signal when the sensor activates. Note: most Siemens S7-series and Mitsubishi PLCs with NPN inputs use this "sinking input" topology.

Wiring PNP (Sourcing) Sensors

PNP sensors use the same three-wire colour scheme, but the output transistor switches to +V instead of GND:

// PNP (Sourcing) Sensor Wiring
//
//          +24V ─────────────── Brown (sensor +)
//                          │
//                       Sensor
//                          │
//          Black (output) ─────── PLC Input
//                                      │
//                                   LOAD/resistor
//                                      │
//          0V/GND ─────────── Blue (sensor -) ── PLC 0V
//
// When sensor activates: Black connects to +24V internally
// Current flows: Black (+24V) → PLC input → LOAD → 0V
// PLC input sees: HIGH (24V) = sensor active

For PLC wiring with PNP sensors, connect the Black wire to the PLC digital input terminal. The PLC’s COM terminal connects to 0V. The PLC input detects HIGH (24V) when the sensor activates. Allen-Bradley PLC inputs are typically PNP (sourcing input) compatible.

Connecting to PLC Input Cards

PLC input cards can be configured for NPN (sinking) or PNP (sourcing) mode. Critical rule:

  • NPN sensor → NPN PLC input (sinking input): PLC COM terminal connects to 0V. Input detects when signal is pulled to 0V.
  • PNP sensor → PNP PLC input (sourcing input): PLC COM terminal connects to +24V. Input detects when signal is pulled to +24V.

Mixing types causes problems:

  • NPN sensor into PNP input: The output pulls to 0V, but the PNP input reference is +24V — the input never activates correctly. Some cards may also see reverse voltage.
  • PNP sensor into NPN input: The output sources +24V into the input, which may be interpreted as a fault or cause input damage.

Siemens S7-1200 input cards: IQ32 and IQ16 are PNP (sourcing) by default — use PNP sensors. S7-300 SM321 can be configured for either type by changing the COM connection.

Recommended: 12V Modbus RTU 4-Channel Relay Module RS485 — Add relay outputs to your sensor monitoring system that can interface with both NPN and PNP logic levels.

Connecting to Arduino and ESP32

Arduino and ESP32 logic is 5V and 3.3V respectively — very different from industrial 24V sensors. Direct connection can damage the microcontroller.

NPN Sensor to Arduino (with voltage divider)

// NPN 24V sensor to Arduino 5V digital input
// Use a voltage divider to bring 24V → 5V

// Sensor Brown → 24V supply
// Sensor Blue  → GND
// Sensor Black → Resistor 10kΩ → Arduino Pin 2
//             └── Resistor 22kΩ → GND
// (Voltage divider: 24V × 22k/(10k+22k) = 16.5V ... too high!)
//
// Better: Use 5V power for NPN sensor (many have 5-30V range)
// Sensor Brown → Arduino 5V
// Sensor Blue  → Arduino GND
// Sensor Black → Arduino Pin 2 (with 10kΩ pull-up to 5V)

const int SENSOR_PIN = 2;
void setup() {
  pinMode(SENSOR_PIN, INPUT_PULLUP);  // Enable internal pull-up
  Serial.begin(9600);
}
void loop() {
  if (digitalRead(SENSOR_PIN) == LOW) {  // NPN active = LOW
    Serial.println("Object detected!");
  }
  delay(100);
}

PNP Sensor to Arduino

// PNP 5V sensor to Arduino digital input
// Sensor Brown → Arduino 5V
// Sensor Blue  → Arduino GND
// Sensor Black → Arduino Pin 2
// Add 10kΩ pull-down resistor from Pin 2 to GND

const int SENSOR_PIN = 2;
void setup() {
  pinMode(SENSOR_PIN, INPUT);  // External pull-down — no internal pull-up
  Serial.begin(9600);
}
void loop() {
  if (digitalRead(SENSOR_PIN) == HIGH) {  // PNP active = HIGH
    Serial.println("Object detected!");
  }
  delay(100);
}

For 24V industrial sensors with 3.3V ESP32, use an optocoupler (PC817) as a safe interface: the sensor drives the LED side, and the ESP32 reads the transistor output at 3.3V — complete electrical isolation.

Recommended: 4-20mA to 5V Converter for Arduino Industrial Sensor Interface Board — This industrial-grade interface board handles voltage level conversion from industrial field signals to Arduino-compatible levels safely.

Selecting the Right Output Type for India

The Indian automation market is mixed:

  • Siemens PLC installations: Use PNP sensors (S7-1200 inputs are PNP sourcing by default).
  • Allen-Bradley PLC installations: Use PNP sensors (CompactLogix inputs are PNP sourcing).
  • Asian-brand PLCs (Mitsubishi, Keyence, OMRON): Many use NPN inputs — check the datasheet carefully.
  • Arduino/ESP32 projects: Choose sensors that work at 5V or 3.3V supply voltage, and prefer NPN for easier pull-up connection.
  • When in doubt: Choose sensors with "NPN/PNP selectable" (also called "IO-Link capable" or "configurable output"). These sensors can be configured for either type via DIP switch or software — maximum flexibility.

Frequently Asked Questions

Can I use a PNP sensor on an NPN PLC input?

Yes, using a relay as a signal converter. Wire the PNP sensor output to activate a small relay (5V or 24V coil), then use the relay’s normally-open contact to drive the NPN PLC input to 0V. This electrically isolates the two circuits and converts between output types. Many Indian panel builders use this approach when mixing sensor and PLC types.

What happens if I accidentally connect a 24V sensor to an Arduino 5V pin?

Applying 24V to an Arduino or ESP32 input pin (rated for 5V or 3.3V respectively) will damage the pin permanently — and may damage the entire microcontroller. Always verify sensor operating voltage before connecting. If using 24V sensors with microcontrollers, always use a voltage divider, optocoupler, or level shifter module as an interface.

What are four-wire sensors and how are they different?

Four-wire sensors have two output channels — typically one NPN output and one PNP output from the same sensor body, powered by a common supply. Some four-wire sensors provide both NO and NC outputs simultaneously. They offer maximum wiring flexibility. Five-wire sensors add an analogue output in addition to the switching outputs — used for distance measurement or intensity reading in addition to switching.

My sensor LED flickers but the output is not switching reliably — why?

Flickering LED with unreliable output typically means the object is at the sensing limit (boundary zone). The sensor alternately detects and loses the target as the LED flickers. Move the sensor closer or further to operate in the stable sensing zone (typically 70–80% of the specified sensing range). Also check for reflective surfaces near the sensor that might be causing false triggering.

Shop Industrial Automation at Zbotic →

Tags: NPN sensor, photoelectric sensor, PNP sensor, Proximity Sensor, sensor wiring
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
PCB Material FR4 vs Rogers vs ...
blog pcb material fr4 vs rogers vs aluminum which to use 598580
blog weather alert system sms notification with esp32 and sim800 598590
Weather Alert System: SMS Noti...

Related posts

Svg%3E
Read more

Compressed Air Monitor: Pressure and Leak Detection

April 1, 2026 0
Table of Contents Understanding Compressed Air Monitor Technical Fundamentals of Compressed Air Monitor Indian Market: Components and Pricing Sensor Integration... Continue reading
Svg%3E
Read more

Industrial Gas Detection: Multi-Gas Monitoring System

April 1, 2026 0
Table of Contents Understanding Industrial Gas Detection Technical Fundamentals of Industrial Gas Detection Indian Market: Components and Pricing Sensor Integration... Continue reading
Svg%3E
Read more

Cold Room Controller: Compressor and Defrost Cycle

April 1, 2026 0
Table of Contents Understanding Cold Room Controller Technical Fundamentals of Cold Room Controller Indian Market: Components and Pricing Sensor Integration... Continue reading
Svg%3E
Read more

Grain Storage Monitor: Temperature and Moisture

April 1, 2026 0
Table of Contents Understanding Grain Storage Monitor Technical Fundamentals of Grain Storage Monitor Indian Market: Components and Pricing Sensor Integration... Continue reading
Svg%3E
Read more

Poultry House Controller: Climate and Feeding Automation

April 1, 2026 0
Table of Contents Understanding Poultry House Controller Technical Fundamentals of Poultry House Controller Indian Market: Components and Pricing Sensor Integration... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now