Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with Python for the Internet of Things

You're reading from   Getting Started with Python for the Internet of Things Leverage the full potential of Python to prototype and build IoT projects using the Raspberry Pi

Arrow left icon
Product type Course
Published in Feb 2019
Publisher
ISBN-13 9781838555795
Length 732 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (5):
Arrow left icon
Tim Cox Tim Cox
Author Profile Icon Tim Cox
Tim Cox
Prof. Diwakar Vaish Prof. Diwakar Vaish
Author Profile Icon Prof. Diwakar Vaish
Prof. Diwakar Vaish
Sai Yamanoor Sai Yamanoor
Author Profile Icon Sai Yamanoor
Sai Yamanoor
Steven Lawrence Fernandes Steven Lawrence Fernandes
Author Profile Icon Steven Lawrence Fernandes
Steven Lawrence Fernandes
Srihari Yamanoor Srihari Yamanoor
Author Profile Icon Srihari Yamanoor
Srihari Yamanoor
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (37) Chapters Close

Title Page
Copyright and Credits
About Packt
Contributors
Preface
1. Getting Started with a Raspberry Pi 3 Computer FREE CHAPTER 2. Dividing Text Data and Building Text Classifiers 3. Using Python for Automation and Productivity 4. Predicting Sentiments in Words 5. Detecting Edges and Contours in Images 6. Building Face Detector and Face Recognition Applications 7. Using Python to Drive Hardware 8. Sensing and Displaying Real-World Data 9. Building Neural Network Modules for Optical Character Recognition 10. Arithmetic Operations, Loops, and Blinky Lights 11. Conditional Statements, Functions, and Lists 12. Communication Interfaces 13. Data Types and Object-Oriented Programming in Python 14. File I/O and Python Utilities 15. Requests and Web Frameworks 16. Awesome Things You Could Develop Using Python 17. Robotics 101 18. Using GPIOs as Input 19. Making a Gardener Robot 20. Basics of Motors 21. Bluetooth-Controlled Robotic Car 22. Sensor Interface for Obstacle Avoidance 23. Making Your Own Area Scanner 24. Basic Switching 25. Recognizing Humans with Jarvis 26. Making Jarvis IoT Enabled 27. Giving Voice to Jarvis 28. Gesture Recognition 29. Machine Learning 30. Making a Robotic Arm 1. Other Books You May Enjoy Index

Configuring your network manually


If your network does not include a DHCP server or it is disabled (typically, these are built into most modern ADSL/cable modems or routers), you may need to configure your network settings manually.

Getting ready

Before you start, you will need to determine the network settings for your network.

You will need to find out the following information from your router's settings or another computer connected to the network:

  • IPv4 address: This address will need to be selected to be similar to other computers on the network (typically, the first three numbers should match, that is, 192.168.1.X if netmask is 255.255.255.0), but it should not already be used by another computer. However, avoid x.x.x.255 as the last address, since this is reserved as a broadcast address.
  • Subnet mask: This number determines the range of addresses the computer will respond to (for a home network, it is typically 255.255.255.0, which allows up to 254 addresses). This is also sometimes referred to as the netmask.
  • Default gateway address: This address is usually your router's IP address, through which the computers connect to the internet.
  • DNS servers: The Domain Name Service (DNS) server converts names into IP addresses by looking them up. Usually, they will already be configured on your router, in which case you can use your router's address. Alternatively, your Internet Service Provider (ISP) may provide some addresses, or you can use Google's public DNS servers at the addresses 8.8.8.8 and 8.8.4.4. These are also called nameservers in some systems.

For Windows, you can obtain this information by connecting to the internet and running the following command:

ipconfig /all

Locate the active connection (usually called Local Area Connection 1 or similar if you are using a wired connection, or if you are using Wi-Fi, it is called a wireless network connection) and find the information required, as follows:

The ipconfig/all command shows useful information about your network settings

For Linux and macOS X, you can obtain the required information with the following command (note that it is ifconfig rather than ipconfig):

ifconfig

The DNS servers are called nameservers and are usually listed in the resolv.conf file. You can use the less command as follows to view its contents (press Q to quit when you have finished viewing it):

less /etc/resolv.conf

How to do it...

To set the network interface settings, edit /etc/network/interfaces using the following code:

sudo nano /etc/network/interfaces

Now perform the following steps:

  1. We can add the details for our particular network, the IP address number we want to allocate to it, the netmask address of the network, and the gateway address, as follows:
iface eth0 inet static  address 192.168.1.10  netmask 255.255.255.0  gateway 192.168.1.254
  1. Save and exit by pressing Ctrl + X, Y, and Enter.
  2. To set the name servers for DNS, edit /etc/resolv.conf using the following code:
sudo nano /etc/resolv.conf
  1. Add the addresses for your DNS servers as follows:
nameserver 8.8.8.8nameserver 8.8.4.4
  1. Save and exit by pressing Ctrl + X, Y, and Enter.

There's more...

You can configure the network settings by editing cmdline.txt in the BOOT partition and adding settings to the startup command line with ip.

 

The ip option takes the following form:

ip=client-ip:nfsserver-ip:gw-ip:netmask:hostname:device:autoconf
  • The client-ip option is the IP address you want to allocate to Raspberry Pi
  • The gw-ip option will set the gateway server address if you need to set it manually
  • The netmask option will directly set the netmask of the network
  • The hostname option will allow you to change the default raspberrypi hostname
  • The device option allows you to specify a default network device if more than one network device is present
  • The autoconf option allows the automatic configuration to be switched on or off
You have been reading a chapter from
Getting Started with Python for the Internet of Things
Published in: Feb 2019
Publisher:
ISBN-13: 9781838555795
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 $19.99/month. Cancel anytime
Banner background image