ESP32 KY-008 Laser Transmitter Module
Overview
The KY-008 is a laser transmitter module that emits a red laser beam at 650 nm with an output power of 5 mW. It is suitable for applications requiring a visible laser source and is compatible with various microcontrollers.
About KY-008 Laser Transmitter Module
The KY-008 Laser Transmitter Module emits a red laser beam with a wavelength of 650 nm and an output power of 5 mW. It operates at a voltage of 5V and consumes less than 40 mA of current. The module features a 650 nm red laser diode, a resistor, and three male header pins. It is commonly used in laser pointer applications and is compatible with microcontrollers like Arduino, Raspberry Pi, and ESP32.
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
Pin (S):
Signal pin, connects to the microcontroller's digital output pin.Pin (middle):
Not connected.Pin (-):
Ground pin, connects to the ground of the circuit.
Troubleshooting Guide
Common Issues
❌ Laser Not Emitting
Issue: The laser module does not emit a beam when expected.
Solutions:
- Ensure that the signal pin is connected to the correct GPIO pin on the microcontroller and is configured as an output.
- Verify that the microcontroller is supplying a HIGH signal to the laser module to activate it.
- Check all wiring connections for continuity and correctness.
- Confirm that the supply voltage is 5V as required by the module.
⚡ Weak or Flickering Laser Beam
Issue: The laser beam is dim or flickers during operation.
Solutions:
- Ensure a stable 5V power supply to the module.
- Check for loose connections or intermittent contacts in the wiring.
- Verify that the current supplied to the module does not exceed 40 mA to prevent overheating.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
int laserPin = 13;
void setup() {
pinMode(laserPin, OUTPUT);
}
void loop() {
digitalWrite(laserPin, HIGH); // Turn on the laser
delay(1000); // Wait for one second
digitalWrite(laserPin, LOW); // Turn off the laser
delay(1000); // Wait for one second
}
This Arduino code controls the KY-008 laser module connected to digital pin 13. It turns the laser on for one second and then off for one second, creating a blinking effect.
ESP-IDF Example
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#define LASER_PIN GPIO_NUM_5
void app_main(void) {
gpio_pad_select_gpio(LASER_PIN);
gpio_set_direction(LASER_PIN, GPIO_MODE_OUTPUT);
while (1) {
gpio_set_level(LASER_PIN, 1); // Turn on the laser
vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait for one second
gpio_set_level(LASER_PIN, 0); // Turn off the laser
vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait for one second
}
}
This ESP-IDF code configures GPIO5 as an output to control the KY-008 laser module. It turns the laser on for one second and off for one second in a loop, creating a blinking effect.
ESPHome Example
switch:
- platform: gpio
pin: GPIO5
name: "KY-008 Laser"
id: laser_switch
This ESPHome configuration sets up a switch to control the KY-008 laser module connected to GPIO5. The laser can be turned on and off via the defined switch entity.
PlatformIO Example
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
PlatformIO Example Code
#include <Arduino.h>
#define LASER_PIN 5
void setup() {
pinMode(LASER_PIN, OUTPUT);
}
void loop() {
digitalWrite(LASER_PIN, HIGH); // Turn on the laser
delay(1000); // Wait for one second
digitalWrite(LASER_PIN, LOW); // Turn off the laser
delay(1000); // Wait for one second
}
This PlatformIO code initializes GPIO5 as an output to control the KY-008 laser module. It toggles the laser on and off every second, creating a blinking effect.
MicroPython Example
import machine
import time
LASER_PIN = machine.Pin(5, machine.Pin.OUT)
while True:
LASER_PIN.value(1) # Turn on the laser
time.sleep(1) # Wait for one second
LASER_PIN.value(0) # Turn off the laser
time.sleep(1) # Wait for one second
This MicroPython script sets up the KY-008 laser module on GPIO5 and toggles it on and off every second, producing a blinking effect.
Conclusion
The ESP32 KY-008 Laser Transmitter Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.