loader

Activity No. 7: Measuring brightness (Starter kit Vittascience)

Using the light sensor with the NUCLEO-L476 board.

The Grove light sensor is a module that measures ambient light over a range of 0 to 350 lux.

The operating principle is simple. This sensor consists of a photoresistor, which measures the light intensity of the environment. The voltage of the photoresistor decreases as the light intensity increases. The greater the brightness, the greater the value returned by the sensor. It is expressed in Lux.

zoom-photoresistance

To measure the brightness using the NUCLEO-L476RG board, the following connection must be made: 
- Connect the Shield Grove to the board connectors. 
- Connect, using the Grove cable, the screen to one of the ports named I2C available.
- Connect the light sensor using the Grove cable to one of the analog ports. We will choose port A2.

luminosite-EN

Be careful to respect the direction of connection of the Grove cable (4 wires in 1 with polarizing slot).

Let's get to the programming now! 

We will use two blocks:
- " [LCD] display text ... on line 0 position 0 ", available in the Display of the block locker to manage the screen.
- "[Light sensor] light on pin A2", available in the Sensors, to retrieve the value of the module.


Use the following interface to program the module: 



To facilitate reading, you can insert a pause and clear the screen. 
clear-en



Once the program has been created, it must be copied onto the card. To do this, use the "Upload" button (see Activity 0: Getting started with the board)

We are now going to create a text, to make it easier for the user to read. 

You must use the "create the text ... ... ... " block available in the Text part of the block locker, combining it with the block ("...") which allows you to write. 
text-en

Here is an example of ready-to-use code:


This code includes:
- the display of the word "Brightness:" on the first line of the screen
- the display of a text composed of the rounding of the brightness value + the word ''lux'', on the second line of the screen
- a 1 second pause
- the cleaning of the screen to facilitate reading

Launch the simulator to check that your program is running correctly or download it to the card. 

You succeeded ? Perfect, you now know how to program a temperature sensor using your NUCLEO-L476RG board! 
Discover the other activities of the Starter kit by clicking on the icons below.

Licence d'utilisation

Licence Creative Commons

Cette ressource est mise à disposition selon les termes de la Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 2.0 France