NDVI investigations of compost-enhanced crops

I made a couple of NDVI images of the beans which had been greatly improved using compost compared to those grown without. The principles of NDVI as based on that

Generally, healthy vegetation will absorb most of the visible light that falls on it, and
reflects a large portion of the near-infrared light. Unhealthy or sparse vegetation reflects
more visible light and less near-infrared light.[ref]Understanding the NDVI PDF[/ref]

Knowing that, it’s possible to see in the NDVI image that the compost-grown beans do seem to be reflecting more IR relative to visble light, I find this easier to qualify from the greyscale image Continue reading “NDVI investigations of compost-enhanced crops”

Remarkable win on beans with compost extract

Last year we made compost and compost extract for use in the polytunnels. The extract was also looked at with the microscope. Most of the compost after making extract was used in polytunnel which has tomatoes in it. These look healthy and were praised by another local gardener, but there’s no control. However, we did have a control on the extract applied to the beans in another polytunnel.

If you look at the picture at the head of this post, on the RHS of the picture is the control. This is what we would have grown normally.

in the middle on the top you can just see a blue ribbon which is where application of the compost extract stopped. On the left are the plants where compost extract was applied to the ground, it ran out at the blue ribbon point. Same plants, same time planted, and the same set of seeds. The difference in vigour, height of growth and yield is remarkable and clearly to be seen. Continue reading “Remarkable win on beans with compost extract”

Seed saving beans

The Seed Saver’s handbook says beans are easy to save, so it seems a good idea to start out with them, in this case some Sutton Dwarf beans. The idea if you leave them to dry in the pods and then save the good ones. Beans are an easy win as they adapt over the generations to the local conditions; they don’t use insects for pollination and the book says the gene pool is kept wide to allow self-pollination.
Right off the bat the book says that

The first pods to form are the best for seeds. They are to be found at the base and are larger than subsequent pods, Allow these pods to dry on the bush, and choose those from the most vigorous plants. Such refined steps cannot be taken on a large scale where a whole field is combine-harvested and threshed.

Well, we don’t have a problem picking seeds out of the combine harvester we don’t use 😉

the good bean seeds
the good bean seeds

The guys that wrote that book are Australian, and I guess they don’t have a problem with saying you need to store seeds at a relative humidity of 5%.

Closing the conservatory door at about 9 was a good move, though I am a long, long way from 5%!
Closing the conservatory door at about 9pm was a good move, though I am a long, long way from 5%!

So I am writing on the evening of what has been a reasonably warm sunny day and I see the RH starting to skyrocket to 50% by 10pm and realise that I need to close the door to the conservatory because the dew comes in the evening as the sun goes down, not in the morning. 5% is going to be a tough call in the UK, probably involving silica gel. Interestingly the Seed Saver’s Handbook says good airflow is more important that high temperature, and it should not go beyond 35C anyway.

long bean pods give the best results
long bean pods give the best results

They’re right about those lower pods – long beans are definitely the place to go for the size of the seeds. You have to be pretty discriminating about the seeds, however.

Continue reading “Seed saving beans”

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”

Using the microscope to grade compost and compost extract

This is using Elaine Ingham’s microscopy techniques to investigate thermal compost – some of what I saw. I am at an early stage of being able to do this, so any errors are mine and not Elaine Ingham’s 😉 The principle is to classify organisms by their morphology – aerobic fungi tend to have a colour, diameter wider than 2.5µm and/or have uniform septa. Spiral structures are bad, indiciative of anaerobic conditions, and ciliates (hairs all over the body) also indicate anaerobic – bad- conditions. Apart form the spirochete most of these are good.

This is on a 5x dilution, the recommended intial conditions (use 1ml of compost and make up to 5ml total with water left to stand so the chlorine has gone).

Composting win

If at first you don’t succeed, try again 🙂 The requirements of Elaine Ingham’s thermal composting are quite demanding, keeping the heap at over 55C for more than three days to kill weed seeds and pathogens. The previous attempt got really close then seemed to dry out, this appears to be a issue with using a lot of woodchip which is a difficult material to wet. This time I used less of it.

more green material with this heap
more green material with this heap

I used a higher proportion of green material, and more of the high nitrogen clover too. I filled the wheelbarrows with woodchip and then added water until it overflowed, then left it to soak overnight

this achieved over 55C for three days - the dip is when this was turned
this achieved over 55C for three days – the dip is when this was turned on Thursday evening

After it had been over 55C for three days I turned this heap, wetting the material as it was turned over. I should be able to turn this again on Monday, assuming it holds above 55C

Composting – take two

Time to put some of the learning from the last time into practice, with thanks to Polly for help with wrangling the materials –

Raw materials
Raw materials

The clover which it the high-nitrogen component because it fixes N from the air is on the black plastic. Loads of wood chip is in the bin and the wheelbarrow. First we put sticks in the bottom to improve airflow because the whole point of thermal compost is to keep things aerobic

base of sticks to improve airflow
base of sticks to improve airflow

We needed to wet the material. In the video tutorials Ingham recommends standing the material in water overnight. We wetted is using a fine spray on the hose

Lucia and Polly soaking the woodchip
Lucia and Polly soaking the woodchip

A heck of a lot of material goes into a compost pile – thanks to Polly and Lucia who helped at the working party Continue reading “Composting – take two”

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”

A lower energy more expandable Pigcam network

Is covering a 12-acre farm with WiFi a reasonable idea? If so, I could run multiple cameras, say have one on the cows and one on the pigs, all connected to a central location, On the upside, the farm is roughly square and with a mild slope to the ridge at the top. Everything is pretty much line of sight. On the downside, there’s no good central location, which would be the obvious way to service the farm with 2.4GHz WiFi. Distances are long – the field is about 250m wide/long, and I could easily pick up a 300m path length feeding from the edge.

the MiFi node and power management
the MiFi node and power management

Earlier experiments showed that I could in theory use native WiFi, using a router to receive BTFon from a broadband connection in the town over a high-gain antenna and redistributing it from a WiFi AP. The trouble is I am desperately short of power – every extra piece of kit means more frequent battery changing. In the end I went with a more powerful MiFi access point – one that supported an external WiFi aerial. I used a 9dB TP-Link patch antenna

This feed the farm from one edge, as it happens the antenna is furthest away from the most likely camera sites but slightly higher than the target sites. The signal pattern fans out quite well, serving the likely points of interest. I was chuffed with the performance of the aerial – it gives the right balance of directionality, as I don’t need to bother to serve the field behind me, but it gives very useful gain in the wanted direction – I can just about get a wifi connection with the internal antenna of my iPod touch from the opposite corner of the field. As the forest garden and some of the windbreak trees grow I may experience problems, but that is for another day. By then perhaps we have a site with mains power 🙂

For the MiFi unit I used a TP-Link MR3220 – it’s surprisingly hard to find a MiFi box with an external WiFi aerial socket, because not unreasonably they anticipate you using this sort of thing as a personal cloud. I had to live with the 9V powering and used a Chinese Ebay 12V to 9V converter switchmode converter to efficiently turn the 12V battery power to 9VDC

The other part of improving range is to upgrade the camera end with a WiFi card with an external rather than internal antenna; since the Pice case has been withdrawn I need another solution for that. The PICE case also still exposes the Raspberry Pi camera lens to the elements which is Not a Good Thing leading to the lens haziness problem.

It doesn’t really matter how big the camera is, so I took the opportunity of using a much larger box – a  Hammond case 1599 to fit it all in.

If you’re going to put something outside then the fewer holes you can drill the better, hence the use of sticky pads and cable ties as mounts, and the single 2.1mm power socket on the base, so water could drain out that way if necessary, and could be standing 0.5cm without affecting the electronics.

The case has several mounting lugs in the lid, but in the end I will have to drill a hole for the camera. I placed an O ring on the case and a microscope slide pressed down by foam and the camera to make a watertight seal but keep the elements out of the lens; that way hopefully I get to either clean or replace the microscope slide after a season is out rather than the camera.

camera mounted in the lid
camera mounted in the lid. Reed switch is top left wit the yellow wires, the 1p glued to the case holds the magnet there because they are made of steel these days not copper.

The 12V to 5V converter is mounted in the case; that way any cable losses aren’t too bad and the current in the supply cable is reduced, it is about 200mA max.

Setting it up in the field

Pig Camera in service
Pig Camera in service

The paving slab is there because the first version of the tripod ended up flat on its back in the morning. At least the construction can survive a fall of 2m. Perhaps the neoprene sunshade and the extra area at the top of the pole presents too much wind loading.

Camera close-up
Camera close-up

Controlling the Pi

I postulated all sorts of complex feedback when first considering this, letting the Pi tell the microcontroller to turn the Pi off with a GPIO pin, but it’s been massively simplified. A microcontroller powers up the Pi, and pulls the power after 5 minutes. Then it waits 10 minutes and does it again, provided that the 12V supply is enough (>11.5V) and it is daylight.

I use similar Python code to the first cut, but this time I start running the takepic.py camera code on startup. I look for a switch closed on the GPIO, and if so, abort uploading the picture because the Pi is in service mode1. This switch is a reed switch mounted on the inside of the case and activated by sticking a magnet to it, this saves a hole. It lets me get onto the Pi and configure it. Normally the switch is open, in which case the Pi tells the system to do a shutdown in 4 minutes, which is enough to connect, get Wifi network DHCP and SFTP the picture to the website. 5 minutes after powerup, the microcontroller managing power pulls the power from the Pi.

The shutdown command on the Pi minimizes the chance of corrupting the SD card, and the picture is written to the /run/shm/ ramdisk prior to uploading, since there is no point using up SD card write cycles with ephemeral data like that.

#!/usr/bin/python
#$Id: takepic.py 58 2014-11-06 20:54:02Z ermine $
import time
import picamera
import paramiko
import os
import socket
import datetime
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD) # USE Pi BOARD pins, not the BCM ver
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) # 7 is next to gnd on pin 9, so set pull up

# defs
camerafail=False;
DIR='/run/shm/'
imagename=socket.gethostname()+'.jpg'
remotename='WEBSITE.COM' # assuming this is reachable by ssh and www
try :
    with picamera.PiCamera() as camera:
        #camera.resolution = (2592, 1944)
        # The following is equivalent
        #camera.resolution = camera.MAX_IMAGE_RESOLUTION
        # run half res to test out connectivity etc and save money
        #camera.led = False
        camera.resolution = camera.MAX_IMAGE_RESOLUTION
        #camera.resolution = (1296, 972) # do half real to eliminate Bayer softness and save TX bandwidth
        camera.exposure_mode='night'
        camera.meter_mode='matrix'
        camera.start_preview()
        time.sleep(2)
        camera.capture(DIR+imagename, resize=(1296,972), format='jpeg', quality=20)
except picamera.PiCameraError,e :
    print e
    camerafail=True
finally :
        camera.close()
time.sleep(10) # hopefully nw is up by now 
if(GPIO.input(7) ==1):
    #print "will shutdown"
    os.system("/usr/bin/sudo /sbin/shutdown -h +4 &")

    if not(camerafail) :


        timedout=False
        connected=False
        counter=0

        while (not timedout) and not connected :
            try :
                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                s.connect((remotename,80))
                print(s.getsockname()[0])
                connected=True
            except socket.error,e :
                
                counter += 1
                print counter
            finally: 
                s.close()
            time.sleep(5)
            if counter >= 5:
                timedout=True
                print 'Failed to connect to ',remotename,' ',datetime.datetime.now().strftime("%y/%m/%d %H:%M")
        
        

         
        #upload
        if not timedout: 
            print 'ftp image starting ',datetime.datetime.now().strftime("%y/%m/%d %H:%M")
            try :
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(remotename, port=2222, username='USERNAME', password='PASSWORD')
                sftp = ssh.open_sftp();
                sftp.put(DIR+imagename, '/home/DIR/'+imagename)
                sftp.close()
                print "closed SFTP"
            except paramiko.AuthenticationException,e :
                print e
            except socket.error,e :
                print e
else :
    print "manually aborted by jumper 7 to 9"

Power savings

This has massively reduced the power drain of the camera – it is < 200mA for a third of the time, with an outage during the night of about 1/3 of the time, so about 1/3 × 2/3 × 200mA average, ie ~50mA. The original power drain was about 300mA 24×7.This power drain is much less than an electric fence which is usually about 150mA, so it could be used from the fence battery, which would then let us monitor the fence battery voltage as a bonus.

It also suits solar panel charging well, as the power drain is proportional to day length. The WiFi node draws more (a sustained 200mA during the day) but at least it is just one place where the battery needs changing more often – about once every two weeks. That’s livable with, but if I’d used a WiFi long-distance connect and a WiFi high power AP that would be shortened too much, particularly as logging into BT Fon would require another Pi to keep the connection open. GiffGaff run about £7.50 per Gb PAYG which isn’t bad.

Got pigs

Got pigs
Got pigs, end of the day picture in lowish light, 4:30 pm November

So far so good. The new pigcam

  • works all over the likely sites on the farm
  • concentrates the data through one GiffGaff SIM[ref]data service gets cheaper with volume, so this is much better than each camera having a SIM[/ref]
  • reduces power at camera sites to minimal
  • lets me add more than one camera to the system

which is a success compared to the single site version which had a very high power drain because it wasn’t being power-managed.

Pigs
Pigs, photo taken with a regular camera earlier in the day

  1. In service mode I get to ssh into the Pi to configure it, and issue the shutdown command manually – I bypass the microcontroller shutdown for that 

Remote Farm camera – experimenting with WiFi

Clive from the Raspberry Pi Foundation very kindly let us have a Pi Model A and camera, so it’s time to take this project forward a stage. At the moment the alpha test version is in service keeping an eye on our new piglets. Although the original purpose was to keep an eye on our newly arrived cattle pigs are more enterprising, so it’s good to know where they are

Our camera on the pigs
Our camera on the pigs

Development was stalled however since it’s not easy to work on a piece of kit in service.  Ideally one MiFi box could serve a number of cameras. This would reduce the camera power drain and consolidate.

The trouble is that the site is on the edge of town, a couple of hundred metres from the nearest houses, and I want to use BT Wi-Fi

Yagi wifi antenna
Yagi wifi antenna

I acquired one of these from ebay I didn’t have much hope for the integrity of the device, and to gain height I needed to go 250m further way from any likely source of WiFi. But it worked a treat, as a WISP client, I’m amazed. I was able to see 18 access points, five of which were BT WiFi , 3 of which were 5dB or above. The TP-Link gives a decent link at more than 5 and nothing at 2. I streamed a video to confirm the stability of the link.

TP Link signal strength with yagi
TP Link signal strength with yagi

I use it with a TP-Link TL-WA5110G which has the advantage of having a sma antenna socket and a native power supply of 12V. Although the adaptor is specced at 1A I measured the power drain at about 210 mA (~2.5W @12V). Which isn’t great but not terrible

A WISP client is not a  repeater

The trouble with using the tP link as a WISP client is the signal is presented as Ethernet, and I’d then want to re-radiate the signal on a different Wi-Fi network.  I could set it as a repeater, but then every Raspberry Pi would have the hurt of logging into BT WiFi. Whereas if I use a Raspberry Pi connected via ethernet to the TP-link and a WiPi dongle to connect to the farm I can collect pictures from the cameras on the farm network and perhaps power-manage the TP Link to only update every so often.

So an unexpected win, and I can look at using a Model B as a concentrator