Update: I checked (16-03-2016) and PiUi development appears to have stopped 3 years ago. I suggest trying to setup your own Apatche system instead

Last week I posted a vine video of one of the cool raspberry pi features I just got working for cBAM and a few people asked for more details about how I did it e.t.c. The short answer is ‘I used the fantastic PiUi plugin provided by David Singleton’ the long answer is the short answer plus lots of swearing at slightly inaccurate how-to guides. So I thought a quick combined write up of these guides might also help anyone else Googling around for solutions.


Things you will need

  • RaspberryPi (+monitor, keyboard, mouse, operating system, power supply, power, a surface to put it on, a roof to keep water off, etc..)
  • The internet
  • Some kind of other internet linked device

Step 1: Set up connection

So the first step in using PiUi is making sure that you can login to Raspberry Pi from another device. All you need to do is setup the Raspberry Pi so that it is broadcasting a wi-fi network you can log into. That one simple sentence belies how difficult that actually is to do. Thankfully the process is made a little simpler by the existence of a module called Pi-Point which handles most of the details. Unfortunately the documentation for pi-point is a little patchy and hilariously the ‘Online docs‘ and the ‘Docs in PDF format‘ don’t actually contain all the same instructions. So to speed this up I’ve reproduced a combination of them in the steps below – if you have any problems please go read both of them as they contain more details.

  1. Update your Pi libraries with (all commands are in the LXTerminal) sudo apt-update
  2. Install the following packages
    1. rfkill sudo apt-get install rfkill
    2. zd1211 sudo apt-get install zd1211-firmware
    3. hostapd sudo apt-get install hostapd
    4. hostap-utils sudo apt-get install hostap-utils
    5. iw sudo apt-get install iw
    6. dnsmasq sudo apt-get install dnsmasq
  3. Edit the hostap file with sudo nano /etc/network/interfaces and make sure it looks like the below (you can save with Ctrl+O);
    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp
    iface wlan0 inet static
  4. Restart the Raspberry Pi using the command sudo reboot or just unplugging it and plugging it back in again (the first method is considered a bit more technical than the second)
  5. Edit the hostap config file with sudo nano /etc/hostapd/hostapd.conf this may be blank but make sure it has the following contents  (you can save with Ctrl+O);
    wpa_pairwise=TKIP CCMP
    rsn_pairwise=TKIP CCMP
  6. Restart hostapd with the command sudo service hostapd restart following this you should be able to see your new wi-fi network being broadcast on other devices
  7. Edit the dnsmasq config file with sudo nano /etc/dnsmasq.conf this is a really really long file with 99% of it commented out (has a # at the start) but you need to look for these lines, un-comment them (delete the #) and make sure their values match up to the list below.
  8. Restart hostapd with the command sudo service dnsmasq restart this will now let you log into the network and you should now be assigned a proper IP address.
  9. Finally you need to make sure that this all runs and starts when the Raspberry Pi starts, so you need to create an init.d script . To do this, create a new script with sudo nano /etc/init.d/pipoint and fill it with the following contents.
    # Configure Wifi Access Point.
    # Provides: WifiAP
    # Required-Start: $remote_fs $syslog $time
    # Required-Stop: $remote_fs $syslog $time
    # Should-Start: $network $named slapd autofs ypbind nscd nslcd
    # Should-Stop: $network $named slapd autofs ypbind nscd nslcd
    # Default-Start: 2
    # Default-Stop:
    # Short-Description: Wifi Access Point configuration
    # Description:starts hostap
    # start the access point
    hostapd -B /etc/hostapd/hostapd.conf
  10. You should now be able to start the Raspberry Pi and immediately log into the wi-fi network it is broadcasting. If not, then keep randomly changing things until it works 🙂

Step 2: SetUp PiUi

PiUi is a python based set of packages that essentially sets up a webpage with a range of controls that feedback to the Raspberry Pi. The read-me file for PiUi is pretty good and available here. However, for the sake of keeping everything together, I have also produced a quick-start step by step guide below.

  1. Add mapping for PiUi to the hosts file load up in the nano editor with sudo nano /etc/hosts and add the line piui
  2. Install the nginx package with the command sudo apt-get install nginx
  3. Get the PiUi code from github with sudo git clone https://github.com/dps/piui.git
  4. Copy the nginx file to from the PiUi code to the config directory with sudo cp /home/pi/piui/nginx-conf/nginx.conf /etc/nginx/
  5. Copy the startup script ot the start up folder with sudo cp /home/pi/piui/supervisor/piui-supervisor /etc/init.d
  6. Run the PiUI setup script which installs any other required files with the command sudo python piui/setup.py install [Thanks to Adam for pointing out this additional step 24/07/13]
  7. Reboot Raspberry Pi
  8. Run the demo in the PiUi directory with python /piui/piui_demo.py
  9. Using any device with a browser login to the wi-fi network broadcast by the Raspberry Pi and go to the
  10. Enjoy god like Raspberry Pi powers at your finger tips!

Step 3: Make it dance

Now we’ve got it up and running the last step is to modify the code to run other scripts. This is pretty basic python stuff and depends on what you want to link it to. However, the following steps are a good place to start playing around for anyone a little un-sure of how to use it.

  1. Using an editor load up the piui_demo.py code on the Raspberry Pi. This can either be done using Geany or using the nano editor we used before with the command sudo nano /piui/piui_demo.py
  2. This file will be pretty long and full of def functions but the one you want to start playing with is def onupclick and def ondownclick these are the commands associated with the ‘Buttons’ page in the demo
  3. You can then modify these commands by adding in your own lines of code which will run every time you press these buttons. The simplest way to get these buttons to run code is to have it call other pre-prepared python scripts. You can do these several ways but a very reliable way is to use the call function.
    1. First add the line from subprocess import call to the very top of the piui_demo.py file with all the other import commands
    2. In the def function (either up or down it doesn’t matter) add the line
      call (["sudo python /home....location and name of your python file"],shell=True)
      filling in the name and location of the python file you want to call
    3. Now when you run the piui_demo.py file as at the end of step 2 pressing you chosen button in the browser will now execute the python file you’ve setup.

I hope this is of some help to anyone wanting to repeat what I’ve managed to do. If you have any problems, just post them in the comments section and I’ll do my best to answer them. then good luck fixing them, it’s been years and I’ve forgotten how all this works.

Hi there!

Sign up to receive awesome cartoony content in your inbox, every month.

We don’t spam! Read our privacy policy for more info.


Mel · 4 August 2014 at 08:23

Hey Matthew

I am really interested in using the PIUI app to connect to the raspberry Pi for a project for university but i am fairly new to using the Raspberry Pi. I tried your step 1 and tried playing around with it but i cant seem to get the access point working or showing up on my phone. Are there any tips you can tell me about what i can do to get it to work. also i couln’t get iw installed could that have anything to do with it??:?

    Matthew (@MCeeP) · 13 August 2014 at 21:40

    Hi Mel,

    Sorry for not replying sooner I had some issues with commenting on my blog.

    Do you still need help?


      Nathan G. · 19 November 2014 at 16:47

      I would need help!

      Nathan G. · 19 November 2014 at 16:47

      I would need help!

Melroy · 8 August 2014 at 10:40

Hey there followed ur steps (with a few changes) and got my raspi to be an woreless AP and got the app on my phone to connect to the raspberry pi but stuck on step2.6. i keep getting an error message and cant figure out why the file wont open even if its there.

pi@raspberrypi ~ $ sudo python /piui/setup.py install
python: can’t open file ‘/piui/setup.py’: [Errno 2] No such file or directory

Really desperate to get this to work and any help would be awesome


    Matthew (@MCeeP) · 13 August 2014 at 21:38

    Hi Melroy,

    I know you contact me on twitter eventually to solve this but I wanted to post the fix you helped find here..

    In the How-To the command: sudo python piui/setup.py install had an extra back-slash in the wrong place. I’ve removed it and hopefully it will now work for everyone.


John · 1 February 2015 at 21:22

I’m having the same problem as “Mel” above. Got to step 1.6 and cannot see the SSID being broadcast. Any ideas?

Thanks to the author for the tutorial. Some corrections/additions:
1. Step 1.2.D has a misspelling “sudo apt-get install hastap-utils” should be “sudo apt-get install hostap-utils”.
2. Step 1.3 and 1.5 require the user to type “CTRL-O” to save what they edited before closing. That was not in the bottom menu and could be useful to others.

    Matthew (@MCeeP) · 4 February 2015 at 12:21

    Hi John,

    Thanks for the tips! I’ve updated the how to guide accordingly. Thank-you for keeping it working! 😀


mark · 23 February 2015 at 20:00

Interesting concept. Can this be used as a remote for a python app I am running on the PI

    Matthew (@MCeeP) · 25 February 2015 at 13:10

    Hi Mark, Yup that’s what I had it doing. I should make clear though it’s not my concept or software all I did was write a little how to guide.


stephanie · 10 December 2015 at 23:54

does Piui clashes with apache, php set on it?

mathew · 16 April 2016 at 11:42

how do I STOP a session

An exercise in extra processing – ErrantScience · 8 February 2019 at 22:17

[…] waiting for BAM parts so I spent a little time working on the RasperryPi software, and as I think I mentioned at the time, made pretty good progress. The only thing was that once I’d finished writing the program I […]

12 months of blog statistics – ErrantScience · 8 February 2019 at 22:22

[…] How to: use PiUi (1,400 readers) […]

Leave a Reply