The Light Fantastic

CY-30 Light SensorThis morning, a long-forgotten package turned up for me – a cheap but accurate light level sensor from China – claimed to be around 1 lux accuracy and giving a direct output in lux. A small board is available here in Britain for around £4 or the identical board from China for 98 pence. I chose the latter. It is called the GY-30 board.

The tiny board comes complete with connector which takes seconds to solder on (I put mine on the underside). There is an address line which does not need connecting and the I2c has pull-up resistors already in place so basically you provide ground, 3v3 and I2c.

I plugged this into one of our ESP826 boards and did the I2c search – it came back with device 35 (0x23).

The documentation has various modes but unless you are power saving (in which case the ESP8266 might not be your best call) you can just leave the thing on converting at high resolution 0-65k. I wrote two functions – one to initialise the I2c and to start the conversion off – the other function to read back the 16 bit value from the device.

tmpC1DBAt maximum resolution, you have to leave around 180ms between readings and of course it won’t start the next check until you read it so the best thing to do is just grab the readings maybe every few seconds depending on your application (once every 15 minutes would do me) and store it away somewhere.

Anyway I’ve added the code to the house control code – boards suitably updated (v1.6.50 or higher) can issue {gy30_init:35} and {gy30_read:35} commands. If you cover the sensor with your hand you will typically get a value of 4 or less. Ambient light in my office produces around 80-100 and pointing the unit up to the lights produces a reading of around 1000. Don’t ask me to do a sunlight test – wrong time of the year here in the frozen wastes of the Northeast of England.

I do plan to stick one in the window and log it – so when I’m off in Spain and people back here are saying “oh, it’s lovely and bright here” I can tell if they are telling fibs. Check out the blog entries on home control 2016, flashing the code for more info.



10 thoughts on “The Light Fantastic

  1. Yes I can confirm it is a GY-30 using the BH1750 IC. I bought mine from Banggood earlier this year before the pound collapsed against the dollar.

    What’s a Pratchett fan? Never heard that expression before.

  2. is it CY30 or GY30? I ask as I can’t find anythign with CY30 even on Aliexpress or eBay while I see few GY302 (using BH1750 sensor)
    can someone eventually point to a link to buy it?

      1. Both seems to use same chip BH1750, so I doubt there are any other differenca rather than “form factor” 🙂

  3. Hi Peter, yes these are a nice little device. I’ve had one running for about 9 months now on an ESP-12E and it has proven to be completely reliable. I use MQTT to send the data and log it in MQTT-Spy. I only use the vanilla Arduino -ESP I2C library but it does work really well. I think this device is infinitely superior to other light sensing devices for both accuracy and repeatability.

Comments are closed.