UV Meter

UV is important to reptiles (and people) in processing vitamin D3 which is needed to absorb calcium. Without it reptiles often suffer from Metabolic Bone Disease (MBD) which leads to weak bones and can be fatal.  Thankfully, pet shops have the answer, UV producing globes which can stave off the dreaded MBD.  These are in the form of T8 florescent tubes or compact florescent globes and go for $50+ each.  And, yeah, they need to be replaced periodically.    How do I know if I replacing a globe while it is still producing enough UV?  How do I know I haven’t waited too long?  The standard wisdom is to replace them every 6 to 12 months which can add up across multiple tanks not to mention the environmental impact of whatever goes in to making them.

Or, I can measure it.  UV meters sell for $400 but I thought I might be able to do something myself.

I had an Arduino Uno R3 and a TFT touchscreen lying around so I picked up a UV sensor and gave it a go.


The sensor

There are quite a few UV sensors around, most with a narrow frequency response.  While the wavelength of vitamin D3 absorption is around 300nm (UVB), UVA is also important for reptiles.  For this reason and to avoid missing the relatively narrow peaks in the output of commercial UV lamps I decided to go with the  ML8511 which seems to have the broadest wavelength band of the UV sensors I could find.  Reminder: Always read the datasheet, ideally before you buy it or you could be disappointed


ML8511 frequency response


Example UV lamp output (Exo Terra : Exo Terra CF lamp)

It produces an analog voltage relative to the UV intensity detected.  It is then easy enough to map the voltage to an intensity after sampling the analog voltage a few times to smooth it.  Some code was reused from a DFrobot example.

A quick walk outside and I could see the intensity to go from 0 to 3 mW/cm^2 which seemed reasonable for a mostly sunny winter’s morning in Melbourne.

Breakout for ML8511 from my usual go-to : ML8511 from core electronics


I used an Arduino UNO R3 clone and wired the sensor:

  • Power : 5V
  • Ground : Ground
  • Analog Output : A4 input.  (to avoid clashing with A0 to A3 which can be used by some of the display/keypad shields)

I soldered (well actually my friend did who has much steadier hands) it straight to the Arduino board to avoid the extra thickness of a prototype board.



Adafruit make these cool TFT resistive touchscreen shields for Arduino and I couldn’t resist buying one.  The screen update is pretty slow (visible flickering) when used with SPI bus but works really nicely in this project when I only redraw elements when they change.

The library provided with the screen and touch sensor work like a charm so integration was pretty straight forward.  It provides basic drawing functions like line, circle, rectangle and text but you need to build text box and button classes yourself if you want to simplify building a UI.

Adafruit TFT resistive touch screen available here.




The intensity varies (by the inverse square law) over distance so an intensity without a distance is not meaningful when judging to the output of the globe.  Instead of being forced to measure a distance each time I decided to measure the output right at the globe which involves sticking the device up and into each cage.  To avoid having to read off the screen while performing a yoga move I made the main output an output of the max output registered so I can put the device in the cage up to the globe and then pull it out to get a measurement.  I included a smaller instantaneous output and voltage output as well.  To reset the captured measurement I hit reset button on the screen.

The Max and Instantaneous values are displayed in a color indicating if they are in the range expected of a “good” globe.  Green for good, yellow for reduced and red for “its dead Jim”.

The tubes provide light across the length of the tube while the CFs provide a more concentrated source so the expected output for each is different at the globe.  To account for this the user can select CF or TUBE to change the assessment thresholds.

Finally, the zero mW/cm2 point seems to fluctuate a little (~0.02V) so I also include a calibration button which set the current instantaneous measurement to “0.0 mW/cm2”.



The Code

It is interesting writing Arduino code as it is C++ without the std template library (for memory reasons) so we have classes but no built in container classes for example.

It is a pretty simple application so I didn’t get too carried away.  I created a textbox class and then extended that to a button and provided just the visual customisation I needed (background colour, text colour & size, textbox size, textbox position).  I extended that for buttons with a simple isIn function for when the screen is touched and a selected flag to give it two states.

Check out the code here: UVMeter on GitHub

I update the display at 2Hz but only redraw objects that have changed, this avoids the flickering you get if you redraw objects each time.  Note, if a text value (i.e. a numerical display) is changing you need to redraw the background before rewriting the text as the text just redraws over the top leading to a mess of drawn pixels – hence a lot of text boxes with black background.

What is left

The device is not in a case yet and I currently power the Arduino with a mobile phone power pack.  I hope to build a case with a battery pack with 3D printing but it could take a while to get to the top of the list so if anymore is keen to do it let me know and I’m happy to be “first to be second” as they say.


This turned out to be pretty straight forward and useful.  Most of the time on the project will be in building a case for it!


Yet Another Monitor

It is probably the most obvious and straight-forward IoT project there is but for me it was a chance to try some technology I haven’t had a chance to use – the ‘ol ‘monitor the temperature and display some pretty graphs’ project.  Much of what I have used is overkill for the need but provides a good base of knowledge for something bigger.

The Project

Monitor the temperature of up to 20 reptile enclosures, logging the data to ensure an optimal environment, particularly during the winter cooling period and correlate successful breeding with winter temperatures.

The Solution

Using every buzz-word in one project… IoT, “the cloud”, AWS, Python.

YAM (1).jpg

I’ll go in to more detail on each part in future posts to set the scene this is how it went.

Part 1. Sensors

I need around 20 sensors spread over two sides of a room so the DS18B20 sensors in a waterproof housing are a good option.  Cheap (on ebay) and communicate via digitial signal over a 3 wire bus (incl. power & ground) so less wiring and no noise/voltage drop issues from an analog sensor.

Part 2. Arduino / Particle Photon

Two of a number of options for wifi connected micro-controllers.  Read the sensors from the bus on a digital input and broadcast through MQTT. The use of MQTT means any number of devices can be connected to any number (within reason) of sensors without the upstream processing needing to know or care.  JSON allows data to be encoded in a human readable and easy to integrate in python format.  Sure the payload is larger than a binary message, but in this case, who cares?

Sneak-peek : The Photon is much better than the arduino in this context.  The new raspberry pi zero W would also do the job with a 5 line shell script at AUD$15.

Side-note: Am I old for realising the Pi Zero W is more powerful than the first $10k I spent on computers?

Part 3. MQTT Broker

Handy gateway to “the cloud”, down-sampling data, adding sensor -> location mapping plus security and buffering to the MQTT connection to the cloud.

Part 4. Storage

A database as you expect.  NoSQL and in the cloud : because I can…  And so I can access the data outside my network without opening up my ports.

Part 5. Display

On the web, using python and one of the many charting libraries, hosted in the cloud.  If 100,000 people want to view the temperature I keep my S. ciliaris at they can, if I pay for the capacity…. And again, I don’t need to open my ports.

This was an opportunity to try flask and bokeh python libraries for web-framework and charting respectively.  Django and google charts would be fine too.

I haven’t put much effort in to the display so far so it is pretty basic and clunky but works as a proof of concept.

Check it out for yourself live : YarraRiverReptiles Live!




This is still a work in progress, things to clean up and features to add but it is a start.  If you are interested in more details, check out the follow up posts over the next few weeks or get in touch.