Analogue DSL Bandwidth meter

March 20th, 2016 robin Posted in Just for Fun, Photon | No Comments »

Got round to doing some hardware hacking again! :)

I put together an analogue DSL bandwidth meter display – it shows the current percentage of bandwidth (upstream/downstream) used:

DSL bandwidth meterfinished-meter-sidebreadboard

That’s some ugly MDF board to hold the Particle Photon, two 3V voltage meters, and an LED which lights up if the data is stale (hasn’t been updated in >20s).  I soldered a little breadboard together with the sockets for the photon, cables out to the meters, and a resistor for the LED.

The components are:

Thanks Jeremy for the inspiration for this project! :)


Monitoring heating oil levels with a webcam

December 13th, 2015 robin Posted in Just for Fun | No Comments »

Challenge: measure the level of heating oil in a tank (in a rental house) non-invasively and on the cheap.

Requirement: works with an oil tank of milk-white plastic where you can optically see the oil level through the wall of the tank.

Step 1 – get an IR PTZ webcam

I got a DBPower VA033K+ webcam for <30EUR on Amazon.   It has a resolution of 640×480, infra red lamps, pan/tilt/zoom and even a plastic wall mount.  Mount it in your oil tank room so you have a good view of the oil tank:

snapshot-oil-tank

Step 2 – mark the oil tank

Like above, use a marker to draw a vertical line down the side of the oil tank, and mark it every 5cm.  Move the camera (if it has PTZ (Pan, Tilt, Zoom) you can do this without even getting out of your chair!).

Step 3 – how many litres per cm?

This involves a certain amount of guess work, and a lot of inaccuracy… we have 3 x 3000l tanks, and it works out at about 35.37l/cm.  Of course the bulge of the tanks will make that vary over the height, but it’s a good enough value for me to work with.  As you can see, I chose to monitor a 30cm section to get higher resolution – I will have to move the camera over the course of the year as the oil level decreases.  The precision at this resolution is pretty phenomenal: 30cm at 480px == 0.0625cm / pixel == 2.21l / pixel

Step 4 – Convert the image to litres of heating oil

I used imagemagick to:

  • take a a 60 pixel vertical strip just left of my marked line
  • use edge detection to highlight the boundary
  • reduce to a 1-pixel wide strip
  • output image to a text file

This is all wrapped in a perl script (webcam-oiltank-monitor) which further identifies the boundary (black line == RGB value 0,0,0), and calculates the exact cm height interpolating from a mapping where I have noted the height in cm of the pixels of my reference line.  The height in pixels is then converted to litres with the conversion rate noted above.

The script also outputs an image file to confirm that the correct height was identified by painting a red line:

oil-level-marker

You might need to fiddle with the brightness and contrast settings to get it to identify the line well…

Step 5 Monitor

Feed the output of the script through logstash to elasticsearch and display with kibana:

oil-levels-kibana

As you can see, it’s only been monitoring for a couple weeks, but it will be interesting to follow this over the course of a year!

Issues

  1. Power failure – the camera that I used scrolls full left-right and up-down before resuming its position if power is lost, and the position it gets is close but not exactly where it was before.  Either add a UPS (as the camera I use runs on 5VDC, a USB battery bank which allows simultaneous charging/discharging would work), or kill the PTZ and lock the camera in place.
  2. It seems there is some balancing system (a fuel pump?) between the tanks such that level in the tank I am monitoring goes down a while, then bounces up as the level in the neighbouring tank goes down… this makes for odd bumps in the data, but over the days it averages out.

Monitoring bird nest

December 10th, 2015 robin Posted in Just for Fun | No Comments »

I did something like this a few years ago, but this time it’s a bit better with an IR (infra-red camera).

I got a cheap DBPower VA033K+ wlan webcam on Amazon for about 20EUR.  These are pretty neat cameras with PTZ (Pan, Tilt, Zoom) functionality and IR lighting.  The image quality is crap, but what do you expect for 20EUR eh?  The image resolution is 640×480.

The camera is also horribly insecure… while you can set a username/password to access the web interface, it has a telnet port open which you can log into with the ingenious credentials root:123456 … (BusyBox v1.12.1 on Linux version 2.6.21) so yeah… you probably don’t want to use this webcam in a public network!

I ripped out the main board and camera from the body (discarding two servo motors, one bearing and a piezo speaker) – all can be unplugged from the main board easily, and the camera functions fine without them attached.

Then I drilled a hole in the top of a bird nest box we have hung under the eves behind our garage (east facing is good for birds nests: gets early morning warmth but doesn’t get cooked in the afternoon), and made a rough wooden box to house the main board and camera, then glued the camera in place, adjusted the focus for the lens (yes!  you can adjust the lens focus on this webcam from infinity down to a few mm!), and the results look like this:

birdcam-insides

(note that I bent the notification LED upwards so that it does not glow green in the nest.  You might consider snipping the leads to darken it completely)

birdcam-outside

The birds nest is hung just under the roof eves, so even though it is outside, it’s not likely to get any direct rain, and I hope the box will protect the electronics enough from the damp.

This is the resulting view:

Birdcam snapshot

Now we just have to wait and see who will nest there come spring time (or maybe take shelter there on a cold winter night). :)