Labs / Bipes + MicroPython / 7 Sensors: Enable Programs to "Perceive the World"

7.12 Worried about sunburn while soaking up the sun? Check UV intensity with one click! —— UV sensor module based on GUVA-S12SD

Author: Li Zisheng · Source: FreakStudio open documentation · License: CC BY 4.0

Contents

Young makers, let’s get to know a kind of sensor that is "invisible but very important" ☀️!

The sunshine is warm and cozy, but did you know that there is also a kind of invisible energy hidden in sunlight — ultraviolet rays. Too much exposure to it can darken your skin or even cause sunburn.

Today, the module we’re about to unlock is the one that can " sense the intensity of ultraviolet rays " —— the UV ultraviolet sensor module based on GUVA-S12SD ✨ It lets the development board know: 👉 how strong the current sunlight is, and whether you need to take sun protection measures!

1. Module Introduction

We can perceive light and colors with our eyes, but ultraviolet light is invisible to the naked eye — so how do devices measure its intensity?

This is precisely the task of the GUVA-S12SD ultraviolet sensor module.

It is an analog environmental sensor: when the ultraviolet intensity in the environment increases, the module will output a higher voltage signal; the development board can judge "the current ultraviolet level is low / medium / high" by reading this change.

Compared with ordinary "switch-type" modules, it has the following characteristics:

In graphical programming, these blocks are commonly used for UV ultraviolet sensors:

In practical projects, it is often used for the following purposes:

Quick Science: What is Ultraviolet (UV) Light?

Ultraviolet (UV) radiation is a type of light invisible to the human eye, and it is present in sunlight. When UV radiation is too intense, it can cause harm to the skin and eyes, which is why weather forecasts often include a "UV index" alert.

2. Wiring Instructions

To make the development board "sense" the intensity of sunlight, the first step remains —— connect the module correctly!

7.12 Worried about sunburn while soaking up the sun? Check UV intensity with one click! —— UV sensor module based on GUVA-S12SD

We will connect the GUVA-S12SD ultraviolet sensor module to the analog interface AIN0 of the development board, with the corresponding relationship as follows:

Development Board Pins

Module Pins

Description

Pin 26

AIN

UV ultraviolet sensor analog output pin

Pin 19

NC

-

📌 Note

3. Example: Detecting Ultraviolet Intensity

Experiment Objective: Detect the ultraviolet intensity in the environment in real time and print the current value on the terminal.

Everyday Thought: The "UV Index" displayed in weather apps is essentially measured using sensors similar to this. Now, let's build our very own UV detector!

The graphical program is as follows:

7.12 Worried about sunburn while soaking up the sun? Check UV intensity with one click! —— UV sensor module based on GUVA-S12SD

Building Block Assembly Steps:

  1. infinite loop
    • Use the repeat while true block to make the program continuously detect the environment;
  2. Read UV index
    • Use the read analog input block;
    • Select the analog pin connected to the UV sensor;
  3. Save the value
    • Store the read value in the variable uv_value;
  4. Statistics show
    • Use the print block to print the current ultraviolet value to the terminal.

Experimental Effect:

📌 You can try: Compare the value changes in the morning / at noon / in the afternoon!

Graphical blocks will be automatically converted into MicroPython code, and the running results will be displayed:

7.12 Worried about sunburn while soaking up the sun? Check UV intensity with one click! —— UV sensor module based on GUVA-S12SD

XML file (can be directly imported into building blocks):

UV ultraviolet sensor module.xml 2 KB

Tips

  1. If the change in the value is not significant:
    • Try placing it directly in sunlight;
    • Do not be completely blocked by the transparent casing;
  2. The ultraviolet sensor is an analog quantity:
    • The value will change continuously, which is a normal phenomenon;
  3. Advanced Gameplay:
    • Set a "safety threshold", and the LED will light up as a reminder once the threshold is exceeded.

✨ Interactive Quick Question

  1. Think about it:
    Why can't UV sensors output only "0 or 1" like buttons?
  2. Give it a try:
    Set a threshold to display "Pay attention to sun protection" when the UV is too strong, and "Suitable for outdoor activities" when it is weak.

Summary

  1. The GUVA-S12SD ultraviolet sensor is a environmental analog sensor;
  2. It can detect the intensity changes of ultraviolet rays in sunlight;
  3. The stronger the ultraviolet radiation, the higher the reading obtained;
  4. Intelligent reminder functions can be implemented through conditional judgment.