Most people are increasingly confronted with the applications of Artificial Intelligence (AI). Music or video ratings, navigation systems, shopping advice, etc. are based on methods that can be attributed to this field.
The term Artificial Intelligence was coined in 1956 at an international conference known as the Dartmouth Summer Research Project. One basic approach was to model the functioning of the human brain and to construct advanced computer systems based on this. Soon it should be clear how the human mind works. Transferring it to a machine was considered only a small step. This notion proved to be a bit too optimistic. Nevertheless, the progress of modern AI, or rather its subspecialty called Machine Learning (ML), can no longer be denied.
In this book, several different systems will be used to get to know the methods of machine learning in more detail. In addition to the PC, both the Raspberry Pi and the Maixduino will demonstrate their capabilities in the individual projects. In addition to applications such as object and facial recognition, practical systems such as bottle detectors, person counters, or a “talking eye” will also be created.
The latter is capable of acoustically describing objects or faces that are detected automatically. For example, if a vehicle is in the field of view of the connected camera, the information 'I see a car!' is output via electronically generated speech. Such devices are highly interesting examples of how, for example, blind or severely visually impaired people can also benefit from AI systems.
This book is about teaching the Python programming language using the Raspberry Pi 4 computer. The book makes an introduction to Raspberry Pi 4 and then teaches Python with the topics: variables, strings, arrays, matrices, tuples, lists, dictionaries, user functions, flow of control, printing, keyboard input, graphics, GUI, object oriented programming and many more topics.
The book is aimed for beginners, students, practising engineers, hobbyists, and for anyone else who may want to learn to program in Python.
The book includes many example programs and case studies. All the example programs and case studies have been tested fully by the author and are all working. The example programs aim to teach the various programming concepts of Python. The case studies cover the use of Python in the analysis and design of electronic circuits. Some of the case study topics are:
Resistor colour code identification
Resistive potential divider circuits
Resistive attenuator design
Zener diode voltage regulator design
RC and RLC transient circuits
Circuit frequency response
Saving data on external memory stick
Mesh and node circuit analysis using matrices
Resonance in RLC circuits
Transistor Biasing analysis
Transistor amplifier design
Design of active filters
Interfacing hardware with GPIO, I²C and SPI
Using Wi-Fi with Python and TCP/IP and UDP programs
Using Bluetooth from Python
Full program listings of all the programs used in the book are available at the Elektor website of the book. Readers should be able just to copy and use these programs in their Raspberry Pi projects without any modifications.
Features
1.54" IPS TFT display with 240x240 resolution that can show text or video
Stereo speaker ports for audio playback - either text-to-speech, alerts or for creating a voice assistant.
Stereo headphone out for audio playback through a stereo system, headphones, or powered speakers.
Stereo microphone input - perfect for making your very own smart home assistants
Two 3-pin JST STEMMA connectors that can be used to connect more buttons, a relay, or even some NeoPixels!
STEMMA QT plug-and-play I2C port can be used with any of Adafruits 50+ I2C STEMMA QT boards or can be used to connect to Grove I²C devices with an adapter cable.
5-Way Joystick + Button for user interface and control.
Three RGB DotStar LEDs for colorful LED feedback.
The STEMMA QT port means you can attach heat image sensors like the Panasonic Grid-EYE or MLX90640. Heat-Sensitive cameras can be used as a person detector, even in the dark! An external accelerometer can be attached for gesture or vibration sensing such as machinery/industrial predictive maintenance projects
Please note: A Raspberry Pi 4 is not included.
Raspberry Pi DAC+ (formerly known as IQaudio DAC+) is a high-performance audio HAT designed for any Raspberry Pi with a 40-pin GPIO header. Equipped with the Texas Instruments PCM5122 DAC, it delivers crystal-clear stereo analogue audio through a pair of phono (RCA) connectors.
No external power is needed – the DAC+ connects directly to the Raspberry Pi’s GPIO header without requiring soldering or cables.
Features
Power LED
Analogue audio out (0-2 V RMS) via panel-mounted stereo
phono (RCA) sockets with MUTE signal (headphone detect)
Dedicated headphone amplifier, output via 3.5 mm panel-mounted barrel socket
40-pin pass-through GPIO header
HAT EEPROM write-enabled
Downloads
Datasheet
Multitasking and multiprocessing have become a very important topic in microcontroller-based systems, namely in complex commercial, domestic, and industrial automation applications. As the complexity of projects grows, more functionalities are demanded from the projects. Such projects require the use of multiple inter-related tasks running on the same system and sharing the available resources, such as the CPU, memory, and input-output ports. As a result of this, the importance of multitasking operations in microcontroller-based applications has grown steadily over the last few years. Many complex automation projects now make use of some form of a multitasking kernel.
This book is project-based and its main aim is to teach the basic features of multitasking using the Python 3 programming language on Raspberry Pi. Many fully tested projects are provided in the book using the multitasking modules of Python. Each project is described fully and in detail. Complete program listings are given for each project. Readers should be able to use the projects as they are, or modify them to suit their own needs.
The following Python multitasking modules have been described and used in the projects:
Fork
Thread
Threading
Subprocess
Multiprocessing
The book includes simple multitasking projects such as independently controlling multiple LEDs, to more complex multitasking projects such as on/off temperature control, traffic lights control, 2-digit, and 4-digit 7-segment LED event counter, reaction timer, stepper motor control, keypad based projects, car park controller, and many more. The fundamental multitasking concepts such as process synchronization, process communication, and memory sharing techniques have been described in projects concerning event flags, queues, semaphores, values, and so on.
Specifications
RP2040 microcontroller chip designed by Raspberry Pi in the UK
Dual-core ARM Cortex M0+ processor, with a flexible clock running up to 133 MHz
264 kB SRAM, and 2 MB on-board Flash memory
Castellated module allows soldering directly to carrier boards
USB 1.1 host and device support
Energy-efficient sleep and dormant modes
Drag and drop programming using mass storage via USB
26x multifunction GPIO pins
2x SPI, 2x I²C, 2x UART, 3x 12-bit ADC, 16x controllable PWM channels
On-chip accurate clock and timer
Temperature sensor
On-chip accelerated floating point libraries
8x programmable IO (PIO) state machines for custom peripherals
Why a Raspberry Pi Pico?
Designing your own microcontroller instead of buying an existing one brings a number of advantages. According to Raspberry Pi itself, not one of the existing products available for this comes close to their price/performance ratio.
This Raspberry Pi Pico has also given Raspberry Pi the ability to add some innovative and powerful features of their own. These features are not available anywhere else.
A third reason is that the Raspberry Pi Pico has given Raspberry Pi the ability to create powerful software around the product. Surrounding this software stack is an extensive documentation set. The software and documentation meet the high standard of Raspberry Pi's core products (such as the Raspberry Pi 400, Pi 4 Model B and Pi 3 Model A+).
Who is this microcontroller for?
The Raspberry Pi Pico is suitable for both advanced and novice users. From controlling a display to controlling many different devices that you use every day. Automating everyday operations is made possible by this technology.
Beginner users
The Raspberry Pi Pico is programmable in the C and MicroPython languages and is customizable for a wide range of devices. In addition, the Pico is as easy to use as dragging and dropping files. This makes this microcontroller ideally suited for the novice user.
Advanced users
For advanced users, it is possible to take advantage of the Pico's extensive peripherals. The peripherals include the SPI, I²C, and eight programmable I/O (PIO)-state machines.
What makes the Raspberry Pi Pico unique?
What's unique about the Pico is that it was developed by Raspberry Pi itself. The RP2040 features a dual-core Arm Cortex-M0+ processor with 264 KB of internal RAM and support for up to 16 MB of off-chip Flash.
The Raspberry Pi Pico is unique for several reasons:
The product has the highest price/quality ratio in the microcontroller board market.
The Raspberry Pi Pico has been developed by Raspberry Pi itself.
The software stack surrounding this product is of high quality and comes paired with a comprehensive documentation set.
Technical Specifications Dual ARM Cortex-M0+ @ 133 MHz 264 kB on-chip SRAM in six independent banks Support for up to 16 MB of off-chip Flash memory via dedicated QSPI bus DMA controller Fully-connected AHB crossbar Interpolator and integer divider peripherals On-chip programmable LDO to generate core voltage 2x on-chip PLLs to generate USB and core clocks 30x GPIO pins, 4 of which can be used as analogue inputs Peripherals 2x UARTs 2x SPI controllers 2x I²C controllers 16x PWM channels USB 1.1 controller and PHY, with host and device support 8x PIO state machines What you'll get 10x bare RP2040 chips
Build robust, intelligent machines that combine Raspberry Pi computing power with LEGO components.
The Raspberry Pi Build HAT provides four connectors for LEGO Technic motors and sensors from the SPIKE Portfolio. The available sensors include a distance sensor, a color sensor, and a versatile force sensor. The angular motors come in a range of sizes and include integrated encoders that can be queried to find their position.
The Build HAT fits all Raspberry Pi computers with a 40-pin GPIO header, including – with the addition of a ribbon cable or other extension device — Raspberry Pi 400. Connected LEGO Technic devices can easily be controlled in Python, alongside standard Raspberry Pi accessories such as a camera module.
Features
Controls up to 4 motors and sensors
Powers the Raspberry Pi (when used with a suitable external PSU)
Easy to use from Python on the Raspberry Pi
The Raspberry Pi Pico 2 is a new microcontroller board from the Raspberry Pi Foundation, based on the RP2350. It features a higher core clock speed, double the on-chip SRAM, double the on-board flash memory, more powerful Arm cores, optional RISC-V cores, new security features, and upgraded interfacing capabilities. The Raspberry Pi Pico 2 offers a significant boost in performance and features while maintaining hardware and software compatibility with earlier members of the Raspberry Pi Pico series.
The RP2350 provides a comprehensive security architecture built around Arm TrustZone for Cortex-M. It incorporates signed boot, 8 KB of antifuse OTP for key storage, SHA-256 acceleration, a hardware TRNG, and fast glitch detectors.
The unique dual-core, dual-architecture capability of the RP2350 allows users to choose between a pair of industry-standard Arm Cortex-M33 cores and a pair of open-hardware Hazard3 RISC-V cores. Programmable in C/C++ and Python, and supported by detailed documentation, the Raspberry Pi Pico 2 is the ideal microcontroller board for both enthusiasts and professional developers.
Specifications
CPU
Dual Arm Cortex-M33 or dual RISC-V Hazard3 processors @ 150 MHz
Memory
520 KB on-chip SRAM; 4 MB on-board QSPI flash
Interfaces
26 multi-purpose GPIO pins, including 4 that can be used for AD
Peripherals
2x UART
2x SPI controllers
2x I²C controllers
24x PWM channels
1x USB 1.1 controller and PHY, with host and device support
12x PIO state machines
Input power
1.8-5.5 V DC
Dimensions
21 x 51 mm
Downloads
Datasheet (Pico 2)
Datasheet (RP2350)
The Raspberry Pi Debug Probe is an all-in-one USB-to-debug kit that provides all the necessary hardware and cables for easy, solderless, plug-and-play debugging.
It features both a processor serial debug interface (by default the ARM Serial Wire Debug interface, but other interfaces can be supported) and an industry-standard UART interface. Both interfaces use the Raspberry Pi 3-pin debug connector.
It is designed to make it easy to debug and program Raspberry Pi Pico and RP2040 with a range of host platforms including Windows, Mac, and typical Linux computers.
While designed for use with Raspberry Pi products, the Debug Probe provides standard UART and CMSIS-DAP interfaces over USB, so it can also be used with other processors, or even just as a USB-to-UART cable. It works with OpenOCD and other tools that support CMSIS-DAP.
The Debug Probe is based on Raspberry Pi Pico hardware and runs the open source Raspberry Pi Pico Probe software. The firmware is updated in the same way as Raspberry Pi Pico firmware, so it is easy to keep the unit up to date with the latest firmware, or to use custom firmware.
Features
USB to ARM Serial Wire Debug (SWD) port
USB to UART bridge
Compatible with the CMSIS-DAP standard
Works with OpenOCD and other tools supporting CMSIS-DAP
Open source, easily upgradeable firmware
Specifications
Dimensions: 22 x 32 mm
Nominal I/O voltage: 3.3 V
Operating temperature: -20°C to +70°C
Included
1x Raspberry Pi Debug Probe
1x Plastic case
1x USB cable
3x Debug cables
3-pin JST connector to 3-pin JST connector cable
3-pin JST connector to 0.1-inch header (female)
3-pin JST connector to 0.1-inch header (male)
Downloads
Datasheet
3-pin Debug Connector
Schematics
Diagram
Latest Firmware
The Raspberry Pi Zero W extends the Raspberry Pi Zero family. The Raspberry Pi Zero W has all the functionality of the original Raspberry Pi Zero, but comes with added connectivity consisting of:
802.11 b/g/n wireless LAN
Bluetooth 4.1
Bluetooth Low Energy (BLE)
Other Features
1 GHz, single-core CPU
512 MB RAM
Mini HDMI and USB On-The-Go ports
Micro-USB power
HAT-compatible 40-pin header
Composite video and reset headers
CSI camera connector
Downloads
Mechanical Drawing
Schematics
Raspberry Pi Pico W is a microcontroller board based on the Raspberry Pi RP2040 microcontroller chip.
The RP2040 microcontroller chip ('Raspberry Silicon') offers a dual-core ARM Cortex-M0+ processor (133 MHz), 256 KB RAM, 30 GPIO pins, and many other interface options. In addition, there is 2 MB of on-board QSPI flash memory for code and data storage.
Raspberry Pi Pico W has been designed to be a low cost yet flexible development platform for RP2040 with a 2.4 GHz wireless interface using an Infineon CYW43439. The wireless interface is connected via SPI to the RP2040.
Features of Pico W
RP2040 microcontroller with 2 MB of flash memory
On-board single-band 2.4 GHz wireless interfaces (802.11n)
Micro USB B port for power and data (and for reprogramming the flash)
40 pin 21 x 51 mm 'DIP' style 1 mm thick PCB with 0.1' through-hole pins also with edge castellations
Exposes 26 multi-function 3.3 V general purpose I/O (GPIO)
23 GPIO are digital-only, with three also being ADC capable
Can be surface mounted as a module
3-pin ARM serial wire debug (SWD) port
Simple yet highly flexible power supply architecture
Various options for easily powering the unit from micro USB, external supplies or batteries
High quality, low cost, high availability
Comprehensive SDK, software examples and documentation
Features of the RP2040 microcontroller
Dual-core cortex M0+ at up to 133 MHz
On-chip PLL allows variable core frequency
264 kByte multi-bank high performance SRAM
External Quad-SPI Flash with eXecute In Place (XIP) and 16 kByte on-chip cache
High performance full-crossbar bus fabric
On-board USB1.1 (device or host)
30 multi-function general purpose I/O (four can be used for ADC)
1.8-3.3 V I/O voltage
12-bit 500 ksps analogue to digital converter (ADC)
Various digital peripherals
2x UART, 2x I²C, 2x SPI, 16x PWM channels
1x timer with 4 alarms, 1x real time clock
2x programmable I/O (PIO) blocks, 8 state machines in total
Flexible, user-programmable high-speed I/O
Can emulate interfaces such as SD card and VGA
Note: Raspberry Pi Pico W I/O voltage is fixed at 3.3 V.
Downloads
Datasheet
Specifications of 3-pin Debug Connector