Flypi - cheap microscope/experimental setup

Pi + Picamera + M12 lens + Arduino microscope/experimental setup for diagnostics and scientific experiments!

Public Chat
Similar projects worth following
Our plan with this project is to develop a complete opensource and cheap device for scientific experiments (data collection and analysis) and diagnostics (if they are "microscopy based").
So far we were able to perform some proof of principle experiments in life sciences (Fluorescence and calcium imaging, opto and thermo genetics essays) and to perform diagnostics of the following parasites: Loa loa, Brugia Malayi, Wuchereria bankrofti, Schistosoma eggs, Mansonella perstans

The setup is quite simple:

A raspberry pi 2 (or 3) (running Raspian) + picamera with mounted lens (M12 standard) + some python3 code (for custom GUI + saving of data) do most of the lifting and an Arduino + custom PCB + electronic bits take care of timing, light stimulation, heating, temperature sensing and any other physical interaction necessary.

For more details, please check:

Necessary files for odering PCBs

Zip Archive - 194.91 kB - 01/21/2018 at 22:11



Here is a torrent file which should make it easier to download the prepared image for the flypi

x-bittorrent - 148.56 kB - 09/28/2017 at 05:30



Scad file containing all parts that need to be 3D printed

x-openscad - 46.73 kB - 10/05/2016 at 22:07



Diagram of PCB layout

x-download - 16.33 kB - 10/04/2016 at 20:55



Bill of materials pdf 04.10.2016

x-download - 48.20 kB - 10/04/2016 at 18:30


View all 12 files

  • 1 × Raspberry Pi 2 or 3
  • 1 × 16 GB mini SD card card is installed with raspian
  • 1 × HDMI to VGA adapter
  • 1 × Monitor
  • 1 × Mouse (USB)

View all 47 components

  • Pre print is out!

    Andre Maia Chagas06/05/2017 at 05:00 0 comments

    After some time in the lab, we finally got around and wrote a manuscript about the FlyPi. It can be found at BioRxiv:

    It includes a throughout description of the experiments we made, and we contextualize the uses we made of this device. Also it contains an updated assembly and user manual. From Raspberry installation to GUI use.

  • AVI conversion, Protocols

    Andre Maia Chagas12/05/2016 at 15:12 0 comments

    Not much to disclose here other than we updated the code and the following things were updated/created:

    "TO AVI" button created --> This allows the user to convert the videos recorded by the PiCamera into AVI format, which is preferred over the default h264 as it can be opened by different analysis software, as ImageJ

    The camera horizontal and vertical offset now default to the middle of the image when a zoom bigger than 1 is used

    The protocol class has been updated. Users can now create their own protocols and have the FlyPi recording data for (hopefully) any amount of time.

  • Overall schematics

    Andre Maia Chagas10/05/2016 at 09:03 0 comments

    To clarify a couple of things, such as the PCB arrangement, how the Pi and the Arduino communicate, where timing is done, below are a couple of schematics.

    Overall schematics: How the Pi, camera, Arduino and PCB are connected to each other and what each part is doing.

    Overall view - How Pi, camera, Arduino and PCB are connected and their roles

    PCB schematic, how components are distributed on the PCB according to location and functional module

    PCB Layout by region/functional unitsPython software schematic: How the different independent classes relate to each other

  • Some UI demos and tests

    Andre Maia Chagas07/11/2016 at 05:55 0 comments

    Here is a small collection of videos demonstrating the new user interface and some of the functionalities implemented for each component:

    And a screenshot of the soon to be finished "Protocol class", which can be used to automatize tasks:

  • FlyPi distribution licenses

    Andre Maia Chagas07/11/2016 at 05:36 0 comments

    Although this project is already open to everyone, we have never explicitly stated which license we are using for it's distribution

    To keep adherent to the open source philosophy, make this tool as useful and widespread as possible and to hopefully contribute to bringing citizen science and academic science closer together, the FlyPi is distributed as (CC BY-SA 4.0) or the creative commons Attribution-ShareAlike 4.0 International license. Meaning that anyone is allowed to use, distribute, remix, and even commercialize this project, as long as proper reference is made to the creators and the new variants are distributed under the same license.

  • PCB design with KiCad

    Andre Maia Chagas07/08/2016 at 07:04 0 comments

    We started the PCB design for this project in Fritzing. Since the project started small and simple, it was a satisfactory solution. As the project grew and became more complex, using Fritzing became too cumbersome. A reported bug had tracks disappearing, which made getting the board correct a freakin' mess. We then decided to migrate to KiCad. If the folks over the CERN use and develop it, how bad could it be?! Turns out it was quite easy to learn it (make sure to install the latest version!) and develop the new board, see the image of the schematics and pcb layout:

  • Overview video

    Andre Maia Chagas06/05/2016 at 19:24 0 comments

    Here is a small video with an overview of the Flypi. Some user interface shots (although this version is a bit outdated), some shots of the device in action

  • HackadayPrize2016 entry log

    Andre Maia Chagas05/31/2016 at 19:11 0 comments

    Scientists need to have the proper tools to perform experiments and test their ideas. These tools are expensive, because they normally use cutting edge technology and are produced in "small" quantities by only a handful of companies. This ends up restricting who and where research is being done, which aggravates the situation in a lot of places where simple research could bring a lot of improvement to society.

    Our project aims are:

    -Development of a cheap (so far a complete set is ~100-150 US$) open source microscopy system capable of

    --- Recording photos (time lapse and single snaps) and videos

    --- Analysis of recorded data (motion tracking, time series of the time lapses)

    --- using cutting edge tools in neuroscience to both stimulate and record activity from neuronal tissue

    --- portable enough so it can be taken to the remote areas/fit in the DIY biolab garage

    --- Diagnostics - imaging of prepared samples of human tissue that might or not be infected with parasites (so far tested with parasites from the digestive system)

    --- Being used as am educational tool. An intro into the basics of microcontrollers, electronic circuits, 3D printing and programming

    --- Last but not least, it is also modular. If one is only interested in microscopy, them only the Rasperry pi, the PiCamera and the main frame will suffice. If special lighting is necessary, them LEDs of all sorts can be added, If positioning is important, up to three cheap 3-axis micromanipulators (manually or servo adjusted) can be attached to the main frame. And since all programming is done in python classes, adding new features should be fairly straight forward

  • Unified power supply

    Andre Maia Chagas05/29/2016 at 15:40 0 comments

    So far the way we were supplying power to our system was only "quick and dirty". The Pi would be powered by a phone charger. All other things would be powered by usb cables cut open and connected to an usb hub. Cables everywhere and very little control over max current and so on...

    After playing around and learning about linear/switching voltage regulators, we came up with a system that seems to do the job just right. It consists of a 12V 5A power brick (the ones used for laptops) and switching voltage regulators that power all parts of our system. The power circuit is integrated into the PCB.

  • Peltier, it finally works...

    Andre Maia Chagas01/12/2016 at 16:23 0 comments

    Finally the Peltier system is up and running. The solution with the L298N works quite well.. Here some images of temperature curves we logged with it... (it still needs some fine tuning, but it works!)

    The images - Room temp to 15 °C. Cycles of 35 to 25 °C and room temp to 35 °C

    Here after some more tuning:

    5 min periods for each temp. 5min for settling into room temp (after 35°C) than switching between 35°C and 15°C (4X) and one period at 19°C and more 5min with peltier off (the bump comes from heat dissipating from the bottom side of the peltier to the top side, where temperature is measured).

View all 14 project logs

  • 1
    Step 1

    Instructions overview:

    This build is pretty simple and consists of few steps:

    • Printing the necessary parts from the scad file
    • Soldering all necessary components to the PCB
    • Setting up the Operating System for the Raspberry Pi
    • Fixating components to the printed parts:
    1. Main body to Raspberry Pi + Peltier + camera
    2. Micromanipulator
    3. LED ring and light diffuser
    4. High Powered LEDs and fluorescence module
    • Setting up Arduino and Python code

  • 2
    Step 2

    Printing the necessary parts from the scad file

    Necessary parts:

    • OpenScad (free open source software, can be downloaded here).
    • The scad file containing the Flypi's 3D model, can be found on the project page, in files.

    Steps (images below):

    1. Use OpenScad and the flags in the script to render the parts necessary (see image below) - If you are only using the microscope module, the only necessary parts are the base, backplate, camera holder.
    2. Convert the rendered parts to .STL (example below using Cura)
    3. load it to your preferred printer. (15-25% percent infill should be more than enough).
    4. (Optional step): Print the base, one long arm and the camera holder. After printed, test if the parts slide properly into one another. If they are too loose or too tight, change the "tolerance" parameter on the SCAD file.
    5. Print away (the complete Flypi can be printed in about 30 hours with a printer running at 40-50 mm/sec and 0.25 layer height).

    OpenScad screenshot, showing bare minimum to be printed

    After being exported as STL, a slicing software is used to prepare parts for printing

  • 3
    Step 3

    Soldering all necessary components to the PCB

    Necessary parts:

    • Custom PCB (gerber files necessary to fabricate them are on the project page)
    • Electronic components for the modules you want to build.

    The PCB was designed to be modular. If the user only wants to use the peltier module and the LED ports, than only the components for those parts need to be soldered in. Also, we opted to stay with "through hole" architecture so people won't get stuck while learning how to solder and populating the PCB at the same time.

    The PCB is annotated (component number and value), so one can read which component goes where (R refers to resistors, C to capacitors, D to diodes, P to screwterminals, U to integrated circuits (ICs), L to inductors and Q to transistors - see image below).

    Steps (if building a complete set - images follow below):

    1. Start by placing and soldering the smallest components. Good place to start are resistors, transistors and capacitors - remember to check their polarity - (check the schematics below to have an idea of where on the board the modules are distributed). If you are building the Peltier module, leave the big resistor that sits in the back of the board as the very last thing to solder
    2. Move on to ICs, power modules and Peltier first, Arduino with female connectors last. On placing the arduino, it is a good idea to sit the board on female connectors first and then connect those to the PCB (see image below), this way there is less chance of overheating the board, it can be taken off for other projects or in case of damage, and makes alignment of the female connectors easier. Remember that the Arduino USB port should be facing away from the barrel connector
    3. Last, solder the screw terminals and barrel connector.

View all 9 instructions

Enjoy this project?



Lucía wrote 09/14/2020 at 10:58 point

Hello, I'm thinking of building this with our science group and I'm wondering if it can be done in one month or under! Also, hope it's approved because this is such a cool tool. Moreover, do you know anywhere we can buy the Rpi cam from Europe?

  Are you sure? yes | no

rexcchao wrote 09/03/2019 at 11:10 point

 Since you showed some sample images that are quite different in magnification, I’m wondering what lens did you use. Is it the one comes with the camera ?

  Are you sure? yes | no

mfitch09 wrote 03/15/2018 at 16:09 point

I am currently trying to figure out a problem with our GUI. The camera, LED1, LED2, protocol, and quit button modules work fine, but the ring, matrix, and autofocus modules do not. When the GUI is running with any or all of those, their sliders do not show up, and the entire GUI freezes (we have to kill it by closing the Python shell). Does anyone know why this might be happening?


  Are you sure? yes | no

Andre Maia Chagas wrote 03/20/2018 at 08:56 point

Hi Margaret,

that is quite odd. The only thing I can think off is maybe a problem with the serial communication when the flag for those modules is set to 1. Maybe try to use the updated code we have on this repo:
Remember that you'll need to update both the arduino and the GUI codes!
Let me know how it goes!

  Are you sure? yes | no

Phi Joe wrote 09/01/2017 at 09:11 point

I'm trying to assemble the components and build one. I'm confused by the power resister. The BOM shows 2 an 11W for the fluorescence module and a 17W for the Peltier module. The PCB board however only seems to have one power resister. I'm guessing its the 17W for the Peltier. Where does the other power resister go?

  Are you sure? yes | no

Andre Maia Chagas wrote 09/07/2017 at 15:39 point

Hi Phi Joe,
unfortunately the BOM here is likely outdated (sorry about that! will try to fix it in the coming days). You can get an up to date version at our github repo:

Let me know if I can help with something else!

Also if you don't mind me asking, what will be using it for?

  Are you sure? yes | no

ntbsharp wrote 06/03/2017 at 20:23 point

So I currently and trying to do this project for a science research class and wish to use the thermal option, however I cannot order a PCB because I cannot find a program to view the .grb and .drl file types.  I am assuming they are export files for the PCB drill to read.  Therefore, I have a couple of question for you, Andre, as follows.  Can you send me the specs for ordering, or can to tell me how I can order one/how you did, or do you make your own in which would I be able to buy it from you? 

Thank you so much and I look forward to hearing back from you.


  Are you sure? yes | no

Andre Maia Chagas wrote 06/05/2017 at 04:57 point

Hi Noah,

as far as I know, the files you need, with drilling specs and so on are the Gerber files. You can find all of them, together with an updated version of assembly manual/PCB/GUI on github:

For the PCBs, we ordered them from one of them many Chinese distributors out there. In our case, Depending on your location, there are local producers that could deliver an "easier" experience.

I hope this helps! Let me know if you have any other questions!

  Are you sure? yes | no

robhobson wrote 01/26/2017 at 20:14 point

This is a great project, we built one of these in the lab to track some aquatic invertebrates and they are working great. One issue we are having is with the availability of the camera from waveshare. We have a great deal of difficulty buying the camera through our university. Do you know of any alternatives? Otherwise we will probably just try and but the camera components and lenses ourselves.

  Are you sure? yes | no

Andre Maia Chagas wrote 04/11/2017 at 19:51 point

we somehow missed your message. One of the things we've been doing is to just buy the regular PiCamera, print an adaptor for coupling an M12 lens to the picamera ( (after removing the original lens) and using a m12 lens we need for the problem at hand. Hope this helps!

  Are you sure? yes | no

rwilsongr8 wrote 07/28/2016 at 01:46 point

this is awesome. I help run an electronics club at my school and this looks like an very interesting project. I hope you get it finished, good luck 

  Are you sure? yes | no

Andre Maia Chagas wrote 08/02/2016 at 22:06 point

Thanks! We are finishing some last things, but it is completely usable already! Send us a message later if you want more info or some help setting some up!

  Are you sure? yes | no

zakqwy wrote 04/01/2015 at 15:25 point

This is great! Make sure to check out the Backyard Brains guys--their Spiker Box (which uses cockroaches) is somewhat related to your project.

  Are you sure? yes | no

Andre Maia Chagas wrote 04/13/2015 at 20:16 point

Thanks for the tip! We know the work of those guys!
You also have some cool projects!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates