Table of Contents:
The SL01 xChip includes 2 separate sensors that measure the following properties of light:
- One of the sensors (the VEML607) measures the UVA and UVB levels and also integrates them and provide the UV index.
- The other sensor (the TSL4531) measures ambient light and is designed to approximate human eye response. It reports results in lux (which is the SI unit of illuminance).
Using these sensors the the SL01 extension provides the following functions:
- Illuminance (lux)
- Ultraviolet A (mW / cm2)
- Ultraviolet B (mW / cm2)
- Ultraviolet index.
To write code to interact with the LED on the SL01 in MakeCode you will need to load the SL01 extension:
- Open MakeCode and start a new project
- Click on Extensions
- Type in XinaBox/pxt-sl01
- Click on search
- Select the SL01 tile
After a few moments the extension should load and you will see a new tab in the left hand menu titled SL01.
One of the most simple programs you can write with the SL01 is to display lux on screen. Its easy to manipulate the reading and may inspire students to use a light sensor as a simple switch.
As long as you've imported the SL01 you can use the code below:
Remember to attach your SL01 to your micro:bit before running the code.
- Connecting it up
- Loading the extension and Hello World!
- Outputting sensor readings to the OD01 and high UV warning
The micro:bit 5x5 LED screen is not ideal for displaying sensor readings, but the micro:bit can easily be upgraded to a 64x128 OLED monochrome monitor: the OD01 from XinaBox.