Photosensitive for Relay ON/OFF
STM32-Experiments Free Updated Sep 27, 2026

Photosensitive for Relay ON/OFF

Photosensitive

Introduction

Streetlights that switch on automatically at dusk and off again at dawn are built using exactly this combination, a light sensor deciding when it is dark enough, paired with a relay capable of switching a much higher voltage load than a microcontroller could ever handle directly. In this experiment, a photosensitive module is read by the STM32F070RB, and based on the detected light level, a relay module is switched to control a 230V AC lamp.

2. Scope

This experiment covers reading a photosensitive light sensor module's digital output, and using that reading to drive a relay module that switches a mains-voltage AC lamp. Genuine mains voltage is involved on the load side of this experiment, and appropriate electrical safety precautions must be followed throughout, detailed in Section 5.

3. Prerequisite

3.1 Hardware

  • STM32 Nucleo-F070RB development board

  • Photosensitive light sensor module, with digital output

  • A relay module rated to safely switch 230V AC at the required current for your lamp

  • A 230V AC lamp or bulb with an appropriate fixture, and a correctly rated mains supply connection

  • Breadboard and jumper wires

  • Micro-USB cable

3.2 Software

  • STM32CubeMX (standalone)

  • STM32CubeIDE

  • ST-LINK USB driver

Community Q&A

0 questions

Ask questions and get answers from our community and staff moderators.

No questions yet — be the first to start the conversation!

Ask a Question

Please log in to ask a question or post a reply.

Login to Participate