Raspberry Pi HQ Camera Microscope - a Minimalist LEGO Version

4,122

29

6

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

Be the First to Share

    Recommendations

    • Paint Challenge

      Paint Challenge
    • Reclaimed Materials Contest

      Reclaimed Materials Contest
    • Tiny Things Speed Challenge

      Tiny Things Speed Challenge

    6 Comments

    0
    lefsky
    lefsky

    Question 9 months ago

    Do you have any idea of the actual resolution you can achieve with this product? I'd like to use something similar to image aerial photo slides using a field of view of about 250 mm and achieve between 10 and 20 um _actual_ spatial resolution. The nominal resolution of the RPI HQ would be about 6.25 um but it is unlikely that I'd be able to identify objects of that resolution because of Rayleigh limitation, etc. Have you imaged anything where you can see features at that small size and if so, what field of view were you able to image at the same time?

    0
    Dr H
    Dr H

    Answer 9 months ago

    Good question.
    I guess if you get as close as possible to the object, a pixel represents about 2 µm or a bit less, but the image will not be in focus outside of the central area.
    So 6 µ will about 3 pixel. I have been playing today with the only normalized and colored 6 µm objects at hand: my very own red blood cells, and placed small amounts of diluted blood (about 1:20 in 1% NaCl) on different white surfaces. It's very hard to say if these really were erythrocytes, but there were several reddish blobs of the expected size to be seen.
    In another previous experiment I used stained amorphous glass beads with a diameter of about 70-120 µm with an inner structure, and they show areas with clearly different staining about 10 - 20 µ large. But again, good in the center of image, not in focus outside.
    I guess contrast would be another issue. and detecting a 20 µ dark object on a white background should work, dark gray on light gray presumably not (at least without optimizing contrast or color curves).
    I may post some of the pictures the coming days, so you can have an impression yourself.

    Best regards,
    Holger

    0
    MTKapp27
    MTKapp27

    Tip 11 months ago

    Very Cool Project!
    I am have the iMicro Q by the way and it can't wait for the new version.
    Have you heard about open Flexure microscope? It consists of 3D printed parts (rather than Legos), cheap optics, raspberry pi, & pi camera. The software can do amazing things too.

    0
    MakersAtMicrosoft
    MakersAtMicrosoft

    11 months ago

    Creative way to use LEGO blocks! Great photos + writeup, too! Two thumbs up.