Raspberry Pi microscope

I am part of A/V project echo 10-9, together with Robertina Šebjanič. The development of the echo 10-9 project is based on research and experiments with ferrofluids, oils and nanobots, which create their own choreography in relation to different micro- and macrofluids, nanomaterials and magnetic reaction fields, in unison with physical and chemical effects. With their interventions, the authors stimulate the self-generated or autopoetic chemical reactions on multiple levels, influencing the sonic composition and choreography between the nanobots.

Until recently, we used hacked Playstation Eye USB camera, hooked to the computer, and video out to projector. As fun as it looked in the first place, we found a major drawback – camera’s resolution, which is only 640×480 pixels; so the projected image is a bit pixellated. Because of that we wanted to upgrade camera’s resolution and at the same time discard the use of laptop on stage. The solution was to use a RaspberryPi with a camera.

IMG_1520

You’ll need:

  • Raspberry Pi 2 B
  • appropriate miniSD card
  • power supply
  • Raspberry Pi camera board
  • USB keyboard (for setup)

First, download Raspbian/Wheezy OS and install it on SD card. Then put SD card in RPi, connect camera, keyboard, HDMI screen, network (preferably to your router) and power supply.

On the first boot you’ll be shown a RPi Configuration Tool; first you should “Expand Filesystem”, then set up “Internationalization Options”, “Enable Camera” (very important), and optionally “Change User Password” (default user is pi with password raspberry). After exiting you’ll be prompt to boot.

Now it’s time for upgrade and other fun activities, so we’ll move to computer for easier setup. Open Terminal window (I use OSX) and enter ssh@<IP>, where <IP> is PI address of your RPi given by the router. When entering a command line, type in sudo apt-get update && apt-get upgrade. After that type sudo apt-get install python-picamera. To create a Python script for our camera type in command line sudo nano rpicam.py and copy in the following text:

# Raspberri Pi Camera Python Script

import time
import picamera

with picamera.PiCamera() as camera:
camera.sharpness = 0
camera.contrast = 0
camera.brightness = 50
camera.video_stabilization = False
camera.awb_mode = ‘auto’
camera.ISO = 0
camera.exposure_mode = ‘auto’
camera.meter_mode = ‘average’
camera.image_effect = ‘none’
camera.start_preview()
time.sleep(99999)
camera.stop_preview()

# color effects (0 < u < 255 and 0 < v < 255)
#camera.color_effects = (u, v)

# contrast (-100 < u < 100)
#camera.contrast = -i

# image_effect
# Image effect mode options:
# none, negative, sketch, denoise, emboss, hatch, gpen, pastel, film, blur, sat$
# These effects don’t work:
# solarise, oilpaint, watercolour, colourswap, colourpoint, colourbalance
#camera.image_effect = ‘posterise’

# rotation (0, 90, 180, 270)
#camera.rotate = 90

# vflip (False, True)
#camera.vflip = False

# hflip (False, True)
#camera.hflip = False

# preview_fullscreen (False, True)
#camera.preview_fullscreen = True

 

To save file press Ctrl+O, confirm save and exit with Ctrl+X.

You’d also want toturn of the red LED on the camera board. In command line type sudo nano /boot/config.txt and add a line:

disable_camera_led=1

save file with Ctrl+O, confirm save and exit with Ctrl+X.

Now run the Python camera script by typing in command line sudo python rpicam.py, and if everything is set up correctly, you should see a video on your TV (or wherever is the HDMI connected) screen. Exit the script with Ctrl+C. There’s a number of video setting that you can change in rpicam.py script, by uncommenting (removing #) the line and changing the value.

And if you want to the our camera script automatically after boot up, type in command line sudo nano /etc/rc.local and add a new line:

python /home/pi/rpicam.py &

save file with Ctrl+O, confirm save and exit with Ctrl+X.

Now type in command line sudo reboot, and after booting you’ll see a video feed from camera on your screen.

 

We successfully made a Raspberry Pi Camera, now to use it as a microscope, you should turn around the lens on a camera or install a new one – follow these links for guidance: 1, 2, 3.

 

 

Additional links:

https://www.raspberrypi.org/documentation/usage/camera/python/README.md

http://embeddedartist.dernulleffekt.de/doku.php?id=picamera

http://picamera.readthedocs.org/

Advertisements