PiicoDev Ambient Light Sensor VEML6030 - Micro:bit Guide

Updated 23 September 2021

Introduction

This guide will help you read light intensity data from your PiicoDev Ambient Light Sensor and a Micro:bit.

To follow along, it's best to have:

We'll program with Thonny in this tutorial. If you haven't used Thonny before, check out our guide for Programming a Micro:bit with Thonny. If you prefer, you can program your Micro:bit using python.microbit.org instead (see our guide).

If you prefer not to use the Micro:bit adapter, there are other connection options in our PiicoDev Connection Guide.

Connect the PiicoDev sensor to your Micro:bit

Plug your Micro:bit into the PiicoDev adapter (buttons + LED matrix facing up), connect your sensor to the adapter via the PiicoDev cable and connect your Micro:bit to your computer with a USB lead.

If you're unfamiliar with connecting PiicoDev modules, read the PiicoDev Connection Guide before proceeding.

piicodev-veml6030-microbit-connections

Download the PiicoDev Modules and Example Code

Download the following files and save them to your working directory (Right Click > "Save Link As")

It will be best to keep this file wherever you like to keep your coding projects eg. Documents > PiicoDev

Example Code

Open Thonny, connect to your micro:bit and upload the three files from the previous step.

Press Ctrl+D to restart your micro:bit and run the main script - light data should begin streaming up the shell

example-script-for-microbit

Above: Plotted data starts at ambient levels, then I cover the sensor with my hand and the data dips. A flashlight is then shined on the sensor with creates a large peak.

Now we can easily read light data with our Pico.

Remix - Day/Night message

In the final part of the video, we modify the example code to keep track of whether it is day or night (bright/dark). When light data transitions between bright and dark, we can create a Good Morning or Goodnight sound with our micro:bit - You can use this structure for decision-making in your own projects - be sure to code along!

If you have any questions or uncertainty, start the discussion below. We're full-time makers and here to help!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.