Build Your Own Digital Microscope


I was in need of a digital microscope which
would let me capture videos with a decent quality for a reasonable price, so I build
this thing right here. Thanks to the Raspberry Pi Zero W it directly
outputs an HDMI video signal with next to no latency, but it also lets you save the
files to an USB stick or, in this case, an SD card. It would be easy to configure it to stream
over WiFi or do other cool things. It uses a Raspberry Pi camera module together
with a cheap smartphone macro lens. This also makes it easy to use any other lens
and adapt the microscope to the task you want to use it for. Although I have used some aluminum parts,
most of the microscope can be 3d printed and assembled without any special tools. Considering the price, the video quality is
very good, especially in the center of the image. It gets a little bit blurry on the outside
and the depth of field is also quiet shallow, but this could be improved by using a better
lens. Still it is a great tool to check your electronics
or have a closer look on your 3d prints to spot any problems. It also lets you inspect your tools, not that
this defect was especially hard to see but you get the idea. And overall it’s just really cool to have
a closer look on the things in your shop. I mean, look how cool this felt looks. Even simple foam looks amazing in my opinion. The
assembly is fairly straightforward. You can find all the parts needed on hackaday,
the link is in the description. I used aluminum for the base, but you could
also 3d print it. However you want to make it as heavy as possible,
so maybe add some pieces of steel or similar. A 12mm steel rod gets clamped to the base
with a M4 grub screw. The screw dimensions aren’t critical, so
use what you have at hand. The
main body of the microscope is clamped onto the steel rod with a M4 screw. To be able to move the microscope head up
and down I am using a rack and pinion design. For this you need a 5mm shaft, I went with
aluminum because it is easily machinable. I added a flat spot so the setscrew for the
gear is going to have a better grip, however this isn’t absolutely necessary. The knob could also be 3d printed and then
glued onto the shaft. The gear comes with a hole which needs to
be tapped first. It then gets clamped with a m3 grub screw. And that’s it for the base assembly, next
up is the microscope head. The 6 holes of the main part with the rack
on the back need to be tapped for m3 screws. Then place the spacers on it and mount the
Rasperry Pi Zero W. Next up: the camera module. This one is version 1.3 and comes with a flex
cable which directly mounts into the pi. Now screw in the camera holder and push the
camera into it. This piece can be modified easily to allow
other camera sizes or lens types. I wouldn’t recommend to press the camera
sensor all the way in, as this makes removing it a bit harder. The lens I am using is a 20 times macro lens
and it comes with this white clip. The offers for those come and go so I am not
going to post any links, but I am sure you can find it on the usual websites. As I said, it’s easy to modify the camera
head to mount any other lens, so you don’t have to use this one. Lastly add a button on the two lowest pins
of the Raspberry Pi and push in an SD card preferably with Raspbian OS installed. Insert the microscope head into the base and
the assembly is finished. In order to get a video signal right after
startup, we need to add some code. For that I am assuming that your Pi is running
the newest version of Raspbian and you are already connected to it via ssh. There are tons of tutorials out there how
to do that, so I won’t go into detail here. First we need to activate the camera, so type
in “sudo raspi-config”. Hit enter and then go to the interface options,
camera and hit yes. That’s all we have to do here, so move to
finish and decline the reboot we will do that later. Next we create the script to autostart the
camera, so enter “sudo nano camera.sh” and paste the code I am providing. Press CTRL and O to save and CTRL and X to
exit. Then we add another script which will let
us shutdown the pi safely, so type in “sudo nano shutdown.py” and again, just paste the
code, save it and exit. We have to do this one more time, type in
“sudo nano /etc/rc.local” and paste the code, this is going to run both of our scripts right
after start up. Save and exit and we are finished. Reboot the Pi by entering “sudo reboot” and
after a few seconds, you should be able to see the video feed. Assuming you connected a display of course. Make sure that the shutdown button is doing
what it should do, the green led should turn off some seconds after you’ve pressed it. And that’s it. Thanks for watching and have a great day.

3 thoughts on “Build Your Own Digital Microscope

  1. nice short and crisp tutorial! Fantastic result.
    Mabye it would be nicer for the workspace to mount the raspberry 90 deg rotated? Then the cables would go out to the rear end 🙂

  2. I've seen alot of 3d printable projects, but this is by far one of the coolest. You could add a lens removal hole sized for a 3 or 4 mm hex-Allen key. Can't wait to start printing this one.

Leave a Reply

Your email address will not be published. Required fields are marked *