Raspberry Pi HQ Camera Microscope - a Minimalist LEGO Version

by Dr H in Circuits > Raspberry Pi

7221 Views, 31 Favorites, 0 Comments

Raspberry Pi HQ Camera Microscope - a Minimalist LEGO Version

Raspberry Pi HQ camera microscope
IMG_20201122_154038.jpg
IMG_20201214_112741.jpg
TSL2591_1_cut - Kopie.jpg
fruitfly_8_cut.jpg
test10 cut.jpg
zucker_1.jpg
e-ink_cut2.jpg
fruitfly_5.jpg

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

The Microscope Rig

IMG_20201122_155058.jpg
IMG_20201214_112625.jpg
IMG_20201214_113046.jpg
IMG_20201214_112647.jpg
IMG_20201122_154121.jpg
IMG_20201214_112824.jpg
IMG_20201214_112349.jpg
IMG_20201122_154729.jpg
IMG_20201122_154204.jpg
Träger für Kamera.jpg

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.

Taking Images

blüte_1.jpg
fruitfly_3.jpg
slide_105_fingertip.jpg
slide_33_cut_artherial_vessel.jpg

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

Picamera Scripts for Microscope + Touch Phat

2021-01-02 22:15 - overview.jpg
2021-01-02 22:15 - ROI-none.png
2021-01-02 22:16_hispeed
2021-01-02 22:16_largevid

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.

Image Quality

IMG_20201122_154904.jpg
Color_error..jpg
scale_1._skaliert-706.jpg
scale_2.jpg
scale_5.jpg

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.

Light Sensors

TCS34725_1_cut - Kopie.jpg
TCS34725_1_skal811 - Kopie.jpg
TSL2591_1_cut - Kopie.jpg
TSL2591_1_scal811 - Kopie.jpg
veml7700_2_cut - Kopie.jpg
veml7700_skal811.jpg
VEML6875_1_cut.jpg
VEML6875_1_skal811 - Kopie.jpg
IMG_20201122_150138.jpg

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.

Two Insects

insect_2d_head.jpg
insect_2b.jpg
fruitfly_8_cut_1.jpg
fruitfly_3.jpg
fruitfly_6.jpg

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.

Histology Slides

slide_37_1.jpg
slide_56.jpg
slide_90.jpg
slide_105_ii.jpg

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.

Other Stuff

e-ink_cut2.jpg
e-ink_cut.jpg
e-ink_1.jpg
Print_1.jpg

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

Some More Pictures of the Microscope Rig

IMG_20201231_151928.jpg
IMG_20201231_165434.jpg
IMG_20201231_152046.jpg
IMG_20201231_152058.jpg
IMG_20201231_152033.jpg
IMG_20201231_165248.jpg

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