BR-0016-01-2.jpg?width=251In case you're looking for an optical flow sensor, there is now one available in the DIYDrones store for a penny under $40.


This sensor is based on the ADNS3080 mouse sensor which is a good choice for optical flow because:
   high resolution: 30 x 30 pixel frames meaning it can see features that lesser mice cannot
   high speed: 2000 to 6400 frames per second update rate which contributes to better low light performance than other mouse sensors
   SPI interface meaning it can be interfaced to many micro controllers and co-exist with other sensors


Other features:

  • Intended to interface with a 5v microcontroller.
  • 8mm lens with 11 deg FOV
  • Standard M12x0.5 lens mount meaning you can replace the lense easily  if required


Instructions for connecting the sensor to your APM/Oilpan are here.


Things to be careful of:

  • Performs best outdoors in well lit environments
  • Does not play well with Fluorescent lights (the blinking throws off the sensor)
  • Needs a somewhat varied surface to see movement (plain carpets are not it's friend)


Uses including odometry and obstacle avoidance but I've used it mostly for horizontal position hold.


Note: integration with ACM and the existing GPS pos hold is a work-in-progress but should hopefully be completed in a few weeks.  Here is a video of a slightly modified version of the ACM code using only optical flow (and sonar for altitude hold).


Inspiration and some technical help especially early on came from Marko Klein Berkenbusch and his blog on position hold with mouse sensor.


Hope you like it, all comments welcome!

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Sorry, the following item is currently out of stock: Optical Flow Sensor?????

  • Hello! I always get the same error:

    Failed to initialise ADNS3080

    I use the apm 2.5. What is wrong? I did the wirering like on the wiki page.

    Please helpe me!

  • I have been trying to get the optical flow sensor to work with my APM 2.5 board and getting some strange flakey results. The sensor will capture images and output them to the Arduino Serial Monitor or Python image grabber for 2 - 5 frames and then cut off midway through outputting a frame. Here's what it looks like on the serial monitor:

    image data --------------
    image data --------------

    If I reboot the board, I can repeat this over an over. I have followed the instructions closely and I don't think I left off any steps (like modifying the code and board jumper). Anyone having the same problem? Any ideas on how to fix it? The sensor never worked terribly well for position hold on the APM 1.0 board either, but it was not showing the same problem.

  • Hi,

    I am getting some mixed results with OF_loiter.  It has been really overcast when I have flown, but the surface quality has been well above 20 (60 - 100 range).  Today I had a couple of rock solid OF_loiters, but most of the time, my arducopter would drift in one direction.  I normally get some drift in stabilize mode.  This was over grass and at about 20' ft altitude.  My best loiter of the day was at about 3 ft altitude over a rough patch of grass with a bunch of dirt spots and divets.  I was able to properly focus my camera, but I focused it on something only a couple of feet away from the sensor.  I am confused as to whether the cause of the problem: the regular grass is not textured enough, there isn't enough light, I need to focus the sensor on something further away, need to tune OF PIDs, or if this is caused by something else.  Any help would be greatly appreciated!

  • Developer


         The optical flow sensor really only helps with horizontal position hold so it won't help with altitude hold.  For that the baro or sonar is better.  catch you later.

  • Randy,

    The idea of the "complementary filters" implementation and how it would be used sounds very nice.

    I will give do some PID tuning in the weekend.

    Something that crossed my mind yesterday was:
    Can the OPTFLOW be used to land the quad or does one require a sonar?


  • Developer

    Ah, much, much better!  That's what it should look like.

    Yes the OF_LOITER pids will need some tuning.  It's a fairly simple control method..just a single PID controller for roll and another for pitch.  In the regular Loiter we use a pair of controllers (distance + speed) for each axis.

    Recently I've discovered the wonders of "complementary filters" so this may be the way that we can combine the optical flow speed with the gps position to make regular loiter better.  That's not a super simple task but that's really where we need to get to.  So you attach your optical flow and it just uses it when it can to make your loiter performance special OF_LOITER mode required.

  • Randy,

    Got the sketch uploaded and lens focused. It's a bit fiddly but it works (just made sure I saved all my parameters before loading the sketch).

    Here are the results:

    Before (good surface qual value when using the CLI, however bad focus)

    3692521999?profile=originaland after (loading the test sketch and focus the lens)

    3692522894?profile=originalThis looks far better.
    Loiter was not bad but then again it was quite windy today.
    May need some playing around with the OF_LOITER PIDs.
    As a recap, turning the lens until you get a good surface qual. value through the CLI is not enough.
    One must load the test sketch and focus the lens (I used a lipo bag and turned the lens until I could read the print on the bag).
    As you also mention, add some tape to secure the position of the lens.

    Hope this blog helps some other OF enthusiasts.

    Randy, thanks again for your feedback.

  • Developer


        Ok 6:30pm is probably too late in the day.  The mouse sensor it's built with does require a lot of light...that's it's main weakness actually.

  • Randy,

    I will go through the python sketch this evening.

    Do you have a recommendation to what distance I need to focus?

    I already taped the lense as it seemed to have the tendency to move a little.
    I was flying around 6:30pm and the light conditions were still ok.

    Indeed there were some good samples but now I need to get some consistency in it.

    Thanks again for the support.

This reply was deleted.