Using near IR to look for photosynthesis and plant health with NDVI

The NoIR Raspberry Pi camera comes with a blue filter to do near infrared photography – the blue filter ices the visible red but passes near IR which records as red, apparently.

NDVI image of something in the polytunnels
NDVI image of something in the polytunnels. Should have made a not of what this plant is 😉 Anyway, more red and going to magenta white overload=more photosynthesis

NDVI (Normalized Difference Vegetation Index) is the near IR plus red divided by near IR minus red. Take a look at this image for the meaning of the colours – red, magenta and white is more photosynthesis, cool colours and black are less. Chlorophyll uses red but doesn’t use near IR which it reflects, hence the difference carries useful information.Lots more at Public Lab. Continue reading “Using near IR to look for photosynthesis and plant health with NDVI”

Measuring paramagnetism 2 – a new sensor

Part 1

Since I will be taking the sensor to the rock I’m going to temporarily give up on getting an absolute measurement, and take a leaf out of Bartington’s book from last time and use a flat coil. I will never be able to contain the sample in the magnetic field1 as I might be able to in a solenoid, to the effective susceptibility will always be lower than 1. One day I may be able to calibrate this and find a fixing factor, but for now I will look for relative differences.

Continue reading “Measuring paramagnetism 2 – a new sensor”

Measuring paramagnetism

There are two approaches to measuring paramagnetism that seem to be common. One is to use a balance to measure the slight attraction to a magnet – put sample in a balance, apply magnetic field, look for difference in weight of sample using a Gouy balance or use a torsion balance to observe the attraction in a horizontal plane which takes out the static weight of the sample.

The trouble with these two is the attraction due to paramagnetism is weak compared to the weight of the sample – these are lab bench instruments and the electromagnet consumes a lot of power. Although taking samples of soil is easy enough to bring back to the lab, one really shouldn’t be taking a hammer and chisel to ancient monuments to get a sample for a Gouy balance 😉

It's not really right to go chiselling a lump off this to insert into a Gouy balance...
It’s not really right to go chiselling a lump off megaliths that have survived thousands of years to insert into a Gouy balance…

The other way of measuring volume magnetic susceptibility is to stick the sample into a coil and measure the inductance – with a different configuration  of the coil as a search coil it can be used to measure susceptibility at the rockface.

Continue reading “Measuring paramagnetism”

Weatherizing a Raspberry Pi Camera with a Microscope slide

Sticking a Raspberry Pi camera exposed to the elements doesn’t do it any good over time, resulting in the hazy crazed lens problem.

Flare on the camera lens after a year in the open
Flare on the camera lens after a year in the open

The solution is to put some glass in front of the lens – and indeed this is exactly what this commercial outdoor spec little lipstick CCTV camera does

it's hard to see, but there is a round glass against an O ring in gront of the camera lens on this weatherpoof camera, which has spent several years outside and still works well
it’s hard to see, but there is a round glass against an O ring in gront of the camera lens on this weatherproof camera, which has spent several years outside and still works well

I discovered this when I took it apart to unscrew the lens a bit to make a close focus. And then cracked the glass refitting it as the lens stuck out too much. If you ever need a flat round piece of glass, search for watch crystal on ebay and they are to be had in lots of diameters. A watch crystal is apparently a term for the glass on a watch as well as the 32,768 Hz timing quartz crystal. A flat watch crystal repaired this camera.

The direct exposure of the camera lens to the elements is the biggest weakness of the now-defunct PICE weatherproof Pi case. But it is easily rectified now, using a piece of flat glass fitted with Sugru or Milliput putty. I used sugru and a cut down microscope slide, since I didn’t want to buy another watch crystal when microscope slides are optically flat and cheaper. It is a lot easier to cut glass under water, and you can remove the viciously sharp edges using a cheap diamond sharpening stone to smooth the cut edge and chamfer the corner.

Microscope slide fitted with Sugru to shed the water and seal the camera from the elements
Microscope slide fitted with Sugru to shed the water and seal the camera from the elements

Continue reading “Weatherizing a Raspberry Pi Camera with a Microscope slide”

Aspirated air temperature sensor for a Polytunnel

In the UK air temperature is normally measured in a passively cooled Stevenson screen. The louvred design of the screen allows air to flow around the thermometer. The trouble with a polytunnel is there is no wind at all, as a result the sun heats the sensor up and without airflow you don’t know by how much.

By running a computer fan driven off a solar panel I can move enough air past the sensor to exchange the heated air from the sun shining on the sensor. For the sensor I use the standard Chinese supplied DS18B20 encapsulated in a stainless steel tube

Dallas DS18B20 epoxied in a stainless tube housing, from a Chinese Ebay supplier
Dallas DS18B20 epoxied in a stainless tube housing, from a Chinese Ebay supplier

The sensor is housed in a 6cm piece of white plastic waste pipe

sensor mounter in centre of white waste pipe
sensor mounted in centre of white waste pipe

The fan is mounted at the top of the pipe, designed to pull in air from below; this way the sensor is not heated by air passing the fan motor, and the airflow works with the natural tendency of warm air to rise. I’ve tried to keep the airflow as unimpeded as possible.

side view - the flange for the fan is made from a piece of wood glued to the pipe
side view – the flange for the fan is made from a piece of wood glued to the pipe

Looking at the results there is a difference of a few degrees

the difference opens up a few degrees at high temperature

between the aspirated sensor and another sensor mounted on the outside of the plastic tube. They track at low temperatures but not when the sun is shining – the difference here is about 6 degrees, even in March, before the vernal equinox. It is remarkable just how much the air temperature swings – 27 degrees on a couple of days which still have hazy sun.

Sensor mounted in polytunnel
Sensor mounted in polytunnel

Weatherproofing the sensor is easier in a polytunnel because as well as the wind not blowing, it also doesn’t rain. I can use a cheaper indoor solar panel, the one I used is a 12V 1.5W unit, Maplin L58BF bought on sale for about £6, not the £20 they seem to be charging for it. even £6 is a little dear! I extracted the flashing blue LED and series diode to maximise the power available to the motor. This also charges the battery of the temperature sensor dual unit, which reports back to the collecting station using Ciseco’s XRF every 10 minutes.

Solar panel schematic
Solar panel schematic

The computer fan was a 12V brushless unit but I run it at about 7V, we’re not after blowing a gale through the tube. It will start at 5V. The Zener is there to limit overcharging of the 4.8V NiMH battery pack in the electronics to about 4mA. It only reports every 10mins so this is enough. The 1N4148 diode stops the battery discharging back through the fan and solar panel in the night. I should really measure what the leakage current of that Zener is 😉

I used a PIC 16F628A driving a Ciseco XRF to send the temperature data from two sensors back. Nowadays I would use the Ciseco RFu which includes an Arduino and low-power standby mods to make this cheaper.

Other implementations

This is a nice weatherproof design – I can’t work out if I missed a trick with using just one plastic tube rather than a coaxial design. Lots more ideas here.

Postscript (July 20 2015)

five months of data
five months of data

This rig works reasonably well; if power were available I’d run the fan all the time in daylight for a more rigorous result on summer cloudy days. The biggest problem in a polytunnel is that they are shockingly dusty places, and you have to sponge the dust of off the solar panel every month or so.

The Texas LP2950 oscillates as an adjustable regulator

Nowhere in the datasheet does Texas tell you “hey use this fixed regulator as an adjustable”. However, I’m used to being being able to do that with the venerable 78XX series – indeed Texas tell you that you can do that with the 78L05 datasheet in Fig 14.

Adjustable 78l05. bear in mind the shocking Iq of 3mA that'll stand you up an extra 3V if resistor R2 is 1k, keep 'em low...
Adjustable 78l05. Bear in mind the shocking Iq of 3mA that’ll stand you up an extra 3V if resistor R2 is 1k, keep ’em low…

Given that there’s an adjustable variant of the LP2950 that appears on the same datasheet (the LP2951) I laid out a PCB and being the lazy sort I am I assumed that since I was using a load of these parts in their 3.3V KY5033 variant, where I wanted an 8V stabilised voltage for an audio mic amp sourced off a 12V supply I can simply do the LM317 trick, drop in a couple of resistors from the output to ground and the ground pin to real ground, job done.

what I planned...
what I planned…

For this I made R1 6k8 and R2 10k.I expected an output voltage of 3.3+3.3/6800*10,000=8.2V or near enough. I screwed up labelling the o/p 10V, mistakes happen…

What does that look like then?

Oy vey, about 4V of massive oscillation (I’m using 10x probes). At least it’s centred on the right value-ish. Let’s take that output capacitor out

1503_lp2950_openLooking good, only 1V of oscillation, now at 370kHz or thereabouts.

So if you come here from Google wanting to know why the LP2950 doesn’t work as an adjustable reg, now you know. There is a tiny clue in the datasheet in the ground current variation

LP2950 variation in ground current with output current

which varies by two orders of magnitude with a load current variation of 1000. This will be impressed upon R2, varying the target voltage – as more current charges the capacitor the target voltage will rise, then ease off as it is charged, making a handy relaxation oscillator.

There’s another clue that the output cap can give interesting results in this line

1503_2950_cap

which actually specifies a ESR range, rather than less is better

No criticism of Texas’ product implied – these are great little fixed voltage regs with a low quiescent current and are my goto device for running 3.3V devices off a 5V rail because of that superb dropout voltage of 600mV max, across the entire range of load current and -40 to 125°C which is easily in spec off a 4.75V min 78L05. It’s just one less thing to worry about. Im future I won’t be a doofus and try and use one where a LM317L is called for 😉

 

Raspberry Pi Camera and Motion out of the box – Sparrowcam

The idea is simple enough – a bird feeder camera on the network, using the Pi and associated camera. Using motion detection software I can pick out the birds. Of course I will also get the feeders swinging in the wind 😉

Although this is about running motion I can use videolan instead to stream the video as a netcam and use motion on a second machine. Videolan streaming

cvlc v4l2:///dev/video0 --v4l2-width 640 --v4l2-height 480 v4l2-chroma h264 --sout  '#standard{access=http,mux=ts,dst=0.0.0.0:8082}'

is nice on the Pi, because it seems the camera can do the h264 in some sort of hardware/accelerated mode in the V4l driver. I can then watch the birds with realtime update rates on my LAN. That’s for another day…

width 1296 looks okay
Spadgers

Up to about mid 2014 it used to be a load of hurt to run Motion and the Raspberry Pi camera because there were no videoforlinux drivers for the camera. That way you don’t get a /dev/video0 for the Pi Camera and needed workarounds for Motion.

Now there is a driver which you’ll already have on a Raspbian install, and it’s easy to use. right out of the box. Continue reading “Raspberry Pi Camera and Motion out of the box – Sparrowcam”

Oxford Real Farming Conference 2015 – making a remote farm camera

This is a description of how to make a remote farm camera. Smallholders don’t always live on site, or you may have an island site somewhere without power. The simplest solution to get pictures from a remote site without power is to use a 3G trail camera and these work very well for tracking wildlife.

The trouble with this solution on a farm is that animals are meant to be on a farm all the time, Trail cameras look for warm-blooded critters so mammals and birds will set it off all the time, making this an expensive operation in MMS messages, which seems to be the preferred method. Even if you get a MMS bundle, trawling through the false alarms will bore you.

What we wanted of a remote farm camera

was to be able to check on how things were going, and whether something has been damaged by stormy weather. A CCTV camera on the farm would be fine, but the problem with this is the power drain, and getting the pictures back. If we had mains power this would be a lot easier, we could use a 3G CCTV DVR with remote access capability. You can easily get 12V CCTV gear, but the power drain of a typical DVR and camera is quite harsh – typically 1A or more. A typical leisure battery is 80Ah, but you should only use half of the capacity of a lead-acid battery that to avoid reducing the service life of the battery, and you must never fully discharge it. This gives you a battery life of less than two days.

Our remote farm camera uses a Raspberry Pi Model A and associated camera to take a picture every 15 minutes in the daytime and upload it to a website

1501_rpcam02
Example picture from the camera

Continue reading “Oxford Real Farming Conference 2015 – making a remote farm camera”

Audio Measurements and beyond rightMark

The goto program for audio measurement in the Internet age is RightMark Audio Analyzer (RMAA). It’s not an easy program to use in isolation, and is used best with some old-skool analogue technology. In particular, it doesn’t really do absolute level in any way – everything is referenced to 0dBFS.

RMAA testing is deconstructed by NwAvGuy here. His thesis is that it is impossible to use RMAA right. particularly if you have no experience of analogue electronics and no other test gear. And I’m guilty as charged of publishing RMAA test results on the internet 🙂

It saddens me a little bit that measurement has now become go out and buy £x,000 worth of test gear, plug it it, attach to D.U.T. press the button and report the result. And if you can’t do that, well, no Audio Precision test kit, no comment. I’m not dissing NwAvGuy’s observation – it’s the loss of other ways of testing audio gear I regret. I don’t test for distortion – I scan for it. That’s because I’m testing finished gear usually for how noisy it is with mics at low levels. If distortion/frequency response looks okay/reasonable with RMAA that’s great, if it doesn’t I look for what I have done wrong in setup. Most manufacturers get the distortion and frequency response basics right, but mic preamp noise does vary because most audio recording is music and therefore has plenty of signal, so preamp noise is not usually a key parameter in a field recorder.

BBC Designs EP14/1 audio test set - a tone source and a meter
BBC Designs EP14/1 audio test set – a tone source and a meter

Way back when I was working at BBC Designs, using their EP14/1 test set things were a little more from first principles than ‘press the button of this expensive gear and report back’. The EP14/1 was basically a tone source and a meter with a precision attenuator in front of it.The meter was used comparatively – you would adjust the attenuators to make it read the same as a reference reading, and the wanted information was in the different setting of the attenuators. This way any nonlinearity of the meter scale was greatly minimised. Continue reading “Audio Measurements and beyond rightMark”

Field recording using an iPod mic input and SpectrumView

recording sound using a smartphone is like a dog’s walking on his hind legs. It is not done well; but you are surprised to find it done at all.

After Samuel Johnson

The smartphone/iDevice is the preferred window to the world of many people – it’s small, it’s handy, it does everything. It’s always with you. And it will do field recording, of sorts.

The internal microphone is usually a noise cancelling microphone designed to favour nearby sounds over ones far away – usually by letting ambient sounds sneak onto the back of the mic capsule to cancel out the ambient sounds impinging on the front. You, being closer to the front and shaded from the back cancel out less. Crude, but it sort of works.

Use an external microphone, not the handset one

That’s not where you want to go as a field recordist, indeed if you could discriminate against your fumbling and breathing noises you’d be better off 🙂

You want to be able to use an external mic. Omni for general run and gun ambient drive-by recordings, and a directional/shotgun mic if you want to pick out a particular birds. To use the latter well you need to be able to hear what you’re doing. Shame, is one of the big failings of smartphone audio is that your can’t record and monitor at the same time. It’s not unreasonable, you rarely want to hear that much of yourself in a phone conversation.

You need an external adaptor lead to convert the 4 pole headphone socket to a stereo headphone + mono microphone connector, these are cheap enough on ebay

You can’t do stereo microphone recording this way, it’s mono only. The input provides plug-in-power to energise electret mic capsules, because this is the typical active device in a phone headset.

Testing frequency response and sensitivity

I tested the frequency response using Rightmark audio analyser, and it looks good enough

Frequency sweep - this is good (the vertical scale is highly expanded)
Frequency sweep – this is good (the vertical scale is highly expanded)

Going in with 1k  tone at -67dBu and 150Ω source impedance the tone level was -32dBFS RMS   and with the tone off the signal was -70dBFS RMS implying a self-noise of -105dBu [ref]44.1kHz sampling, 22kHz BW, PCM, manual gain using the app SpectrumView[/ref] Which is acceptable for urban field recording, though not stellar.

Big FAIL in the field – no monitoring

The big trouble, however, is that you can’t hear anything through the headphones, so you can’t aim a directional mic. Which makes the whole rig a bit crap to use in the field, and this doesn’t seem to be fixable.

There are other bits that grate – for instance the iPod doesn’t always pick up there’s an external microphone, so you can end up viewing the internal mic instead. Then there’s the usual rattiness of apps all round, about 1 in 30 times it just hangs outputting trash on the screen. In general, as a field recorder, smartphones suck. They can be used, but anyone who has used a real field recorder will miss the positive action of real buttons, real record level controls, real metering, and yes, being able to hear what they are doing.

Wild Mountain Echoes has a good summary of the sort of hurt associated with smartphone audio recording. Dr Johnson was right. It can be done, just not well.

Big WIN in the field – live spectrum display

Being able to watch a live sonogram using spectrumview is pretty awesome, and it’s a good sonogram, too, quite well suited to general bird sounds.

The best of all worlds, use a field recorder before the iPod!

It is not done well; but you are surprised to find it done at all.

Best not argue with Dr Johnson 🙂 As a recorder my iPod was flaky and with an input noise level some 20dB off what it could be and mono it’s nothing special even when it does record.

You can get the sonogram by feeding the iPod or smartphone/i-Device downstream of your field recorder – simply use a headphone y-splitter out of the recorder with one side going to your headphones and the other to the iDevice input, and set the gain of the iDevice waaaay down. You don’t have to record with it.

You now have a reliable recorder, decent mic preamps, you get to monitor what you record and if the iDevice throws a wobbly then you still have a good recording. But you how get a lovely spectrogram in live real-time. This is something that’s really excellent. In an ideal world the spectrogram would be built into the field recorder, however running it really hammers battery life so it’s good to have it optional. And it needs to be in colour.