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
Conferences
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

Keeping Raspberry Pi up to date


The Linux image used by Raspberry Pi is often updated to include enhancements, fixes, and improvements to the system, as well as adding support for new hardware or changes made to the latest board. Many of the packages that you install can be updated too.

This is particularly important if you plan on using the same system image on another Raspberry Pi board (particularly a newer one), as older images will lack support for any wiring changes or alternative RAM chips. New firmware should work on older Raspberry Pi boards, but older firmware may not be compatible with the latest hardware.

Fortunately, you need not reflash your SD card every time there is a new release, since you can update it instead.

Getting ready

You will need to be connected to the internet to update your system. It is always advisable to make a backup of your image first (and at a minimum, make a copy of your important files).

You can check your current version of firmware with the uname -a command, as follows:

Linux raspberrypi 4.4.9-v7+ #884 SMP Fri May 6 17:28:59 BST 2016 armv7l GNU/Linux

The GPU firmware can be checked using the /opt/vc/bin/vcgencmd version command, as follows:

   May  6 2016 13:53:23Copyright (c) 2012 Broadcomversion 0cc642d53eab041e67c8c373d989fef5847448f8 (clean) (release)

This is important if you are using an older version of firmware (pre-November 2012) on a newer board, since the original Model B board was only 254 MB RAM. Upgrading allows the firmware to make use of the extra memory if available.

The free -h command will detail the RAM available to the main processor (the total RAM is split between the GPU and ARM cores) and will give the following output:

             total       used       free     shared    buffers     cachedMem:          925M       224M       701M       7.1M        14M       123M-/+ buffers/cache:        86M       839MSwap:          99M         0B        99M

You can then recheck the preceding output following a reboot to confirm that they have been updated (although they may have already been the latest).

How to do it...

  1. Before running any upgrades or installing any packages, it is worth ensuring you have the latest list of packages in the repository. The update command gets the latest list of available software and versions:
sudo apt-get update
  1. If you just want to obtain an upgrade of your current packages, upgrade will bring them all up to date:
sudo apt-get upgrade
  1. To ensure that you are running the latest release of Raspbian, you can run dist-upgrade (be warned: this can take an hour or so depending on the amount that needs to be upgraded). This will perform all the updates that upgrade will perform but will also remove redundant packages and clean up:
sudo apt-get dist-upgrade

Both methods will upgrade the software, including the firmware used at boot and startup (bootcode.bin and start.elf).

  1. To update the firmware, the following command can be used:
sudo rpi-update

There's more...

You will often find that you will want to perform a clean installation of your setup, however, this will mean you will have to install everything from scratch. To avoid this, I developed the Pi-Kitchen project (https://github.com/PiHw/Pi-Kitchen), based on the groundwork of Kevin Hill. This aims to provide a flexible platform for creating customized setups that can be automatically deployed to an SD card:

Pi Kitchen allows Raspberry Pi to be configured before powering up

The Pi-Kitchen allows a range of flavors to be configured, which can be selected from the NOOBS menu. Each flavor consists of a list of recipes, each providing a specific function or feature to the final operating system. Recipes can range from setting up custom drivers for Wi-Fi devices, to mapping shared drives on your network, to providing a fully functional web server out of the box, all combining to make your required setup.

This project is in beta, developed as a proof of concept, but once you have everything configured, it can be incredibly useful to deploy fully working setups directly onto an SD card. Ultimately, the project could be combined with Kevin Hill's advanced version of NOOBS, called PINN Is Not NOOBS (PINN), which aims to allow extra features for advanced users, such as allowing operating systems and configurations to be stored on your network or on an external USB memory stick.

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