A microscope on display

The OpenFlexure Microscope is an open-source 3D-printed microscope, including a precise mechanical stage to move the sample and focus the optics. There are many different options for the optics, ranging from a webcam lens to a 100x, oil immersion objective.

The trick of making a microscope out of a webcam has been around for a little while, and produces good results. However, getting a nice mechanical stage to focus the microscope and move around on the sample is tricky. This project is a 3D printable design that enables very fine (sub-micron) mechanical positioning of the sample and the lens, with surprisingly good mechanical stability. It’s discussed in various media articles and a paper in Review of Scientific Instruments (open access).

Assembling Hardware

To build the microscope, go to version 5.20 release and download the STL files and instructions. Don’t just print everything from the STL folder, as there are a number of different configurations possible. The assembly instructions contain instructions on what parts to print and how to build it.

For more details, and full source files, see openflexure-microscope on GitLab.

Installing the software

On your Raspberry Pi (microscope server)

You can download the latest pre-built SD card image with the OpenFlexure software installed here.

Alternatively, you can install all of the required software onto a fresh Raspbian installation using our quick-installer. It’s best to start with an SD card that has been flashed with the latest version of Raspbian. If your Raspbian installation is too old, installation may fail.

From your Raspberry Pi, run curl -LSs get.openflexure.org/microscope |sudo bash and follow the on-screen instructions.

Developer documentation

Developer documentation for the microscope server can be found on Read the Docs. This includes documentation and tutorials on developing plugins for the microscope software.

On a client device (remote control)

We reccommend using the OpenFlexure eV client software for controlling the microscope, both on the Raspberry Pi, and on remote devices. OpenFlexure eV is available for Windows, Linux, and as a web app. Installers can be downloaded from our downloads page.

Full source code is available at openflexure-ev on GitLab.

Using your microscope

Controlling the microscope locally

A microscope on display

Since the microscope uses a Raspberry Pi to control the hardware, by connecting a display, mouse, and keyboard, you can use OpenFlexure eV on the microscope directly. You can launch OpenFlexure eV from your application menu, under ‘Other’.

From here, ensure that the ‘Connect locally’ option is checked, then click ‘Connect’. After a few seconds, you should see a live preview of the microscope camera, and full software control over the device.

Controlling the microscope remotely

Through an existing network

OpenFlexure eV works by sending commands to the microscope over a network connection. This means that if the Raspberry Pi is connected to the same (wired or wireless) network as your laptop, for example, you can remotely control the microscope from that device. In OpenFlexure eV, on your remote device, select ‘Connect remotely’, enter the IP address of the Raspberry Pi in your microscope, and click ‘Connect’.

Direct via ethernet

On most modern computers, you can simply connect the Raspberry Pi directly to the device via an ethernet cable for simple, high-speed control. For many applications using a single microscope, this is a preferred setup. Generally, you don’t even need to know the IP address of the Raspberry Pi in this case. In OpenFlexure eV, on your remote device, select ‘Connect remotely’, enter raspberrypi.local as your hostname, and click ‘Connect’.

Direct via WiFi

Finally, the Raspberry Pi can broadcast it’s own wireless hotspot. By connecting another device to that hotspot, OpenFlexure eV can again be used for remote control. Generally, this is much slower than using an existing network, or a direct connection. However, it allows the microscope to be accessed wirelessly when no other network is available. Again, in OpenFlexure eV, on your remote device, select ‘Connect remotely’, enter raspberrypi.local as your hostname, and click ‘Connect’.

Managing the microscope server

Our installer now includes various commands to simplify common tasks when using the OpenFlexure Microscope. From the terminal on your Raspberry Pi, you should have available the following commands:

ofm start - Start the server background service

ofm stop - Stop the server background service

ofm restart - Restart the server background service

ofm status - Show the status of the server background service

ofm upgrade - Pull and install the latest version of the server. -d option to upgrade to development branch, and include dev dependencies.

ofm update - Pull and install the latest version of the ofm command-line interface itself.

ofm log - Show the most recent chunk of server log

ofm activate - Activate the OFM virtual environment

ofm serve - Start the OFM server with Gunicorn. This will not work is the server is already running as a service.