Introduction: A Raspberry Pi Multispectral Camera

A multispectral camera can be a handy tool to detect stress in plants, or recognise different species in lieu of the differences in the reflectance signatures of plants in general. If combined with a drone, the camera can provide the data for quick NDVIs (Normalised Difference Vegetation Index), create mosaics of farms, forests or woodlands, understand nitrogen consumption, create yield maps and so on. But multispectral cameras can be costly, and their price is directly proportional to the sort of technology they implement. A traditional approach to spectrometry is to use several cameras with long or short bandpass filters that allow the required spectrum to pass trough while blocking the others. There are two challenges to that approach; first, you need to trigger the cameras at the same time, or as close as possible; and second, you need to register (merge images layer after layer) the images so they can form one final composite with the desire bands in it. This means that a big deal of post-processing needs to be done, consuming time and resources (using expensive software such as arcmap, but not necessarily). Other approaches have dealt with this in different ways; recent technology developments at processor level have allowed the creation of scan CMOS sensors with band filters integrated in the sensor's layout. Another approach is to use a beam splitter (prism) that would direct the different beams of light to a different sensor. All these technologies are extremely expensive and therefore out of the reach for explorers and makers. The Raspberry pi compute module and its development board offer a cheap answer to few of these questions (not all though).

Step 1: Enabling the Cameras

Make sure you follow the steps for setting up the cameras in the CM as indicated in the following tutorials:

https://www.raspberrypi.org/documentation/hardware...

Trigger both cameras at the same time using:

sudo raspistill -cs 0 -o test1.jpg & raspistill -cs 1 -o test2.jpg

Use the following topic if for any reason it didn't work:

https://www.raspberrypi.org/forums/viewtopic.php?f...

Further instructions in case you are starting from scratch with the CM here:

https://www.raspberrypi.org/documentation/hardware...

Step 2: Wireless Serial Communication

Buy a set of telemetry radios like these:

http://hobbyking.co.uk/hobbyking/store/__55559__HK...

These radios have four wires: Ground (black), TX, RX, VCC (red). Peal off one extreme of the cables and use female connectors that fit the GPIO pins. Connect the black connector to ground, red to 5V, TX to pin 15, and RX to pin 14 of the J5 GPIO header of the compute module development board.

Make sure you set the baud rate to 57600, and that your host computer has recognised and added the radio as COM (in Windows use the device manager for that). If using Putty, chose serial, the COM port (3, 4 or whatever it is in your computer), and set the baud rate to 57600. Switch your CM on and after it finishes loading, click enter in your computer if you don't see any text coming through the connection. If you notice any garbled text, go and check /boot/cmdline.txt. The baud rate should be 57600. if any further problems arise, please check the following tutorial:

http://www.hobbytronics.co.uk/raspberry-pi-serial-...

Step 3: The Cameras...

You can actually use the cameras in their original configuration, but if not, you will need to modify them in order to accommodate the M12 lenses. Bear in mind that the raspberry pi cameras V1 and V2 are slightly different, so, old M12 holders won't work on new cameras. Also, there was some problems when triggering the new cameras in parallel, if you experience any of this problems please check this topic in the raspberry pi forum:

https://www.raspberrypi.org/forums/viewtopic.php?t...

In any case, a sudo rpi-update should fix the issue.

The M12 lens holder can be 'grind' with a Dremel in order to fit the connector of the CMOS sensor with the camera board. Unscrew the original lens, and place the new lens over the M12 holder. For better results you can actually get rid altogether of the original lens adapter, but it might not be worth the work in light of the risk that entails to damage the sensor. I destroyed at least six camera boards before managing to get rid of the plastic holder that sits above the CMOS sensor.

Step 4: Wifi Connection and Extra Storage

The CM development board has just one USB port; as a result of that you have to use it very wisely, e.g. wifi connection. If you want to go around that, you will have to use your soldering iron skills and attach a dual USB connector under the development board, where the USB is soldered. If you are using the same I have

https://www.amazon.co.uk/gp/product/B00B4GGW5Q/ref...

https://www.amazon.co.uk/gp/product/B005HKIDF2/ref...

Just follow the cable order in the picture.

Once done, attach your wifi module to the dual port, power on the CM and see if the wifi module is working correctly.

It is easier to attach an SD card than a USB drive, so buy something like this:

https://www.amazon.co.uk/gp/product/B00KX4TORI/ref...

To mount the new external storage, follow this tutorial carefully:

http://www.htpcguides.com/properly-mount-usb-stora...

Now you have 2 USB ports, extra storage and wifi connection.

Step 5: Print the Case

Use ABS

Step 6: Put the Pieces Together

Before you assemble the camera, connect a monitor and keyboard to the CM, and focus the lenses. The best way to do that is to use the following command:

raspistill -cs 0 -t 0 -k -o my_pics%02d.jpg

That runs the camera forever, so observing your screen, tight the lens until is focused. Remember to do that with the other camera by changing the -cs command from 0 to 1.

Once your lenses are focused put a small drop of glue between the lens and the M12 lens holder to prevent any movement of the lens. Do the same while attaching the lenses to the case. Make sure that both lenses are aligned as much as possible.

Use a drill to open a hole on the side of the case and put through the radio antenna. Place the radio securely by using double face tape and connect it to the GPIO.

Place the CM development board inside the case and secure it with 4 10mm metal hexagonal extenders. Secure the camera connector adapters so they don't bounce freely inside.

Step 7: Configure Dropbox-Uploader, Install the Camera Script.

Install dropbox_uploader following the instructions provided here

https://github.com/andreafabrizi/Dropbox-Uploader

Use a script similar to that in the picture.

Step 8: Final Product

The final camera can be placed under a medium size (650 mm ⌀) drone or even smaller. It all depends on the configuration. The camera is no more than 350-400 grams.

To power the camera, you will have to provide a separate battery, or connect the camera to the power board of your drone. Be careful not to exceed the power requirements of the CM board. You can use the following items to power your camera:

https://www.adafruit.com/products/353

https://www.amazon.co.uk/USB-Solar-Lithium-Polymer...

You can also build the support, and the anti-vibration dampers according to your drone specifications.

Once you have taken the first pictures, use a GIS program such as Qgis or Arcgis Map to register your images. You can also use matlab.

Happy flight!