Tag Archives: CY-30 Light sensor LUX

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.

Enjoy.

Facebooktwittergoogle_pluspinterestlinkedin