๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Programming the Raspberry Pi Pico/W in MicroPython, Second Edition

โœ Scribed by Harry Fairhead, Mike James


Publisher
I/O Press
Year
2022
Tongue
English
Leaves
360
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Synopsis


Reviews of the first edition:
"Obviously the author knows his stuff. I love the writing style and helpful hints to deal with python limitations."
"Book contains many nuggets of info not found in other books."

The Raspberry Pi Pico is a remarkable microcontroller. It has a power and sophistication that would have been unthinkable just a short time ago. For the sort of jobs it is ideal for, it has plenty of processing power and enough memory to make tasks that would have once required careful planning, relatively easy. Instead of struggling with the machine, you can now focus on a good implementation of your algorithms.

MicroPython is a good choice of language to program the Pico. It isnโ€™t the fastest way, but in most cases it is fast enough to interface with the Picoโ€™s hardware and its big advantage is that it is easy to use. As a high-level language, MicroPython is based on Python 3 and is fully object-oriented. This means that you can create classes to encapsulate hardware and make it easier to use and understand.

The purpose of the book is to reveal what you can do with the Pico's GPIO lines together with widely used sensors, servos and motors and ADCs. After covering the GPIO, outputs and inputs, events and interrupts, it gives you hands-on experience of PWM (Pulse Width Modulation), the SPI bus, the I2C bus and the 1-Wire bus. One of the key advantages of the Pico is its PIO (Programmable I/O) and while this is an advanced feature, it is introduced in this book. After finding out how the PIO works, we apply it to writing a PIO program for the DHT22 and the 1-Wire bus.

The original Pico lacked WiFi connectivity, a limitation overcome by the launch of the Pico W. Two new chapters are dedicated to how to make use of the additional features of the Pico W including how to create a web client and a web server, use HTTPS and asyncio.

Jointly authored by
Harry Fairhead and Mike James, this book is along the same lines as Programming the Raspberry Pi Pico/W in C and combines Harryโ€™s expertise in electronics and the IoT with Mikeโ€™s knowledge of Python.

Harry Fairhead is also the author of Raspberry Pi IoT In C Using Linux Drivers, Raspberry Pi IoT in C, Applying C For The IoT With Linux, Fundamental C: Getting Closer To The Machine and Micro:bit IoT in C.

Mike James is the author of the Programmer's Python: Something Completely Different series of books and several other programming and computer science titles in the I Programmer Library.

โœฆ Table of Contents


Second Edition
Preface
Table of Contents
Chapter 1
The Raspberry Pi Pico โ€“ Before We Begin
The Pico And Its Family
What To Expect
What Do You Need?
Community
Summary
Chapter 2
Getting Started
Installing MicroPython
Hello World Using Thonny
Hello World VS Code
Summary
Chapter 3
Getting Started With The GPIO
Pico Pins
Basic GPIO Functions
Blinky
Which Hardware?
Summary
Chapter 4
Simple Output
Basic GPIO Functions
How Fast?
Including Pauses
Fixed Time Delay
Phased Pulses
Setting Multiple GPIO Lines
Summary
Chapter 5
Some Electronics
Electrical Drive Characteristics
Driving An LED
LED BJT Drive
A BJT Example
MOSFET Driver
MOSFET LED
Setting Drive Type
Push-Pull Mode
Pull-Up Mode
Pull-Down Mode
Setting Output Mode
Basic Input Circuit - The Switch
Debounce
The Potential Divider
Summary
Chapter 6
Simple Input
GPIO Input
Basic Input Functions
The Simple Button
Press Or Hold
How Fast Can We Measure?
The Finite State Machine
FSM Button
FSM Hold Button
FSM Ring Counter
Summary
Chapter 7
Advanced Input โ€“ Events and Interrupts
Events
Interrupts Considered Harmful?
Hardware Events
An Edgy Button
Measuring Pulses With Events
Interrupts
How Fast Is An Interrupt?
Race Conditions and Starvation
Responding To Input
Summary
Chapter 8
Pulse Width Modulation
Some Basic Pico PWM Facts
Pico PWM
Changing The Duty Cycle
Duty Cycle Resolution
Uses Of PWM โ€“ Digital To Analog
Frequency Modulation
Controlling An LED
What Else Can You Use PWM For?
Summary
Chapter 9
Controlling Motors And Servos
DC Motor
Brushed Motors
Unidirectional Brushed Motor
Unidirectional PWM Motor Controller
Bidirectional Brushed Motor
Bidirectional Motor Software
Using A Single Full H-Bridge As Two Half H-Bridges
Controlling a Servo
Brushless DC Motors
Stepper Motors
Stepper Motor Driver
Stepper Motor Rotation โ€“ Using Timers
Summary
Chapter 10
Getting Started With The SPI Bus
SPI Bus Basics
Pico SPI Interfaces
The SPI Functions
Initialization
Data Transfer Functions
Using the Data Transfer Functions
A Loopback Example
Using The CS Line
The BME280 Humidity, Pressure and Temperature Sensor
Problems
Summary
Chapter 11
A-To-D And The SPI Bus
Pico ADC
The MCP3008 SPI ADC
Connecting To The Pico
Basic Configuration
The Protocol
SPI ADC Class
How Fast?
Summary
Chapter 12
Using The I2C Bus
I2C Hardware Basics
The Pico I2C
The I2C Functions
Initialization
Write
Writing To A Register
Read
Reading A Register
Slow Read Protocols
A Real Device
A First Program
The I2C Protocol In Action
Reading The Raw Temperature Data
Processing The Data
Reading Humidity
Checksum Calculation
Complete Listing
Summary
Chapter 13
Using The PIO
PIO Basic Concepts
State Machines And GPIO
PIO Blinky
Clock Division And Timing
Writing Loops
Data To The PIO
Output To GPIO
Side Effects
Input
Edges
Advanced PIO
Summary
Chapter 14
The DHT22 Sensor Implementing A Custom Protocol
The DHT22
The Electronics
The DHT Driver
The Protocol
Reading The Data
Extracting The Data
DHT22 Using the PIO โ€“ Counting
DHT22 Using the PIO โ€“ Sampling
Complete Listing
Summary
Chapter 15
The 1โ€‘Wire Bus And The DS1820
The Hardware
Initialization
Using The Driver
Writing Bits
Writing With The Driver
A First Command - Writing Bytes
Writing Bytes With the Driver
Reading Bits
Reading Using The Driver
Working With 1-Wire Devices
Computing The CRC
The DS18B20 Hardware
The DS18B20 Driver
Initialization
Initiating Temperature Conversion
Reading the Scratchpad
Getting The Temperature
A Temperature Class
The Complete Program
Driver Version
A PIO DS18B20 Program
Complete Program
Other Commands
Summary
Chapter 16
The Serial Port
Serial Protocol
UART Hardware
Setting Up the UART
Data Transfer
Serial Polling
Timeouts
Polling On Write
Reading and Writing Characters and Strings
Summary
Chapter 17
Using The Pico W - WiFi
The Picoย W
The WLAN Class
A Practical Connect
WiFi Scan
A Simple HTTP Client
Request Methods
A Custom Server
The urequests Module
A Temperature Sensor Client
Sockets
Socket Address
Client Sockets
A Socket Web Client
SSL Socket Based HTTPS Client
Socket Server
A Socket Temperature Server
An SSL HTTPS Server
Non-Blocking Sockets
The Connection Queue
Summary
Chapter 18
Asyncio And Servers
Coroutines and Tasks
Await
Awaiting Sleep
Tasks
Sequential and Concurrent
Canceling Tasks
Dealing With Exceptions
Shared Variables and Locks
Using uasyncio
Async Networking
Downloading A Web Page
Server
A Web Server
Best Practice
Summary
Chapter 19
Direct To The Hardware
Registers
Single-Cycle IO Block
Blinky Revisited
Example I - Events
Example II PAD - Pull, Drive and Schmitt
Two Processors
Watchdog and FlashNuke
Digging Deeper
Summary
Programming The Raspberry Pi Pico/W In C, Second Edition ISBN: 978-1871962796
Master the Raspberry Pi Pico ISBN: 978-1871962819
Raspberry Pi IoT in C, Second Edition ISBN: 978-1871962635
Programmer's Python: Everything is an Object, Second EditionISBN: 978-1871962741
Programmer's Python: Everything is DataISBN: 978-1871962595
Programmerโ€™s Python: Async ISBN: 978-1871962595
Raspberry Pi IoT in Python With GPIO Zero ISBN:9781871962666
Raspberry Pi IoT in C With Linux Drivers ISBN:9781871962642
Raspberry Pi IoT in Python With Linux Drivers ISBN:9781871962659
Applying C For The IoT With Linux ISBN: 978-1871962611
Fundamental C: Getting Closer To The Machineย  ISBN: 978-1871962604


๐Ÿ“œ SIMILAR VOLUMES


Get Started with MicroPython on Raspberr
โœ Gareth Halfacree, Ben Everard ๐Ÿ“‚ Library ๐Ÿ“… 2024 ๐Ÿ› Raspberry Pi Press ๐ŸŒ English

<div> <p style="font-weight: bold">Microcontrollers, like the RP2040 chip at the heart of Raspberry Pi Pico, are computers stripped back to their bare essentials.</p> <p>You don't use monitors or keyboards with them โ€” instead, you program them over USB to take their input from (and send their outp

Programming the Raspberry Pi Pico in C
โœ Harry Fairhead ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› I/O Press ๐ŸŒ English

<div> <p>The Raspberry Pi Pico is a remarkable microcontroller. It has a power and sophistication that would have been unthinkable just a short time ago. For the sort of jobs it is ideal for, it has plenty of processing power and enough memory to make tasks that would have once required careful pla

Programming The Raspberry Pi Pico In C
โœ Harry Fairhead ๐Ÿ“‚ Library ๐ŸŒ English

<p><span>There is a new edition of this book: </span><span>Programming The Raspberry Pi Pico/W In C, Second Edition</span><span><br><br>The </span><span>Raspberry Pi Pico</span><span> is a remarkable microcontroller. It has a power and sophistication that would have been unthinkable just a short tim

Get started with MicroPython on Raspberr
โœ Gareth Halfacree, Ben Everard ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› Raspberry Pi Trading Ltd ๐ŸŒ English

You might think of computers as things you stick on your desk and type on, and this is certainly one type of computer, but itโ€™s not the only type. In this book, weโ€™re looking at microcontrollers โ€“ small processing units with a bit of memory that are good at controlling other hardware. You probably h

Get started with MicroPython on Raspberr
โœ Gareth Halfacree; Ben Everard ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› Raspberry Pi Trading Ltd ๐ŸŒ English

THE OFFICIAL RASPBERRY PI PICO GUIDE Get started with MicroPython on Raspberry Pi Pico by Gareth Halfacree and Ben Everard Get started with MicroPython on Raspberry Pi Pico Microcontrollers, like RP2040 at the heart of Raspberry Pi Pico, are computers stripped back to their bare e

Raspberry Pi Pico und Pico W Schnelleins
โœ Thomas Brรผhlmann ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› mitp Verlags GmbH & Co. KG ๐ŸŒ German

<ul> <li> Alle technischen Daten und Anschlรผsse </li> <li> Einfache Codebeispiele in MicroPython </li> <li> Zahlreiche praktische Anwendungen </li> </ul> Dieses Buch ist ein kompakter und praktischer Leitfaden fรผr den Raspberry Pi Pico und Pico W inklusive der Programmierung mit MicroPython. Sie l