aut viam inveniam aut faciam

Pi based wireless access point camera

Notes relating to the wireless AP camera

Something created for my dad but following this should get you a Raspberry Pi acting as a wireless access point that once you have logged into it will show a video of whatever the camera is pointing at, the idea being to allow you to set up garage monitor-bird feeder viewer-wildlife viewer (or shower cam probably not a good idea) but you get the point.

The instructions are perhaps a little dry! or in other words lacking in visualisation and pizzazz something which without the modern world seems to struggle anyway they work, if you do find an issue or have an improvement let me know i'm always open to learn and improve. Oh finally everything here worked when i started this project in May 2017, with subsequent Pi improvements/camera changes/software updates there is no guarantee they'll work but at least they will be a good starting point.

All this info can be downloaded as an org file The Pi as a wireless access point camera

Table of contents   TOC


I setup a pi zero via a USB to TTL Serial lead and using a USB hub with wireless adaptor and a USB>ethernet device to allow for the updates.

clean install raspbian jessie-lite 2017-03-02-raspbian-jessie-lite i use a either win32diskimager or etcher (which i prefer for just burning /img/picam)

Then once the image has burnt, dont eject the card! first create an empty file called ssh eg;

file:/img/picam/2017-03-14 13_58_36-boot (F_).png

the reason for this is that the last few distributions have ssh access disabled as a default. This is ok if you are running the pi with keyboard, mouse, display etc but when all your pi's are setup and run headless its a pain in the ass. Which is why i normally create my own rasbian ssh enabled image, but anyway once the blank file has been created you can remove the sd card and put in the pi and boot.

Once booted and logged in via ssh run the raspi-config utility and set the following options;

  • update tool

  • expand file system

  • change hostname (optional)

  • set memory split (i use 16 or 32 for gpu)

  • enable camera

Once you've done all that it is upto whether to change the default user/password combo, its recommended but purely for play and testing i leave it as is.


sudo apt-get update

sudo apt-get upgrade


sudo apt install python-pip sudo pip install picamera


sudo apt-get install apache2

Run bash script from webpage (eg shutdown)

If you want to run cgi or bash scripts then the default apache conf file (sites-available) is set up for this just put the script in /usr/lib/cgi-bin however in order to get it working i had to edit the /etc/apache2/apache2.conf file and add a single line

Servername localhost

then run the command to enable cgi

sudo a2enmod cgi

then when visiting a page such as the script ran ok and printed the text.

echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash CGI!"
echo "</title></head><body>"
echo "<h1>Hello World</h1>"
echo "Today is $(date)"
echo "</body></html>"

So for example a simple shutdown script would be ;

#!/usr/bin/env sh
sudo shutdown -h now

There is only one more problem with this if you dont add the www-data user to the sudoers list it will error out so;

sudo visudo and add the line

www-data ALL = NOPASSWD: /sbin/shutdown

then the script will shutdown your pi :)


"hostapd is a user space daemon for access point and authentication servers. " or simply put allows you to create an access point.

sudo apt-get install -y hostapd python3 python3-dev python3-flask python3-picamera

Now its installed we need to create the config files so it nows how to act;

Create the following hostapd config file sudo nano /etc/hostapd/hostapd.conf


Changing the ssid and the wpa_passphrase to your own preferences.

static ip

Finally give the pi a static IP address by editing the /etc/network/interfaces/ file. Why? well if there are issues in setting up a python script or you simply want to update the system or improve then its much easier to type ssh pi@i know my target ip address than either search or open the router interface etc, besides if you've got this far its highly likely you will have more than one pi! So giving them each a specific IP address is a good thing.

allow-hotplug wlan0
iface wlan0 inet static
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


Again as with the wifi name and passphrase you can choose your own IP address to suit your network setup.

dchp server

then sudo apt-get install isc-dhcp-server

sudo nano /etc/dhcp/dhcpd.conf and make sure you have the following contents

  • alter the following;

ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
  • comment out the lines;

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
  • add/copy & paste the following to the end of the file;

#for the wireless network on wlan0
subnet netmask {
option domain-name-servers,;
option routers;
interface wlan0;

Now edit the isc default

sudo nano /etc/default/isc-dhcp-server

and change INTERFACES="" to INTERFACES="wlan0"

Close and save the file.

finally reboot.

sudo hostapd -B /etc/hostapd/hostapd.conf

sudo /etc/init.d/isc-dhcp-server restart

I had issues with the above command however the following worked.

sudo systemctl enable isc-dhcp-server

If the above steps mean you connect to the wireless network and can see the local webpage on then get it to auto run by uncommenting the following line in etc/default/hostapd


install pip3   optional

sudo apt-get install python3-pip

stream using motion

Ok the simplest way I've found of streaming video from the pi is using the daemon motion if you have an alternative i'd be interested but this is the easiest way i've found of adding video/images onto a Pi hosted Apache website.

sudo apt-get install motion


Now edit the motion config file

sudo nano /etc/motion/motion.conf

Find and change the following just dont include the text in brackets;

daemon on
stream_localhost off
output_pictures off (doesnt save images on motion detection)
ffmpeg_output_movies off (doesnt save video on motion detection)

stream_maxrate 100 (Allows for real-time streaming)
framerate 100 (gives smother video ie 100 frames per second)
width 640 
height 480

Now we need to set the daemon by;

sudo nano /etc/default/motion

change the line as follows


Now make sure the camera is connected and run the following line:

sudo service motion start

If you need to stop the service, simply run the following command:

sudo service motion stop

if you have issues then re-edit the /etc/motion/motion.conf file and uncomment the line

logfile /tmp/motion.log

You can then review the log file for error messages. Following all the above steps will give you an issue dont panic its not big for a start you will not have seen the red light on the picamera but review the log file and you might see something like;


What this means is as the msg says motion cannot open the video device, to get it working you need to type the following;

sudo modprobe bcm2835-v4l2 (it is v4 lowercase letter L 2)

As soon as you enter the above the red light will come on and you should be able to go to your Pi IP address and see a video; eg for my current setup it was and i see a nice video of an ugly chap (image below);


This will have to be run on every boot of the device. Or you can put bcm2835-v4l2 in /etc/modules to make it run on every boot automatically eg;

# camera with v4l2 driver

Now to add motion to your apache website simply add the following line;

<img src= "" width="640" height="480"/>

So now you have a simple website with live streaming video, not fast but it works. There are a few other steps to take that may make it even better. For a start turning off the damn red light;

sudo nano /boot/config.txt

and add the line


General weblinks to info on pi camera etc

Checking your pi cpu version

Just in case you're interested :)

You can check your pi version with cat /proc/cpuinfo the results will look like;


So you can see the pi i used is a revision 3 which is a model B Rev 1. The following table (taken from raspberrypi-spy) gives revision numbers


Recent posts


See more



former child, still love computer games & fantasy, future corpse