Stufin
Home Quick Cart Profile

SN04-N NPN NO Distance Proximity Sensor Switch Module

Buy Now on Stufin

Operating Voltage

3.3-5V

Output Type

NPN

Output Current

100 mA

Detection Range

2-30 cm (0.6-11.8 inches)

Sensitivity

Adjustable

Response Time

10 ms

Dimensions

20 x 15 x 10 mm (0.78 x 0.59 x 0.39 inches)

Weight

5g

Applications

The SN04-N NPN NO Distance Proximity Sensor Switch Module is suitable for a wide range of applications, including

Obstacle detection and avoidance systems

Proximity sensing and detection

Object counting and tracking

Robotics and automation

Industrial automation and control systems

IoT devices and smart home applications

Pinout

The SN04-N module has a 3-pin interface

VCC (Power Supply)

GND (Ground)

OUT (NPN Output)

By leveraging the features and capabilities of the SN04-N module, developers and engineers can create innovative and effective proximity sensing solutions for various industries and applications.

Pin Configuration

  • SN04-N NPN NO Distance Proximity Sensor Switch Module Documentation
  • Pin Description and Connection Guide
  • The SN04-N NPN NO Distance Proximity Sensor Switch Module is a compact and versatile proximity sensor module that detects objects within a specific distance range. The module has a total of 4 pins, which are described below:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power supply to the module
  • Pin Type: Input
  • Voltage Range: 5V DC (Typical), 4.5V to 5.5V (Acceptable)
  • Connection:
  • + Connect VCC pin to a 5V power supply or a regulated 5V output from a microcontroller or a voltage regulator.
  • + Ensure the power supply can provide sufficient current to the module (typically 10mA to 20mA).
  • Pin 2: GND (Ground)
  • Function: Provides a ground reference to the module
  • Pin Type: Input
  • Connection:
  • + Connect GND pin to the system's ground (GND) or 0V reference point.
  • + Ensure a reliable and low-impedance grounding connection to minimize noise and interference.
  • Pin 3: OUT (Output)
  • Function: Provides a digital output signal indicating the presence or absence of an object within the detection range
  • Pin Type: Output
  • Logic Level: NPN (Negative-Positive-Negative) type output
  • + Logic High (H): No object detected (,output is pulled low)
  • + Logic Low (L): Object detected (output is pulled high)
  • Connection:
  • + Connect OUT pin to a digital input of a microcontroller, a logic-level translator, or a suitable interface circuit.
  • + Ensure the connected device can handle the NPN output type and logic levels.
  • Pin 4: Sensing Zone (Adjustable Distance Setting)
  • Function: Sets the detection range of the proximity sensor
  • Pin Type: Input
  • Connection:
  • + Connect a potentiometer or a variable resistor between Pin 4 and GND (Pin 2) to adjust the detection range.
  • + Rotate the potentiometer or adjust the resistor value to set the desired detection distance (typically 0cm to 5cm).
  • Important Notes:
  • The module's detection range can be adjusted by changing the resistance value between Pin 4 and GND.
  • Ensure proper connections and avoid short-circuiting the pins to prevent damage to the module or connected devices.
  • The module's output is an NPN type, which means it requires a pull-up resistor or a suitable interface circuit to function correctly.
  • By following these pin descriptions and connection guidelines, you can successfully integrate the SN04-N NPN NO Distance Proximity Sensor Switch Module into your IoT project or application.

Code Examples

SN04-N NPN NO Distance Proximity Sensor Switch Module Documentation
Overview
The SN04-N NPN NO Distance Proximity Sensor Switch Module is a compact and efficient sensor module designed for detecting objects within a certain distance range. This module uses an infrared LED and a phototransistor to detect objects, providing a digital output signal when an object is within the detection range. The module is suitable for various IoT applications, including robotics, automation, and smart home systems.
Technical Specifications
Operating Voltage: 5V
 Operating Current: 20mA
 Distance Detection Range: 2-30cm
 Output Signal: Digital ( HIGH or LOW)
 Output Type: NPN (Negative-Positive-Negative) Open Collector
 Response Time: 10ms
Pinouts
VCC: 5V power supply
 GND: Ground
 OUT: Digital output signal
 EN: Enable pin (optional, pull-up to 5V to enable)
Code Examples
### Example 1: Basic Object Detection using Arduino
In this example, we will use the SN04-N module with an Arduino board to detect objects within the detection range. The module's output signal will be connected to a digital input on the Arduino board.
```c
const int sensorPin = 2;  // Digital input pin for sensor output
const int ledPin = 13;   // LED pin to indicate object detection
void setup() {
  pinMode(sensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  int sensorState = digitalRead(sensorPin);
  if (sensorState == HIGH) {
    // Object detected, turn on the LED
    digitalWrite(ledPin, HIGH);
  } else {
    // No object detected, turn off the LED
    digitalWrite(ledPin, LOW);
  }
  delay(50);
}
```
### Example 2: Object Detection with Raspberry Pi using Python
In this example, we will use the SN04-N module with a Raspberry Pi to detect objects within the detection range. The module's output signal will be connected to a digital input on the Raspberry Pi's GPIO pins.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
sensor_pin = 17  # GPIO pin 17 as input for sensor output
led_pin = 18    # GPIO pin 18 as output for LED
GPIO.setup(sensor_pin, GPIO.IN)
GPIO.setup(led_pin, GPIO.OUT)
while True:
    sensor_state = GPIO.input(sensor_pin)
    if sensor_state:
        # Object detected, turn on the LED
        GPIO.output(led_pin, GPIO.HIGH)
    else:
        # No object detected, turn off the LED
        GPIO.output(led_pin, GPIO.LOW)
    time.sleep(0.05)
```
Note: Ensure to connect the sensor module's output signal to a digital input pin on your microcontroller or single-board computer, and configure the pin as an input in your code. Also, connect the power supply (VCC) and ground (GND) pins to the corresponding pins on your board.