Introduction: Raspberry Pi HQ Camera Microscope - a Minimalist LEGO Version

About: Scientist working in in-vitro diagnostics industry. Playing with all types of sensor as a spare time hobby. Aiming for simple and inexpensive tools and projects for STEM, with a bit of science and a bit of sil…

In the following I would like to describe a very minimalistic version of a microscope, using the new Raspberry Pi HQ camera module and the "microscope lens" offered by Pimoroni. The current version of the microscope rig is very much reduced to the minimum, and just consisting of LEGO pieces that were at hand.

I had been working on microscopes based on the Raspberry Pi camera a few years ago, at the time using a WaveShare PiCam module with a small macro lens. Parallel to the relase of the new HQ Raspberry Pi camera, Pimoroni released a super-macro "microscope" lens fitting to the HQ camera.

I wanted to check the capacity of the camera/lens combination. But, as I had not ordered with the lens with a microscope stand, I needed to generate one by my own. I choose to try to build one using LEGO parts, as a simple, cheap and flexible solution to setup and optimize layouts for different applications and objects to be analysed. So the layout used presented here started just a quick fix, and there is still much room for improvement. But I found the quaity of the images very impressive for such a simple and inexpensive solution, and decided to share the project and some of the images with you.

I would like to see your layouts, ideas and images.

To have a better impression of the quality of the images attached here, please click on the example picture and zoom into them.


Edit Dec. 2020:
Since publishing this instrucable I wrote a Python script to simplify handling of the microscope based on the picamera module. In combination with a Pimoroni Touch pHAT it allows to preview the total area covered by the camera as well as to focus on a Region Of Interest (ROI) in the center of the image.
Have a look on the video.

Supplies

Raspberry Pi High Quality Camera - GBP 49.50 at Pimoroni UK

Microscope lens for the Raspberry Pi High Quality Camera - 0.12-1.8x - GBP22.50 at Pimoroni UK

Raspberry Pi 4 Model B – 4GB RAM - GBP 54 at Pimoroni UK. Other Pi versions should work as well.

SD card w/ Raspberry Pi OS, power supply, HDMI - micro HDMI cable, monitor, keyboard & mouse

1m Raspberry Pi camera cable

An assortment of old LEGO pieces for the microscope rig

M2.5 screws, nuts and plastic washers

As objects to be analysed:

  • Some old microscopic slides with stained sections of various tissues
  • A fruitfly and an other tiny insect, freshly catched and intoxicated with 70% isopropanol
  • µRuler - Microscopic rulers from a Kickstarter project
  • several light sensor breakouts from Adafruit: TCS34725, TSL2591, VEML7700 and VEML6070
  • a WaveShare eInk (B/W) display I have used in a previous project

Optional: Pimoroni Touch pHAT

Step 1: The Microscope Rig

Using LEGO pieces to build a microcoscope rig for the camera might not be a good long-term solution, but it gives you the opportunity to try several layouts and to optimize the layout for different application cases. LEGO parts have the benefit to be produced with very high precision and are available in many households. In addition the layout can be changed rapidly, e.g. by adding another layer of bricks of either full size of low profile units to tune the distance of camera and object.

I used a medium sized base plate and build a very simple tower to house camera and lens. The images will give you an idea of the layout. In the first layout, the camera was not really fixed, but just dangling on two beams of low-profile LEGO strips that are several millimeter wider as usual. This was significantly improved by fixing the camera on a (6x14 low profile) LEGO plastic plate with four M2.5 screws, washers and nuts. Hereto 3 mm holes were drilled into the (red) plate at a square of roughly 30 x 30 mm. Luckily I was able use cavities at the back of the plate,. As spacers between camera breakout and plate I used (white) cylindrical LEGO parts, which had been a bit shortened at the lower side (2nd image above). To improve stability, 2x2 flat squares (gray) were placed on the top of the plate (4th image).

I also build a holder for microscopic slides and other objects (5th image).

For illumination I just used a LED spotlight at my desktop and is some cases a LED torch as second light source. For some transillumination images I also used a LED backlight module (3rd & 6th image).

More images of the rig are found in the last step.

Step 2: Taking Images

At first, images were taken just using the console as folllows:

  • "raspistill -k -o filename.jpg"
  • focus by turning the lens
  • take image by pressing enter
  • check image, in case modify focus and take image again
  • end with Ctrl-C

or

  • "raspistill -t 0"
  • focus, then stop with Ctrl-C
  • "raspistill - t 10000 -o filename.jpg"


Python scripts

In late December 2020 I developed a Python script, based on the "picamera" module, to improve the process.
For details, please have a look on the next step and the video.

----------------------------------------------------------------------------------------------------------------

Microscopic images on first page:

  • An electronic light receptor: light sensor TSL2591
  • A biological light receptor: fruit fly - eye
  • Some tissue slide - not annotated in my slide collection (suggestions anyone?)

  • Fruit fly - side view

  • Microscopic ruler (0.05 mm - 5 mm), with sugar crystals

Images on this page:

  • Stamina of the peteals of a tiny bluebell, dried between microscope slides
  • A fruitfly, placed on a microscope slide
  • Tissue section: finger tip (skin)
  • Tissue section: an artery, cross section

Step 3: Picamera Scripts for Microscope + Touch Phat

To improve handling and simplify modification of parameters, the microscope was combined with a Pimoroni Touch phat, which has six touch responsive fields and LEDs. Python scripts were developed that allow the preview and taking of images and videos using the Touch phat as control.

The scripts are based on the picamera module and are parameters are optimized for the HQ camera but might be used for other RPi cameras as well. They should also easily adaptable to be used in conjunction with physical or virtual control buttons, e.g. by applying the gpiozero or guizero libraries.

The '...hispeed' script is optimized for videos with a lower resolution but up to 120 fps applying for HQ camera mode 4 (1012 x 760).

The "...image" script is optimized for hires images, applying HQ camera mode 3 (4056 x 3040) which is limited to 10 fps.

While changing camera modes in a running script seems generally to be possible, changing mode 4 => 3 was resulting in problems. So using two scripts for the different use cases seems to make sense. Both scripts start with a preview of the total area, allowing thereby to optimize object placement and focus. Pressing the 'Enter' button activates a preview focussed on the central area, allwing to fine-tune placement and focus. Pressing Buttons A and B takes images of the total area and the ROI (1/8 of total area), buttons C and D allow to take videos with different resolution and speeds ("hispeed") or taking images with different build-in effects applied ("image"). The 'back' button ends the script and stops the camera, releasing resources. So far, the scripts were run in the IDE, You may need to redefine the parameters defining the location of the preview window to fit to your screen.

There is plenty of room for optimization of the scripts, any ideas and tips are welcome. The scripts can be found attached, use on your own risk, modify freely.

The images and videos on this step are displaying of an e-ink display while changing the image. To follow the process in detail, best view the relevant segments in the videos frame by frame. This way the differences between the 120 and 60 fps are more obvious.

Step 4: Image Quality

I used a microscopic scale called i-SEEING I had from a Kickstarter project, It allowed me to estimate image size and quality. The overall quality was quite high, with minimal image distortions like cushion effects or color aberations. Just on the extreme distal areas of the image a limited loss of sharpness and rainbow effects were seen ("0" and "100" on stiched image).

At maximal resolution, the area covered by the camera is about 6 mm high. The sensor and maximal picture size is 4056 x 3040 pixel. So the calculated resolution is about 2 µm per pixel.

Step 5: Light Sensors

I used the microscope to take some images of some breakouts with light sensors. Light sensors have the nice feature that many allow to have a direct view on the electronic parts.

Attached you find images of the RGBW color sensor TCS34725, the lux sensor TSL2591, and the ambient light sensor VEML7700 and UV sensor VEML6075.

The attached images are pairs of shrunk versions of the original images of the breakouts and the respective areas containing the sensors in original resolution. In some cases I used a LED torch to optimize illumination.

Step 6: Two Insects

I catched two very tiny insects, a fruitfly and ... something else, killed them using isopropanol, placed them on a microscope slide and took some images. See attached.

Step 7: Histology Slides

I own a selection of very old histology slides and took images of several of them.

These basically are tissues or pieces of certain tissues, cut into extremely fine slices, placed on a microscope slide and stained with a selection of specific dyes. As different types of cells and tissues will take up the dyes differently, this allows to identify very tiny structures.

The first image is a lymph node, the second esophagus, the third pituitary gland and the forth skin from a finger tip.

Step 8: Other Stuff

Images of an e-ink display and of a print from a business card

Step 9: Some More Pictures of the Microscope Rig

Here are some additional pictures of the microscope, December 2020 version, that may simplify you to build your own version.

Plastic Contest

Participated in the
Plastic Contest