Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi 3 Cookbook for Python Programmers

You're reading from   Raspberry Pi 3 Cookbook for Python Programmers Unleash the potential of Raspberry Pi 3 with over 100 recipes

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher
ISBN-13 9781788629874
Length 552 pages
Edition 3rd Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Steven Lawrence Fernandes Steven Lawrence Fernandes
Author Profile Icon Steven Lawrence Fernandes
Steven Lawrence Fernandes
Tim Cox Tim Cox
Author Profile Icon Tim Cox
Tim Cox
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Getting Started with a Raspberry Pi 3 Computer 2. Dividing Text Data and Building Text Classifiers FREE CHAPTER 3. Using Python for Automation and Productivity 4. Predicting Sentiments in Words 5. Creating Games and Graphics 6. Detecting Edges and Contours in Images 7. Creating 3D Graphics 8. Building Face Detector and Face Recognition Applications 9. Using Python to Drive Hardware 10. Sensing and Displaying Real-World Data 11. Building Neural Network Modules for Optical Character Recognition 12. Building Robots 13. Interfacing with Technology 14. Can I Recommend a Movie for You? 15. Hardware and Software List 16. Other Books You May Enjoy

Networking and connecting your Raspberry Pi to the internet via an Ethernet port, using a CAT6 Ethernet cable

The simplest way to connect Raspberry Pi to the internet is by using the built-in LAN connection on the Model B. If you are using a Model A Raspberry Pi, a USB-to-LAN adapter can be used (refer to the There's more... section of the Networking and connecting your Raspberry Pi to the internet via a USB Wi-Fi dongle recipe for details of how to configure this).

Getting ready

You will need access to a suitable wired network, which will be connected to the internet, and a standard network cable (with an RJ45 type connector for connecting to Raspberry Pi).

How to do it...

Many networks connect and configure themselves automatically using the Dynamic Host Configuration Protocol (DHCP), which is controlled by the router or switch. If this is the case, simply plug the network cable into a spare network port on your router or network switch (or wall network socket if applicable).

Alternatively, if a DHCP server is not available, you shall have to configure the settings manually (refer to the There's more... section for details).

You can confirm this is functioning successfully with the following steps:

  1. Ensure that the two LEDs on either side of Raspberry Pi light up (the left orange LED indicates a connection and the green LED on the right shows activity by flashing). This will indicate that there is a physical connection to the router and that the equipment is powered and functioning.
  2. Test the link to your local network using the ping command. First, find out the IP address of another computer on the network (or the address of your router, perhaps, often 192.168.0.1 or 192.168.1.254). Now, on the Raspberry Pi Terminal, use the ping command (the -c 4 parameter is used to send just four messages; otherwise, press Ctrl + C to stop) to ping the IP address, as follows:
sudo ping 192.168.1.254 -c 4
  1. Test the link to the internet (this will fail if you usually connect to the internet through a proxy server) as follows:
sudo ping www.raspberrypi.org -c 4
  
  1. Finally, you can test the link back to Raspberry Pi by discovering the
    IP address using hostname -I on Raspberry Pi. You can then use the ping command on another computer on the network to ensure it is accessible (using Raspberry Pi's IP address in place of www.raspberrypi.org). The Windows version of the ping command will perform five pings and stop automatically, and will not need the -c 4 option.

If the aforementioned tests fail, you will need to check your connections and then confirm the correct configuration for your network.

There's more...

If you find yourself using your Raspberry Pi regularly on the network, you won't want to have to look up the IP address each time you want to connect to it.

On some networks, you may be able to use Raspberry Pi's hostname instead of its IP address (the default is raspberrypi). To assist with this, you may need some additional software, such as Bonjour, to ensure hostnames on the network are correctly registered. If you have macOS X, you will have Bonjour running already.

On Windows, you can either install iTunes (if you haven't got it), which also includes the service, or you can install it separately (via the Apple Bonjour Installer available from https://support.apple.com/kb/DL999). Then you can use the hostname, raspberrypi or raspberrypi.local, to connect to Raspberry Pi over the network. If you need to change the hostname, then you can do so with the Raspberry Pi configuration tool, shown previously.

Alternatively, you may find it helpful to fix the IP address to a known value by manually setting the IP address. However, remember to switch it back to use DHCP when connecting to another network.

Some routers will also have an option to set a Static IP DHCP address, so the same address is always given to Raspberry Pi (how this is set will vary depending on the router itself).

Knowing your Raspberry Pi's IP address or using the hostname is particularly useful if you intend to use one of the remote access solutions described later on, which avoids the need for a display.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime