Digital Free Library: Created by Kirby Griese
Digital Free Library: Created by Kirby Griese
Digital Free Library: Created by Kirby Griese
Guide Contents 2
Overview 3
Parts Needed 3
Preparation 5
Prepare Micro SD Card 5
Install Apache 7
Configure Access Point 9
Set up DHCP server 9
Set up wlan0 for static IP 11
Configure Access Point 13
Update hostapd 15
Finishing up! 16
Understanding the Webpage 17
Transferring The Files 18
Change Hostname 21
Connecting To The Library 23
I decided to create this project so I could share my favorite digital magazines and projects with my neighborhood.
Hopefully this will get others interested in electronics by showing them stuff they might not have know about.
We will be using a Raspberry Pi Zero and a WiFi adapter to create a hotspot that others can connect to and browse the
digital books offered.
Parts Needed
Raspberry Pi Zero (https://adafru.it/sTA) - Version does not matter
SD card (https://adafru.it/sTB) - We will be using Jessie Lite so anything 2gb or greater will work.
USB WiFi Module (https://adafru.it/sTC) - This one has been verified to work with this guide.
Tiny OTG Adapter (https://adafru.it/sTD) - A USB OTG Host Cable (http://adafru.it/1099) would also work if you
have one already
Raspberry Pi Zero Case (http://adafru.it/3252) - Optional
USB Cable A/MicroB (https://adafru.it/sTF)
You may also want to try a more recent version if that's available and 9/28/2016 isnt working
https://adafru.it/sUb
https://adafru.it/sUb
Once that is done we need to setup the Pi Zero to be used as a ethernet gadget. This will allow us to program it from
our computer when it is plugged in to the usb port.
Follow the Ethernet Gadget and Ethernet Tweaks steps in the following guide. I did not need to do the fixed IP step.
https://adafru.it/sUc
https://adafru.it/sUc
To connect to the Raspberry Pi we will use SSH. If you are not familiar with using SSH to access the Raspberry Pi follow
this guide and then come back to here
https://adafru.it/sUd
https://adafru.it/sUd
Now we can connect to the Raspberry Pi using SSH. The hostname we will be connecting to is raspberrypi.local
Before moving to the next step we need to make sure we can connect to the internet. We will ping google.com
ping -c 5 google.com
We will start with installing apache using the following command in terminal. This will take about 5 minutes to install.
cd /var/www/
To test that Apache installed correctly we will open a web browser and go to
http://raspberrypi.local/
We now want to leave this folder and go back to the main directory. We will have issues later in the guide if we stay in
/var/www, to exit just enter
cd
First we install the software onto the Raspberry Pi that will act as the 'hostap' (host access point)
Next we will edit /etc/dhcp/dhcpd.conf, a file that sets up our DHCP server - this allows wifi connections to
automatically get IP addresses, DNS, etc.
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
Then scroll down to the bottom and add the following lines
Run
Next we will set up the wlan0 connection to be static and incoming. Run sudo nano /etc/network/interfaces to edit the file
Find the line auto wlan0 and add a # in front of the line, and in front of every line afterwards. If you don't have that line,
just make sure it looks like the screenshot below in the end! Basically just remove any old wlan0 configuration
settings, we'll be changing them up
Depending on your existing setup/distribution there might be more or less text and it may vary a little bit
After allow-hotplug wlan0 - see below for an example of what it should look like. Any other lines afterwards should
have a # in front to disable them
We will get an error message since we do not have a device connected to wlan0 at the moment.
To enable a password remove the # in front of the 5 lines that have wpa in them
interface=wlan0
#driver=rtl871xdrv
ssid=Pi_AP
country_code=US
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
#wpa=2
#wpa_passphrase=Raspberry
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=CCMP
#wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
I have found that it will load the correct drivers if you comment out the line driver=rtl871xdrv
Save as usual. Make sure each line has no extra spaces or tabs at the end or beginning - this file is pretty picky!
Now we will tell the Pi where to find this configuration file. Run sudo nano /etc/default/hostapd
DAEMON_CONF=
and change it to
DAEMON_CONF=/etc/hostapd/hostapd.conf
Update hostapd
I have added this step as required since I could not get it to work with the usb wifi module until I did this.
Before we can run the access point software, we have to update it to a version that supports the WiFi adapter.
First get the new version by typing in
wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
unzip adafruit_hostapd_14128.zip
to uncompress it. Move the old version out of the way with
Finishing up!
Now it is time to set it up as a 'daemon' - a program that will start when the Pi boots.
To set the daemon services to run every time on boot enter these commands.
https://adafru.it/sVe
https://adafru.it/sVe
Once you have the file downloaded you can open the index.html file in a word editing program such as WordPad and
edit the links for the images and files if you want to add or remove books.
<div class="responsive">
<div class="img">
<a target="_top" href="issues/coloringbook_1-23-2014.pdf">
<img src="images/rforrobot.jpg" >
</a>
<div class="desc"><p>Ladyada's R is for Robotics is a coloring book adventure with robots, their inventors and more
<p>Makers of all ages can learn, color and share their favorite robots and roboticists.</p>
<a href="https://www.adafruit.com/products/1936" target="_blank">https://www.adafruit.com/products/1936</a></div>
</div>
</div>
To add aditional books to the page paste the code shown above before the </body> tag in the html file.
For changing the image that shows you would change the line with
You change either folder to any name, but just make sure the code is pointing to the right folder.
To change the description under the image we would edit this part of the code from earlier.
<div class="desc"><p>Ladyada's "E is for Electronics" is a coloring book adventure with electronic components and the
<p>Makers of all ages can learn, color, and share common parts and historical figures throughout history. Explore the
<a href="https://www.adafruit.com/products/1000" target="_blank">https://www.adafruit.com/products/1000</a></div>
https://adafru.it/sUA
https://adafru.it/sUA
Once WinSCP is installed we will open it up and put in raspberrypi.local for the Host name. You can also enter the
username and password now or it will prompt you for that info later.
We need to go up two directories. So double-click on the folder with the up arrow twice.
Now we are in the root folder. We need to get to /var/www/html, Double-click on the folder labeled var, then double-
click on the folder labeled www, and finally double click the folder labeled html
sudo raspi-config
Once you exit the config it will ask if you would like to reboot. Select yes.
When you connect using SSH you will need to enter the new hostname library.local
In your web browser go library.local this may be different if you used a different hostname.