Getting Started with My Raspberry Pi – Part 1: Blog Post Survey
In this blog post, I give a brief survey of some of the articles I have come across during my initial work with the Raspberry Pi (RPi).
WiFi
- How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 1 – http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/
- A well written multi-part tutorial that describes how to configure your RPi as an access point (AP) and router. The first two parts covers the AP part, including setup of
hostapd
(user space daemon for WiFi),dnsmasq
(DHCP server), and finally the network/etc/network/
interfaces
config file. The third part covers router setup. - Fun fact: the following post appears to be the one where the author (SirLagz) tells about his plan on making this “turn your RPi into an AP”-thing into a blog post (if you, for some reason encounter problems with this, asking your question in the RPi forum might be the way to go as it appears that SirLagz is also helping people getting this to work): http://www.raspberrypi.org/phpBB3/viewtopic.php?f=36&t=14100
- Please note: that not all WiFi adapters are supported! The tutorial uses a WiFi adapter with the Ralink RT5370 chipset (can be bought for less than $10 on ebay) – in a coming blog post I will list my RPi hardware and peripherals for details on which WiFi adapter(s) I have bought.
- Pros:
- Smart if you are planning to connect to the RPi from a mobile device that do not support ad-hoc connections (e.g. Android devices).
- Cons:
- It is not made very clear that this tutorial do not work for WiFi adapters with drivers that do not comply with the nl80211 interface public header (see: http://www.raspberrypi.org/phpBB3/viewtopic.php?p=176498#p176498)
- A well written multi-part tutorial that describes how to configure your RPi as an access point (AP) and router. The first two parts covers the AP part, including setup of
- [HOW TO] Wireless Hotspot With Realtek RTL8188CUS – http://www.raspberrypi.org/phpBB3/viewtopic.php?f=36&t=19517
- A good tutorial describing the steps involved in creating an ad-hoc network on the RPi. I think this tutorial in particular is better than all other similar attempts (like this, this, and this) because it covers encryption, DHCP, and the scenario where the RPi is only supposed to create an ad-hoc network if it cannot connect to a known WiFi on boot.
- In this tutorial
dhcpd
is used as DHCP server, so if you are planning to try turning your RPi into an AP using the tutorial above, please note that the used DHCP servers are not the same, and be aware that this might give some problems in terms of conflicts if both DHCP servers are installed and running at the same time. - Pros:
- Covers the topic in detail with sample code and descriptions.
- Covers WEP encryption and DHCP.
- Cons:
- I have the
2012-09-18-wheezy-raspbian
image running right now, and used this tutorial as basis for setting up ad-hoc network on my RPi. I did encounter different issues however, like conflicts with the bundledwpa_supplicant
which can be used to manage WPA/WPA2 connections on the RPi. - The tutorial covers how to configure the RPi to create an ad-hoc network if it cannot connect to a given WiFi at boot. However, I do not think that the approach used in the tutorial is what people would really like – in the tutorial it is described how the
/etc/network/interfaces
config should be modified such that the RPi can try to connect to a WiFi on boot without using thewpa_supplicant
. The problem with this is when the known WiFi is not in range – in this case, the RPi stalls the boot process sendingDHCPDISCOVER
packages to the network in attempt to get an IP lease. As this process involves exponential backoff, the boot time is increased by at least 1 to 2 minutes. - Please note: In a coming post I will describe how I have have solved both issues described above – changing this approach to use the
wpa_supplicant
instead in order to keep the boot time low and also support connections to more than one WiFi network.
- I have the
GPIO
- RPi Low-level peripherals – http://elinux.org/RPi_Low-level_peripherals
- This is an entry from the RPi wiki. It is a more or less standard article describing GPIO and I think it gives a good introduction and should be used as reference if you are going to work with GPIO.
- Simple Guide to the RPi GPIO Header and Pins – http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
- This is a well written blog post about how to get started with GPIO and the Python library RPi.GPIO. Besides being a clear and concise post, it includes illustrations and sample code, which makes it easy to read.
- One of the things I like about this article is that it deals with a problem that many newcomers might have – the pin numbers. For some reason, this isn’t as simple as one might expect – it turns out that you can refer to the GPIO pins in different ways, e.g., by the pin numbers (1,2,3,4,…) or by the GPIO channel numbers.
- I used this particular post to get started with GPIO on the RPi and it is highly recommendable if you are new with GPIO and is searching for a good place to start.
- Please note: as mentioned in the blog post, beware that most of the pins goes directly into the Broadcom chip on the RPi – so remember to double check everything before you turn it on.
- Pros:
- Well written. Covers almost everything you need to know in order to get started with GPIO and the RPi.GPIO library.
- Cons:
- None.
- WiringPi – https://projects.drogon.net/raspberry-pi/wiringpi/
- From the web-site: “WiringPi is a wiring-like library written in C and should be usable from C++ and many other languages with suitable wrappers” – where some of the wrappers now include Ruby, Python, PHP, and Perl.
- WiringPi comes with a nice little program which describes itself (from its man pages) as a: ” … Swiss army knife of a command line tool to allow the user easy access to the GPIO pins on the Raspberry Pi…”
- The gpio program is located in
/usr/local/bin/gpio
and uses set-uid to allow the “public” to execute it as root, meaning that it can be invoked by non-root users which might come in handy if you are planning to control GPIO from, e.g., a web server (as running a web server as root seems too dangerous). - Installation of WiringPi including the gpio program is straight forward and is covered here: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
- Sample use of the
gpio
program can be found here: https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/ - Pros:
- Concise with samples and easy-to-follow installation instructions.
- Cons:
- It is difficult to find examples of how to use the
gpio
program. However, I found that the man pages is actually quite good, so take a look at them if you get in doubt.
- It is difficult to find examples of how to use the
- Other GPIO posts that I just skimmed but might be of interest to the reader are:
- Getting Started with Raspberry Pi GPIO and Python
- Tutorial: How to use your Raspberry Pi like an Arduino
- Raspberry Pi – Driving a Relay using GPIO
Web Server
- Accessing GPIO from a web server – http://markingramuk.wordpress.com/2012/08/12/accessing-gpio-from-a-web-server/
- A concise tutorial that describes how to set up lighttpd (pron. lighty) with Python CGI in order to communicate with GPIO from a web server.
- A thing I really like about this tutorial is that everything is thought through. A couple of quotes from the author, Mark Ingram, which I think underlines this, are:
- “… the obvious choice would normally be Apache, but with the Raspberry Pi being limited in CPU and memory resources, I decided to check out lighty (lighttpd) as it has a small memory footprint”
- “As it’s a bad idea to run a web server as a root, you need to access the GPIO from a non-root account. In order to do this, I used the “gpio” program from the WiringPi package.”
- The tutorial seems to be a wrap-up of the following questions (asked by Mark Ingram) on the RPi forum at stackexchange:
- I have been using this tutorial in a project where I’m controlling a relay from a web-interface, and using the tutorial was really simple. The only difference I noticed during my installation was that I did not need to run the initial commands that adds the
www-data
group to the system. So, if you are on raspbian wheezy like me, you might also skip those steps and go directly to:sudo apt-get install lighttpd
. - Pros:
- The tutorial is easy to follow and within minutes, you will have a web server running that allow you to communicate with GPIO through CGI scripts.
- Cons:
- None.
Peripherals
- RPi VerifiedPeripherals – http://elinux.org/RPi_VerifiedPeripherals
- If you are planning to buy any kind of peripheral for your Raspberry Pi and want to check if someone else have made it work on the RPi, I suggest that you take a look at this wiki article. The article contains a comprehensive list of verified peripherals grouped by categories like: SD Cards, USB Keyboards, USB Mouse, Power Adapters, etc.
- Pros:
- I used this list to decide which hardware to buy for my RPi, and I wasn’t disappointed – everything have just worked out of the box.
- Cons:
- None.
Trackbacks/Pingbacks
[…] This is covered in great detail by Mark Ingram here: http://markingramuk.wordpress.com/2012/08/12/accessing-gpio-from-a-web-server/ (see my Raspberry Pi blog post survey for my comments on that tutorial: Getting Started with My Raspberry Pi – Part 1: Blog Post Survey) […]