Installing Ubiquiti mFi Controller 2 on Raspberry Pi

Installing Ubiquiti mFi Controller 2 on Raspberry Pi
Please share with your friends...

The Ubiquiti Networks mFi Controller enables energy monitoring, automation, in-depth analytics, machine-to-machine communications, powerful scheduling and more of mPort, mPower, mSensor and other third party devices.

This article describes how to install the mFi Controller software version 2 on Raspberry Pi.

Ubiquiti confirmed in April 2016 that no further software updates would be made available for the mFi Controller and that the product has essentially reached end-of-life.
The mFi Controller software requires Oracle Java 7, and is not compatible with any version of Java 8 (or later). The mFi Controller and UniFi Controller software can co-exist on the same Raspberry Pi.
The instructions in this post have been tested with Raspbain Stretch (August 2017) and mFi 2.1.11


The Shortlink to this post is

If you found this post helpful or useful in some way, please help me by doing the following:

  • Like or link to this post from your favourite social media platforms;
  • Click our advertisers banners;
  • Make a Paypal Donation;
  • Leave a Reply below.
Thank you!


⇓ LastPageNext ⇒

Raspberry Pi is a trademark of the Raspberry Pi Foundation.

Disclaimer: No liability is accepted (whether under the law of contract, the law of torts or otherwise) in relation to the contents of, or use of, or otherwise in connection with, this website to the extent that the website is provided free-of-charge, for any direct loss; for any indirect, special or consequential loss; or for any business losses, loss of revenue, income, profits or anticipated savings, loss of contracts or business relationships, loss of reputation or goodwill, or loss or corruption of information or data. These limitations of liability apply even when expressly advised of the potential loss.

Please share with your friends...


  1. Hi
    thank you present a guide to us

    I’m making MFI on a Raspberry pi 1b and are aware of the limitation on the 2 Gb

    but how long will it be able to run with 4 Mpowe Mini

    and you plan and create a guide to UCRM from Ubnt on a raspberry or banna pi

    2000 thanks from Flemming from Denmark

  2. Thanks a lot! Still working on “Linux raspberrypi 4.4.26-v7+ #915 SMP Thu Oct 20 17:08:44 BST 2016 armv7l GNU/Linux”
    Tried a few other guides which I was unable to follow or complete, but your guide is understandable, friendly and comprehensive.

  3. Hi,
    I would like to set up RPi3 with mFi and UniFi controller.
    But as I understand there is problems with Mongo DB 2GB and no work around at this moment.
    Did I understood correct?

    1. Hi Donisg,

      You are correct, there are issues whereby mFi can fill the MongoDB database – which because it is the 32-bit version – is limited to 2GB. I’m not sure if it is possible to reduce the amount of data mFi records in the database so it doesn’t get so big. However, UniFi works fine on RPi platform.

      Kind Regards,

  4. Today I installed the mFi controller on an old MacMini that stays onsite and transferred the database from my laptop. Reboot, worked like a charm… I think the RPi3 is going to be another Media Player 😀

    1. Good call. You might want to consider ESXI on that Mac Mini if it has enough RAM. Then you can use it for other purposes (like music / media library and/or dns/dhcp server, etc) while keeping the various machines insulated from each other. I’ve got a half-dozen machines on an Intel NUC and that’s proven to be a very solid platform.

  5. After setting up the mFi controller on the RPi3, I was happy to see the interface… but then: no default map, mPort are listed but Inactive… and no data collected 🙁

    1. I’m no longer running on RPi, but one of the tools that helped me understand what was going on when I was running it there was TOP. This helped me see when the CPU was pegged with mongo chewing up time before things worked (so I could be more patient while realizing it was actually /working/ but not available on the UI yet) and also helped me see that there was an extra (un-necessary) mongo instance by default that I was able to remove and saw an improvement in performance.

      I ultimately abandoned the RPI implementation because of mongo’s desire to build HUGE storage – that I would be happy to let it do if it would work – and I was able to move mFi and Unifi to one VM with plenty of storage that runs much faster.

      I’m sure you know that Ubiquiti has abandoned this mFi software (and the hardware) and is supposedly working on something new. So – with that said – it might make just as much sense to get it going on RPI since it works well enough once it’s running. I wouldn’t be surprised if they abandon mongo next time around.

      Back to your description: if your mFi units are listed as inactive, that’s certainly the problem. One way or the other, they need to be adopted to be managed by that instance of MFI.

  6. Hi Guys,
    I have some mFi nodes and RPi3. I followed the UniFi guide and then the mFi guide. I first thought it wasn’t working (3mn for the UniFi to show up, but broken link on port 6443). But after several reboot, I let it rest for a while (went to work on my BBQ instead :D), and magic happened ! It works on port 8443, and I got UniFi & mFi running on a RPi3… until the database is full :/

  7. Hello,

    Thanks a stack for your Unifi Controller Install guide. I followed many others’ advice and it all failed over a non stop period since past Sunday. I installed it on the Pi3

    I bought. Second Pi 3 to run mFi on. I used your guide for mFi installation and it all works. I log on and the first thing it asks for is Flash Player. As I am very new to this architechture, I have no clue as to how to proceed.

    I have been running mFi on a high spec Apple MacMini, running Win 7 but it interfered with my movie watching. I have a huge digital movie collection on the Apple and since I installed the mFi controller on the Apple, I get sound distortions for some reason. I removed mFi and all is well.

    I clearly dit not do my homework well enough to have known about some of the issue ie 2 gig limit, but I understood the Pi3 has a V8 ARM processor and unfortunately took it for granted that all will be Ok.

    Is the OS, Raspbian Jessie a 32bit Os?

    I am hoping to hear from anyone who Actually run mFi on a Raspberry Pi

    1. Hi Len,

      I actually don’t have any mFi components myself (hint, hint if anyone from UniFi reads this comment!), so I can’t provide too much assistance other than the install. Not sure about the need for Flash Player, I’ll look into it.

      As you guessed, Raspbian is a 32-bit operating system. Unfortunately there is no 64-bit Raspbian release for the RPi3 as yet, so MongoDB is still limited to 2GB.

      Glad you found the UniFi guide useful though 🙂

      Kind Regards,

  8. Why does it say that adobe flash is needed when you try to view the map? Yours seems to show the map.

  9. Gregory> Homeseer can work with mFi HW? I don’t see it as a supported HW. So via SSH? I already pushing data from mFi to our Zabbix (monitoring). It’s a working sollution, but Zabbix is a monitoring tool, so it’s not exactly smooth for automation workflow…

    1. There’s a plugin currently working for control. It creates devices for each port on an mFi and accurately reflects their on/off state (and controls them). But it doesn’t pull the amps/watts from anything. The author recently said he’s picking up development again… so we’ll see.

      I’m currently using that plugin to control and reflect state of AV gear that I power on/off at the outlet in the touch-screen apps on my phones, tablets, and PCs. A switch / button for Main AV amp, Pre-pro, surround amp, zone amp. Also espresso / grinder power. These buttons look (and act) identical to the button that sends on/off for the projector, for example (not outlet controlled as that would be bad for it). And same button features as light switches and stuff like that. This also adds automatic “duration in state” (on or off) counters that make for helpful triggers.

      Espresso machine is on for more than an hour and there’s no-one in the house (tracked by cell-phones) or no motion in the house (tracked by security system), turn it off. Up to 1500 watts peak and ~500 watts per hour right there.

      The ideal solution would be to have a plugin that feeds into Homeseer’s power monitoring features. But I doubt that will happen.

      Barring that, just populating a “device” with current power draw and/or 24-hour draw (stuff like that) would allow lots of easy triggers of everything else in the HA stuff. Basically, allowing a replication of all the triggering features in mFi but with much, much broader output options – and without having to build double-work as I do now. Right now, I can create an email trigger in mFi and have HomeSeer act on it.

    2. Gregory> hmmm, sound pretty cool 🙂 Watts/Power is nice to know, but I can live without that info. Anyway, can it read temperature sensor? This is crucial to me, coz I need to remotely turn heating on/off with automatic temperature regulation.

      Btw, which HW controller by Homeseer are you using?

      I have the same idea, with alarm, so for example when there is no home (cannot be solved by phone presence, we have 3 kids :), so when alarm is set on, I’ll switch my heating to Away mode. But it’s about integrating Jablotron alarm (e-mail notifications only) with Net Atmo, so it will be probably something between IFTTT and Zappier, or maybe I’ll write my own controller.

      And yes, the cool thing is that my home talks with me via Slack 🙂

    3. Temp sensor is the same issue as power draw: it’s available by telnet, but not currently part of the plugin. In theory, there are a couple of plugins that use a scrape / regex to populate devices with information. I’ve used one for scraping web stuff, but haven’t put the time in to do it with telnet. Others do it, so I guess it’s do-able.

      But the cheapest / easiest temp stuff would be to use 1-wire. The sensors are crazy cheap and there are already plugins to manage that stuff easily.

      I have run a few different setups for HA over the years; but HS is one of the better ones right now (still). If you’re looking to home-cook something, I played with both OpenHAB and OpenRemote – ran OpenRemote for a few months. If you’re looking to pay for something that’s already pretty solid, HS3 is really hard to beat. I run it in a VM on a NUC. Haven’t had a single failure in the few months that I’ve been on it.

      Same box is also running the Ubiquiti stuff as well as OpenVPN and testing various security camera software. All rock solid.

      On the kids presence thing, I haven’t played with it yet, but there’s folks using Bluetooth devices for prox. Basically, any BT device (whatever battery-based thing you put in their backpack) sync up with a BT stick and the presence is logged. In theory, improves on the IP-addressed / WiFi phone part and allows other devices like newer cars that have BT functions.

  10. hi i think i am going to give on the rpi and moving on to ecs liva, since i have them here, where to get java 7? on their web i can get only 8. thanks.

    home seer looks interesting too. i can’t find price for software only. can you point out where should i get?



      Plenty of stuff out there on installing multiple versions of Java and setting which one is default. I don’t have any one guide I follow. I just re-Goggle it whenever I’ve needed to do it.

      I’ve got Ubiquiti Unifi, mFi, and Video controllers running on a VM and working well. Killed the video – didn’t like the hardware; but the other two run fantastic in a pretty lean VM.

  11. @Maxim, 100% agreed. Why they chose that DB and why they store THAT much data is just poor app management. But the hardware is awesome. I’ve played with a lot of HA stuff over the years and this hardware is some of the best – better than many of the enterprise products we’ve used over the years.

    I think they have done a decent job with the software features – not great, but a good start. The graphs and the triggers and such are pretty cool. The ability to put in the costs and use those as triggers… all good stuff. But the database choice? Stupid and wasteful. And the volume of information? Poor programming: best case, roll it up and stuff it into a summary DB in SQL. Make the fast-and-sloppy (aka “good”) parts of Mongo only used for their advantages and move to roll-ups for everything past a week or whatever.

    The good news is that the devices all work great without the controller. And automating them – with telnet functions – works very well. I’ve got Android controllers and integration with HomeSeer and that stuff just works. Pretty nice. FTR you can even collect the data yourself and push it into something else if that’s preferable. I’m hoping the dude that wrote the HS plugin will add monitoring (beyond on/off status); but if not, I suspect I can figure it out with scraping a telnet.

    @Manit, I came to the conclusion that it would be better to “move on” and it looked like the easiest / cheapest solution was a ComputeStick – either by Intel or the OEM that makes it for them (both available on Amazon and elsewhere) or something similar. But the Windows version of it has more resources, so better to go there and load Linux over the Windows install. The CPU is 64-bit – the Windows version pre-loaded is 32-bit but the pre-loaded Ubuntu is 64-bit (on the lesser hardware). Add a 32G or larger MicroSD, load your favorite Linux alternative (probably best to keep it lean) and you’re good to go.

    I decided to move all my non-audio stuff out of the stack of Raspberry Pis I use and go with VMware on a NUC. Ultimately, much faster and much more flexible – but much more expensive once I kitted it up with an i7, 2TB spinner plus a 500G SSD and 16G of RAM. On the plus, stuff runs even better than on RPi.

  12. hi Maxim Krušina and Gregory thanks for your reply,now i am clear that it must be the corrupted db.
    is there any low power pc and cost that we could use for mfi controller?

  13. Gregory> I Like the Unifi anf mFi hardware, but imho the controller SW for mFi is of very low qualiy and suffers from serious design faults. From the principle, systems intended for remote controlling of something must be designed as really stable and reliable at the first plase, coz they are very often on remote location and it’s really frustrating to drive hunderts of kms just to restart of fix something 🙂

    I have long history of problems with mFi controllers. First, it generates enormous and unnecessary amout of data. Few years ago, I was suprised that mFi crashed about every week or two. After lot of research, I fould it was because it filled MongoDB with 2GB data, which is maximum filesize (on 32 bit) and then the whole DB crashed – only one thing was to delete complete installation and start from scratch. Also, in MongoDB’s documentation i found silly note, that they are simply not checking DB/filesize limits on 32-bit systems, so when you fill enough data (exatly more than 2 GB), it just crash and corrupt whole datbase – silly approach to DB stability.

    Also I found, that mFi stores enormous and absolutely useless about of data. Please note, that I reached that 2 GB limit within a couple of weeks with just two thermal sensors and two 3-port wallets, which is really insane. mFi stores data in some crazy time incremens, which can be nice, if you are controlling nuclear powerplant or Large Hadron Collider, but in case you are measuring temperature in room, you really dont need anything more than one float value per five minutes. There was no way to set how often each sensor should collect data. I know, it can be solved by moving to 64bit platform, but it’s really silly way to control fan on/off status or turning remotely heating on via 64bit machine 🙂 So, now, mFi is just toy for me (I’m still enjoying it), but for remote controlling of heater I’m using for example Netatmo Thermostat – it JUST works, it has API and you dont need 64bit superserver 🙂

    BTW: Tha data insanity is clearly visible when you compare it for example with monitoring system – we are using Zabbix, collecting data from thousands of sensor and the whole system can run on really small machine 🙂

    Maxim Krušina

  14. manit, the total data fed to the Mongo files from the Unifi controller is a tiny fraction of the data fed in the mFi controller. I ran the Unifi controller successfully for a long time and suspect it would continue to run fine. The mFi is much more touchy. Since it is /always/ writing data, any errors create corruption. IOW, a forced reboot could be enough to corrupt it and mFi won’t run.

    I think this is what I used (a couple times) to repair it:

    sudo mongod –dbpath /usr/lib/mfi/data/db –repair

    Ultimately, I moved it to a 64-bit system (with a ton of storage space) and it’s been rock-solid since. I moved to an Intel NUC with VMware and running the controllers in a (rather small) VM. But it’s 64-bit and much faster and more reliable.

  15. Maxim Krušina> hi i have made unifi controller to on the same rpi. unifi controller runs fine even the mfi is dead.

  16. hi chris,

    after using for a week. when i restart the pi. i can not get into the controller.
    anything i should check in particular?


    1. manit> I have mFi on two RPis and on one of them it stopped working. Maybe it’s related tot tha same problem. Btw, on one, where it is still running OK, I don’t remember if I restarted RPi after installation or not 🙂 Second clue: on the working one, there is also installed UniFi controller (UniFi was installed first the mFi).


    2. On the failed MFI controller in RPi, it’s likely corrupted. I’d send links, but I’m on mobile. The 32-bit implementation on Pi is susceptible to corruption. Journaling can be turned on (it’s off by default in Mongo 32-bit) but it won’t solve it completely. I’ll try to get back with links later… But I think you’ll find this on a search for RPI MFI controller stopped.

  17. Hi Chris, thank you for updating your article – it’s awsome! Already running both UniFi and mFi controllers smoothly 🙂

    I only hope that UBNT fixed some troubles with DB, but a long time ago, it was terrible DB/disk space eater!

  18. Hi Chris, thank you very much for great manuals, that (contrary to Ubiquiti’s) works! So now I have my RPi 2 working with Unifi controler smoothly. And now the question: how to smoothly run (if possible) also MFi controler? Coz Unifi Controler is using Java 7, in this artcile we’re talking about Java 6 and 8, so I’m a bit confused, how to install both controlers on the same RPi. Also I’m not sure, if mFi is using different ports or if I shoudl tune something in config. Thanx a lot, great work!!!

    1. Hi Maxim,

      Thanks for your comments! I hadn’t updated the mFi guide for a while, so I’ve just updated it this morning to make things much clearer. Ubiquiti have now standardised on Java 7 for UniFi and mFi since I wrote this guide – so stick with Java 7 and you will be able to install both UniFi and mFi on the same Raspberry Pi. Also UniFi and mFi use different ports, so there is no problem there either.

      Hope that helps!

  19. I am suffering exactly the same issue as Gaiex. Twice clean installed machine and twice this precise issue has happened. Not sure how to clear it. Can you help any?

    1. There have been significant changes in the reliability of various MicroSD cards. sudo rpi-update updates the firmware which has the SD-card fixes. That cured these types of issues for me. Be sure to do further updates after (sudo apt-get update / sudo apt-get upgrade).

  20. rebooted and tried to start the java service with Gregory comand and got this:

    A fatal error has been detected by the Java Runtime Environment:
    Internal Error (os_linux_zero.cpp:285), pid=2665, tid=1308619872
    # fatal error: caught unhandled signal 11
    # JRE version: 6.0_35-b35
    # Java VM: OpenJDK Zero VM (23.25-b01 mixed mode linux-arm )
    # Derivative: IcedTea6 1.13.7
    # Distribution: Debian GNU/Linux 7.8 (wheezy), package 6b35-1.13.7-1~deb7u1+rpi1
    # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again

  21. Used also “ls /etc/rc2.d/S*” to see if the service is starting and “S01mfi” service is starting at boot.

    Also with “ps wwwaux” got bellow:

    root 2148 0.0 0.0 2028 100 ? Ss Aug15 0:00 mfi -home /usr/lib/jvm/java-6-openjdk-armhf -cp /usr/share/java/commons-daemon.jar:/opt/mFi/lib/ace.jar -pidfile /var/run/mfi/ -procname mfi -outfile SYSLOG -errfile SYSLOG -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xmx1024M com.ubnt.ace.Launcher start

    root 2151 0.0 0.0 2028 100 ? S Aug15 0:00 mfi -home /usr/lib/jvm/java-6-openjdk-armhf -cp /usr/share/java/commons-daemon.jar:/opt/mFi/lib/ace.jar -pidfile /var/run/mfi/ -procname mfi -outfile SYSLOG -errfile SYSLOG -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xmx1024M com.ubnt.ace.Launcher start

    root 2152 0.0 2.4 1200456 24648 ? Sl Aug15 5:49 mfi -home /usr/lib/jvm/java-6-openjdk-armhf -cp /usr/share/java/commons-daemon.jar:/opt/mFi/lib/ace.jar -pidfile /var/run/mfi/ -procname mfi -outfile SYSLOG -errfile SYSLOG -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xmx1024M com.ubnt.ace.Launcher start

  22. Thanks for your reply, Chris. I’m not sure why it didn’t start at first… but second reboot… it did. Maybe I just wasn’t waiting long enough; not sure. So… false alarm. Start fine on boot.

    Yes, the additional instance of Mongo is started by the mongo install by default. It’s un-necessary and takes up small amount of memory, cpu and storage. I think I killed it on another system by removing the init.d or something like that. Unfortunately, I didn’t document it and I’ll have to go dig in a bit to figure it out. But if I were to write a “how to” for MFI, I’d make getting rid of that other instance a part of it. FTR, getting rid of that improved performance on my primary MFI system quite a bit.

    Gaiex, that command has to be run from the MFI folder (/opt/mFi/ with this install) for it to work. An advantage to doing it that way is that you’ll see stuff as it starts up (errors or whatever). The down side is that if you kill that session, it dies with it (I think). The fix for /that/ issue is to either use an “&” after the command (only response you’ll see is the PID of the instance) or use the “service mfi start / stop” commands. Again, you won’t get as much info with those. But you should get an “ok” or “fail” response at least.

    On to a more interesting element… I built this on an RPI to move over my current MFI from a Ubuntu system (that’s also my Kodi system – hence wanting to move it). But I can’t move the database from a 64-bit (AMD) to 32-bit (RPI) environment. So, just a heads up. Which brings up the question of just how much data the RPI mongo environment will accommodate. I have one M-port and 7 m-power devices. I didn’t want to move them over if I can’t accommodate at least 2-3 months worth of data. And someone on the UBNT board says they got about two weeks worth on the RPI. So… I’m not going to use the RPI as an MFI server / controller.

    Next up: an Intel-based “stick computer” for not too much more money, but it’ll be 64-bit at least.

  23. Ok,

    I checked services running with “sudo service –status-all” and mFi service is running.

    What to check now?


  24. Hi Chris,

    I looked on Gregory post and tried to manualy start the mFi service but don’t know/doesn’t work the comand Gregory wrote: “java -jar lib/ace.jar start”
    Maybe the service is stopped!
    I have to google more linux comands…


  25. Chris,

    Thank you so much for the clear, simple guides for MFI and UNIFI on RPI. Thanks to you, the Unifi system went really smooth and is running great.

    The MFI system is working but I have two issues I’m hoping you can help with:
    1. It’s not auto-starting on boot. Not sure why, but if I use the “java -jar lib/ace.jar start” approach it works great
    2. From what I can see and understand, there’s a second version of Mongo running that doesn’t need to – it’s auto-started by MFI, so that first one is just taking CPU and drive space (AFAICT). I’m able to stop it with “/etc/init.d/mongodb stop” and it’s gone from TOP. Then when I (manually right now) start MFI, it fires up just the one Mongod it needs.

    At first, I thought I’d created these problems by doing a full Jessie system. So I rolled back to Wheezy and followed your instructions exactly. Same outcome for some reason.

    So… any ideas or advice on how to NOT have the first instance of mongod run AND how to assure that mFi /does/ start?

    Much thanks!

    1. Hi Gregory,

      It’s not auto-starting on boot.

      Just checking, did you create the mFi Controller startup script as per the instructions? This seemed to work in the past.

      There’s a second version of Mongo running

      I noticed that myself when I was writing the instructions, but as UniFi was also installed, I had assumed the mFi was launching a second instance of Mongo as using that. But you are saying you can stop the second instance of Mongo and it doesn’t affect the operation of Unifi or mFi? Interesting! It might be possible to add a line to the mFi Controller startup script to stop the second instance of mongodb… maybe.

      Kind Regards,

  26. Hello Chris,

    It looks like the mFi server is down on my Pi2, I rebooted it several times but cannot see the logon webpage.
    Any help in how to look for the problem?
    I’m a linux rookie, sorry! 🙁

    PS: UniFi server is still running!


  27. Hello again,

    Just to give my feedback.

    Done a fresh install of the system and unifi apps as described on your guides and all work ok now.
    UniFi and mFi working on the same Pi2.


  28. Hello Chris,

    Thank you for the installation guide of the mFi.

    I tested today only doing the java 1.6 install process and it looks like it solved my problem of mFi not working and freezing my Pi 2.
    I will give it some more days before I say it works!

    PS: Like I told you before, I just used the same install method as in your UniFi guide and now the java install and it seems to work, let’s see! If not I will go with your complete guide solution.
    I have the UniFi and mFi running on the same Pi 2


Leave a Reply