Book Image

Raspberry Pi 2 Server Essentials

By : Piotr J Kula
Book Image

Raspberry Pi 2 Server Essentials

By: Piotr J Kula

Overview of this book

There’s no end to what you can do with a Raspberry Pi – it makes a huge range of tech projects possible. This book shows you how to transform it into a multipurpose web server, able to store and manage resources that lets you build some truly innovative and impressive computing creations. You’ll learn how to use your Raspberry Pi 2 to host a website using a range of different languages, host a game server, store files, and run everything from a media center to a cloud network. If you want to take control of your technological world, start building your own server and find out what’s possible with the Raspberry Pi microcomputer. Begin by getting your Pi set up – follow each step as the book shows you how to prepare a network and configure the additional features that you’ll need to build your projects. Once you’ve done this you’ll dig a little deeper and set up your pi as a file server, making sure it’s built for speed using a range of different tools, including Python, Node.js and ASP.NET. Following this the book shows you how to extend your server to allow you to host games, and stream live HD video before customizing it even further to create a fully-fledged media center. It doesn’t stop there however – the book then dives into the exciting world of the Internet of Things (IoT). You’ll learn how to install Windows IoT onto your Raspberry Pi, the operating system that’s driving embedded software projects all around the world. Once you’ve done this you’ll be ready to explore IoT further, as the book shows you how to use your device to host a cloud network that can form the basis of a wider IoT project.
Table of Contents (19 chapters)
Raspberry Pi 2 Server Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Hardware requirements


This book assumes that you are using a Raspberry Pi 2, Model B.

The Raspberry Pi 2 is mostly backwards compatible with all its predecessors. Whenever a compatibility issue occurs, it will be made clear to the user and an alternative solution will be provided, if possible.

The latest versions of Raspberry Pi at the most basic level only need a power supply and Micro SD card to run. To make initial configurations easier, it is recommended that you also have an HDMI cable, a wide screen monitor or television with HDMI input, an Ethernet cable, and a USB keyboard.

The following table describes the main differences between the various models:

Model

Generation 2 Model B

Model B+

Model A+

Soc

BCM2836

BCM2835

CPU

900 MHz Quad Core ARMv7

700 MHz single core ARMv6

GPU

VideoCore IV @ 250Mhz / OpenGL ES 2.0 / H.264/MPEG-4 AVC

SDRAM

1 GB

512 MB

256 MB

USB

4

2

1

Audio in

No direct input and two revision boards via I2S, all of which use a USB

Network

10/100 Mbit/s

None

GPIO

17

17

17

Header

40 pins

26 pins

26 pins

Power

800 mA (4.0 W)

800 mA (4.0 W)

200 mA (1 W)

SD card

Micro SD slot

With the latest models of the Raspberry Pi, most peripherals should work out of the box, as these versions have been upgraded with a dedicated power circuit to handle peak loads but also reduce overall power consumption. Only the plus models have this new circuit, and all the older versions of Raspberry Pi might suffer from power problems caused by inefficient circuits. The most power-efficient Raspberry Pi is Model A+ and is commonly powered using batteries. We will discuss powering your Raspberry Pi from batteries in a later chapter of this book.

Power supply

The Raspberry Pi 2 should ideally be powered using a 2 amp USB power supply if you plan to connect peripherals to the USB ports. The most common power supplies found at home are 1 amp power supplies, which are typically supplied with smartphones, tablets, or mini computers. These chargers are usually made from good quality components and can easily handle the stress of additional power, power spikes, and produce a clean DC power source, which is very important for Wi-Fi or serial peripherals.

You should also pay attention to the USB cable that you are using as some cables are produced cheaply and the copper wire inside them is very thin, which struggles to deliver 1 amp or more of current when needed.

In an independent test, the best USB charger turned out to be the HP TouchPad charger (P/N 157-10157-00), and the next best ones are Apple A1265, Apple iPad A1357, and Samsung Cube ETA0U80JBE. They are considered to be the best because they produce very clean DC power and can handle peak loads for extended periods of time. Be careful, though, as a lot of counterfeit chargers are also being sold now, especially Apple A1265. As time passes, some of these power supplies may become obsolete. Try and search for newer tests.

To help visualize the DC noise problem, examine the following image. The waveform on the left-hand side is extremely noisy and will cause serious problems for communication peripherals such as Wi-Fi, bluetooth, or even serial. The waveform on the right-hand side is considered to be clean and stable:

Tip

Search the Internet for tips on how to identify counterfeit chargers.

USB hub

When you purchase a powered USB hub, it is usually supplied with a 2 or 3 amp power supply. This is enough to power USB devices such as a Wi-Fi adapter, a USB hard drive, a few other peripherals, and even the Raspberry Pi itself.

A typical problem occurs with HD USB cameras where the picture goes black after a running for some time. Using a powered USB hub will solve this problem.

SD cards

SD cards all look alike, but, in fact, some use a multitude of different controllers and NAND Flash memory chips. All these combinations make up the reliability and speed of the card; the cheapest is the worst, usually. That said, spending a fortune on an SD card is not a good idea either. The speeds of SD cards are marked with a numeric symbol ranging from 1, the slowest, to 10, the fastest. A class 6 or 8 SD card is a good balance between performance and price.

However, not all Class 10 cards are the best choice either. The only way to be sure is to use a trusted speed test application to verify that the card is performing at the advertised read and write speeds; this is the best way to identify counterfeit cards:

The SD card should only act as the primary partition for an operating system and applications installed on it. Using an SD card for frequently changing data, such as databases, is not a good idea as it degrades the life of the card faster than expected. Instead, we should use external storage devices, such as hard drives or Network Attached Storage (NAS), to handle frequently changing data but also help with storing large amounts of media.

This book assumes that you are using at least an 8 GB SD card.