Tag Archives: arduino

Network Attached Light Sensor

It was one of the projects that started out with an innocent enough question….

What do you know about light sensors?

The answer was not much, but I can find out, if you can give me some context (which is a pretty standard answer from ETS if it’s something new to us). The person asking was interested in measuring the natural light levels at a reasonable number of out door locations in order to help in making a call on if a given activity was safe to continue.

The client had already been looking at an existing solution which was using USB enabled light meters being routed over ethernet back to a central location. This felt like a really clunky solution so I was asked to have a look to see if I could come up with something a little different.

My first thought was to look at using something with a LDR but that would only really give relative light levels or require a lot of work to calibrate the system. It was time to have a bit of a poke around.

After a bit of searching I found reference to a TSL2561 ic which is a light level sensor that outputs via I2C. I found 2 boards with these sensors mounted, the first from Adafruit but I couldn’t find a UK supplier to get one to test with. A bit more digging and I found a very similar Sparkfun board that was available from Cool Components in the UK. The sensor has a range of 0.1 to 40k lux

The client has a PoE enabled ethernet network covering the site they wish to measure which means I should be able to thuse the a PoE enabled Ethernet Arduino to read from the sensor and report the values back to a central location. I used the sample library from Sparkfun as a starting point and then extended it with the MQTT client library from Nick O’leary.

I threw a prototype together with a breadboard and installed it on the window sill in my office to see how it performed. On the whole it seams pretty good, but I need to find a off the shelf meter that measures in lux to see how the values compare.

I now had a sensor that is publishing it’s light levels about once a second, this solved the initial problem but I needed to visualise the results. I fired up Node-Red to take the values and do a few things with them.

  • Stash the timestamp and light level in a mongo db store
  • Publish alerts when the value dropped below a given threshold
  • Use the light level to change the brightness of my Digispark RGB LED

I also ran up a visualisation using the Rickshaw Javascript library which allows you to draw time series charts using the D3 visualisation library.

The chart on the left show the sun coming over the building opposite my east facing office windows then cutting off sharply as it tracks round to the west.

The next challenge is to come up with an enclosure for the whole thing so it can survive outside in the British summer.

Budget Blink(1)

Production blink(1) units

About a month ago I spotted Kickstarter project for a device called a Blink(1). This was a little USB device that acts like Ambient Orb and it made by the same folk that make the BlinkM 3 colour LED board that is used in them. I had loads of ideas with what to do with one.

The project had already reached it’s funding target and it had actually delivered. The devices where available to order directly from ThinkM here. I was all set to buy one except for 1 thing, the price. While I don’t really have a problem with ThinkM wanting $30 each for them, the problem is not even with the fact that HMRC will want to charge me VAT (at 20% on anything imported with a price of more than £15) on this when it is imported the real issue is that which ever courier handles the UK end of the delivery will charge me at least £8 in “handling” fee for the privileged.

Digispark and RGB Shield

I put the idea to the back of my mind for a while with the hope that the price would come down or a UK supplier would be found. While waiting I came across another Kickstarter project for a really tiny Arduino called a Digispark from the Digistump team. As well as the digispark boards themselves they where doing a range of shield, one of which was a RGB LED shield. Being a miniature arduino means I should be able to add the odd sensor or two to the board which I can use to influence the colour shown by the LED.

And to top it off I could order 2 Digisparks and 2 RGB LED shields + shipping for $26 which comes in just under the import limit for VAT.

The package was waiting for me when I got back from a weekend away and I managed to grab 5 mins today at the office to use the soldering iron to put one of the shields together and add the headers to the first digispark.

I plugged it into my laptop and the standard blink sketch seamed to be running fine. I started to follow the instructions on the wiki to set up the development environment under Linux and I think I followed it all properly but I could not get the tools to upload a new sketch to the device. I have added a comment to a similar question on the forum. In the mean time I have managed to get it all to work on my Windows machine.

EDIT: Following a comment on the forum suggesting I try plugging the digispark into a powered hub to program it I have managed to get my second digispark programmed from Linux.

Along with the RGB shield there is some sample code that makes the digispark behave as a HID device and some python code that allows you to send it RGB values to set the colour shown much the same way the Blink(1) works. When I get 5 mins I will be doing the obvious MQTT hack to allow RGB values to be posted to a topic to set the colour then look at hooking it up to some of the data feeds available.