Stufin
Home Quick Cart Profile

LDR 5mm Metal Housing (Pack of 5)

Buy Now on Stufin

Resistance

Typically ranges from 1 k to 10 k, depending on the light intensity

Power Rating

Up to 100 mW

Operating Temperature

-20C to +70C

Light Sensitivity

Peak sensitivity at 550 nm (yellow-green light)

Response Time

Typically <10 ms

Dimensions

5 mm (diameter) x 3 mm (height)

Applications and Use Cases

Automatic lighting systems

Smart home automation

Environmental monitoring (e.g., measuring light intensity in greenhouses)

Robotics and autonomous systems

Security systems (e.g., motion detection)

IoT projects requiring ambient light sensing

Precautions and Handling

Handle the component with care to avoid mechanical stress and damage.

Avoid exposing the LDR to direct sunlight or high-intensity light sources, as this may lead to damage or degradation.

Store the component in a cool, dry place, away from direct sunlight.

Use a voltage regulator and a current-limiting resistor to prevent overvoltage and overcurrent.

By following proper handling and integration guidelines, the LDR 5mm Metal Housing (Pack of 5) can provide accurate and reliable light sensing capabilities in various IoT and electronic applications.

Pin Configuration

  • LDR 5mm Metal Housing (Pack of 5) Component Documentation
  • Overview
  • The LDR (Light Dependent Resistor) 5mm Metal Housing is a photodetector component used to measure light intensity. It is commonly used in IoT projects to detect ambient light levels, automatically control lighting, and for other applications where light sensing is required.
  • Pinouts
  • The LDR 5mm Metal Housing component has two pins, which are explained below:
  • Pin 1: Output
  • Function: Output voltage proportional to light intensity
  • Description: This pin provides an analog output signal that varies in response to changes in light intensity. The output voltage is typically in the range of 0-5V, with higher voltages indicating higher light intensities.
  • Connect to: Analog input pin of a microcontroller or an ADC (Analog-to-Digital Converter) for reading the light intensity values.
  • Pin 2: GND (Ground)
  • Function: Ground connection
  • Description: This pin is connected to the ground of the circuit, providing a reference point for the output voltage.
  • Connect to: Ground pin of the microcontroller, breadboard, or PCB.
  • Connection Structure
  • To connect the LDR 5mm Metal Housing component, follow the steps below:
  • 1. Connect Pin 1 (Output) to:
  • Analog input pin of a microcontroller (e.g., Arduino, Raspberry Pi)
  • ADC (Analog-to-Digital Converter) input pin
  • Analog input pin of a development board (e.g., ESP32, ESP8266)
  • 2. Connect Pin 2 (GND) to:
  • Ground pin of the microcontroller, breadboard, or PCB
  • Common ground point in the circuit
  • Important Notes
  • Make sure to connect the LDR component to a voltage source (e.g., 5V) and a suitable resistor (e.g., 1 k) in series to prevent the LDR from drawing excessive current.
  • When connecting the LDR to a microcontroller, ensure that the analog input pin is configured to read analog values and that the ADC is enabled.
  • To improve noise immunity and accuracy, use a decoupling capacitor (e.g., 100 nF) between the LDR output and the analog input pin.
  • By following these connection guidelines and pin descriptions, you can successfully integrate the LDR 5mm Metal Housing component into your IoT project and start measuring light intensity levels.

Code Examples

LDR 5mm Metal Housing (Pack of 5) Component Documentation
Overview
The LDR 5mm Metal Housing (Pack of 5) is a light-dependent resistor (LDR) component housed in a 5mm metal casing. LDRs are photocells that change their resistance in response to changes in light intensity. This component is commonly used in various IoT projects, such as ambient light sensors, automatic lighting systems, and robotics.
Pinout
The LDR 5mm Metal Housing has two pins:
Pin 1: One end of the LDR element
 Pin 2: The other end of the LDR element
Specifications
Operating voltage: 5V
 Dark resistance: 10M
 Light resistance: 1k
 Response time: 10-20ms
 Metal housing diameter: 5mm
Code Examples
### Example 1: Basic Ambient Light Sensor with Arduino
This example demonstrates how to use the LDR 5mm Metal Housing to create a basic ambient light sensor with an Arduino board.
```c
const int ldrPin = A0;  // LDR connected to analog input A0
const int LEDPin = 13;  // LED connected to digital output 13
void setup() {
  pinMode(ldrPin, INPUT);
  pinMode(LEDPin, OUTPUT);
}
void loop() {
  int ldrValue = analogRead(ldrPin);
  int brightness = map(ldrValue, 0, 1023, 0, 255);
  analogWrite(LEDPin, brightness);
  delay(20);
}
```
In this example, the LDR is connected to analog input A0, and an LED is connected to digital output 13. The Arduino reads the LDR value, maps it to a brightness value, and adjusts the LED's brightness accordingly.
### Example 2: Automatic Lighting System with Raspberry Pi (Python)
This example demonstrates how to use the LDR 5mm Metal Housing to create an automatic lighting system with a Raspberry Pi and Python.
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define LDR and relay pin numbers
ldr_pin = 17
relay_pin = 23
# Set up LDR pin as input and relay pin as output
GPIO.setup(ldr_pin, GPIO.IN)
GPIO.setup(relay_pin, GPIO.OUT)
while True:
    ldr_value = GPIO.input(ldr_pin)
    if ldr_value == 0:  # LDR is in the dark
        GPIO.output(relay_pin, GPIO.HIGH)  # Turn on the light
    else:
        GPIO.output(relay_pin, GPIO.LOW)  # Turn off the light
    time.sleep(0.5)
```
In this example, the LDR is connected to GPIO pin 17, and a relay module is connected to GPIO pin 23. The Python script reads the LDR value and controls the relay to turn on or off the light based on the ambient light conditions.
Note: These examples are for illustrative purposes only and may require additional components and setup for a complete working project.