Let's Workshop: GY-30 Light Intensity Sensor Module

Posted by Sebastian Karam on

Here is a quick introduction to using the GY-30 light intensity sensor module. This will provide you with an entry point to using the module to accurately monitor light levels.

This example will demonstrate the use of an Arduino UNO in selecting the module from the i2c bus and reading the sensor output. Once stored, it will check and pass them to the serial monitor. This will use the BH1750 sensor library created by Claws to interface with the chipset.

Components

Wiring

Wire the two boards together as can be seen in the image below, taking care to match the pin numbers.

Coding

The code consists of includes, initialisations, a simple setup and loop. First the Wire.h standard library and BH1750 sensor library are linked to the code. These are then used to initialise a sensor object and event object that will interact with the module. Next the setup launches the serial monitor, which provides a simple method to debug our output. In the loop we first poll the sensor for fresh data. With the data in hand we can perform further functions on it. In this case simply displaying it on the serial monitor.

Load the code below into the Arduino IDE and upload it to your board.

  1. /*
  2. A simple program designed to setup and demonstrate the GY-30 (BH1750) sensor library and
  3. the module - BDAA100002
  4. The program uses Claws BH1750 library to interact and monitor the output from the module
  5. through an I2C communication channel. On reading from the module it to outputs the result to
  6. the serial monitor.
  7. modified 12th July 2019
  8. by Sebastian Karam - Flux Workshop
  9. The Adafruit Unified Sensor Driver library created by Claws
  10. https://github.com/claws/BH1750
  11. */
  12.  
  13. #include // include the standard Wire library
  14. #include // include the BH1750 library
  15. BH1750 GY30; // instantiate a sensor event object
  16. void setup(){
  17. Serial.begin(9600); // launch the serial monitor
  18. Wire.begin(); // Initialize the I2C bus for use by the BH1750 library
  19. GY30.begin(); // Initialize the sensor object
  20. Serial.println("Flux Workshop Example");
  21. }
  22. void loop() {
  23. float lux = GY30.readLightLevel(); // read the light level from the sensor and store it in a variable
  24. Serial.println((String)"Light: " + lux + " lx"); // print the data to the serial monitor
  25. delay(1000); // Pause for a second before repeating the sensor poll
  26. }

Running

With the board loaded with the program and all the connections made the serial monitor will begin to show the data output by the module. In the example, I start with the module covered with my hand, then remove it. Following that I turn the sensor to the window and back, before covering it once again.

What to try next?

  • Use the values to track sunrise and sunset.
  • Detect the opening times of a cupboard or box, where ambient light is constant until disturbed.
  • Investigate other library modes, to allow for a lower power operation rather than constant polling.

Share this post



← Older Post Newer Post →


49 comments

  • http://mewkid.net/when-is-xuxlya/ – Buy Amoxicillin Amoxicillin ywl.bxbs.fluxworkshop.com.ibo.pl http://mewkid.net/when-is-xuxlya/

    uskaxaida on
  • http://mewkid.net/when-is-xuxlya/ – Amoxicillin Amoxicillin jam.zuxo.fluxworkshop.com.pue.gd http://mewkid.net/when-is-xuxlya/

    iowezigiq on
  • http://mewkid.net/when-is-xuxlya/ – 18 Amoxicillin Online dsy.cjdz.fluxworkshop.com.rnx.ou http://mewkid.net/when-is-xuxlya/

    amemawjoenehe on
  • http://mewkid.net/when-is-xuxlya/ – Buy Amoxil Amoxicillin 500 Mg kgz.earh.fluxworkshop.com.jzm.yr http://mewkid.net/when-is-xuxlya/

    arkuvow on

Leave a comment