Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Python Programming for IoT

You're reading from  Practical Python Programming for IoT

Product type Book
Published in Nov 2020
Publisher Packt
ISBN-13 9781838982461
Pages 516 pages
Edition 1st Edition
Languages
Author (1):
Gary Smart Gary Smart
Profile icon Gary Smart
Toc

Table of Contents (20) Chapters close

Preface 1. Section 1: Programming with Python and the Raspberry Pi
2. Setting Up your Development Environment 3. Getting Started with Python and IoT 4. Networking with RESTful APIs and Web Sockets Using Flask 5. Networking with MQTT, Python, and the Mosquitto MQTT Broker 6. Section 2: Practical Electronics for Interacting with the Physical World
7. Connecting Your Raspberry Pi to the Physical World 8. Electronics 101 for the Software Engineer 9. Section 3: IoT Playground - Practical Examples to Interact with the Physical World
10. Turning Things On and Off 11. Lights, Indicators, and Displaying Information 12. Measuring Temperature, Humidity, and Light Levels 13. Movement with Servos, Motors, and Steppers 14. Measuring Distance and Detecting Movement 15. Advanced IoT Programming Concepts - Threads, AsyncIO, and Event Loops 16. IoT Visualization and Automation Platforms 17. Tying It All Together - An IoT Christmas Tree 18. Assessments 19. Other Books You May Enjoy

Summary

In this chapter, we explored the Python ecosystem that is part of a typical Unix-based operating system such as Raspbian OS and learned that Python is a core element of the operating system tooling. We then covered how to create and navigate a Python virtual environment so that we can sandbox our Python projects so they will not interfere with one another or the system-level Python ecosystem.

Next, we learned how to use the Python package management tool, pip, to install and manage Python library dependencies from within a virtual environment, and we did this by installing the GPIOZero and PiGPIO libraries. And since there will be times that we need to execute a Python script as the root user, from outside its virtual environment or during boot up, we also covered these various techniques.

By default, Raspbian does not have all of its GPIO interfaces enabled, so we performed the configuration needed to enable these features so that they are readily available for use in later chapters. We also started and learned how to set up the PiGPIO daemon service so that it starts every time your Raspberry Pi is booted.

The core knowledge you have gained in this chapter will help you to correctly set up and navigate sandboxed Python development environments for your own IoT (and non-IoT) projects and safely install library dependencies so they do not interfere with your other Python projects or the system-level installation of Python. Your understanding of different ways of executing a Python program will also help you to run your projects with elevated user permissions (that is, as the root user), or at boot, should your project have these requirements.

Next, in Chapter 2Getting Started with Python and IoT, we will jump straight into Python and electronics and create an end-to-end internet-enabled program that can control an LED over the internet. We will take a look at two alternative ways of flashing an LED using the GPIOZero and PiGPIO GPIO libraries before connecting our LED to the internet by using an online service, dweet.io, as our networking layer. 

You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020 Publisher: Packt ISBN-13: 9781838982461
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 $15.99/month. Cancel anytime