Develop innovative hardware-based projects in C
The Raspberry Pi has traditionally been programmed using Python. Although this is a very powerful language, many programmers may not be familiar with it. C on the other hand is perhaps the most commonly used programming language and all embedded microcontrollers can be programmed using it.
The C language is taught in most technical colleges and universities and almost all engineering students are familiar with using it with their projects. This book is about using the Raspberry Pi with C to develop a range of hardware-based projects. Two of the most popular C libraries, wiringPi and pigpio are used.
The book starts with an introduction to C and most students and newcomers will find this chapter invaluable. Many projects are provided in the book, including using Wi-Fi and Bluetooth to establish communication with smartphones.
Many sensor and hardware-based projects are included. Both wiringPi and pigpio libraries are used in all projects. Complete program listings are given with full explanations. All projects have been fully tested and work.
The following hardware-based projects are provided in the book:
Using sensors
Using LCDs
I²C and SPI buses
Serial communication
Multitasking
External and timer interrupts
Using Wi-Fi
Webservers
Communicating with smartphones
Using Bluetooth
Sending data to the cloud
Program listings of all Raspberry Pi projects developed in this book are available on the Elektor website. Readers can download and use these programs in their projects. Alternatively, they can customize them to suit their applications.
This book is about advanced programming of the Raspberry Pi computer using the Python programming language. The book explains in simple terms and with examples:
How to configure the Raspberry Pi computer;
How to install and use the Linux operating system and the desktop;
How to write advanced programs using the Python programming language;
How to use graphics in our programs;
How to develop hardware based projects using the Raspberry Pi.
The book starts with an introduction to the Raspberry Pi computer and covers the topics of purchasing all the necessary accessories and installing and operating the Linux operating system in command mode. The network interface of the RPi is explained in simple steps, demonstrating how the computer can be accessed remotely from a desktop or a laptop computer.
The remaining parts of the book cover the Python programming language in detail, including advanced topics such as operating system calls, multitasking, interprocess synchronization and interprocess communication techniques. The important topic of network programming using UDP and TCP protocols is described with working examples. The Tkinter graphical user interface module (GUI) is described in detail with example widgets and programs.
The last part of the book includes hardware projects based on using the advanced programming topics such as multitasking and interprocess communication techniques. All the projects given in the book have been fully tested and are working. Complete program listings of all projects are provided with detailed explanations.
ModbusRTU and ModbusTCP examples with the Arduino Uno and ESP8266
Introduction to PLC programming with OpenPLC, the first fully open source Programmable Logic Controller on the Raspberry Pi, and Modbus examples with Arduino Uno and ESP8266
PLC programming is very common in industry and home automation. This book describes how the Raspberry Pi 4 can be used as a Programmable Logic Controller. Before taking you into the programming, the author starts with the software installation on the Raspberry Pi and the PLC editor on the PC, followed by a description of the hardware.
You'll then find interesting examples in the different programming languages complying with the IEC 61131-3 standard. This manual also explains in detail how to use the PLC editor and how to load and execute the programs on the Raspberry Pi. All IEC languages are explained with examples, starting with LD (Ladder Diagram) over ST (Structured Control Language) to SFC (Special Function Chart). All examples can be downloaded from the author's website.
Networking gets thorough attention too. The Arduino Uno and the ESP8266 are programmed as ModbusRTU or ModbusTCP modules to get access to external peripherals, reading sensors and switching electrical loads. I/O circuits complying with the 24 V industry standard may also be of interest for the reader.
The book ends with an overview of commands for ST and LD. After reading the book, the reader will be able to create his own controllers with the Raspberry Pi.
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
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
Learn programming for Alexa devices, extend it to smart home devices and control the Raspberry Pi
The book is split into two parts: the first part covers creating Alexa skills and the second part, designing Internet of Things and Smart Home devices using a Raspberry Pi.
The first chapters describe the process of Alexa communication, opening an Amazon account and creating a skill for free. The operation of an Alexa skill and terminology such as utterances, intents, slots, and conversations are explained. Debugging your code, saving user data between sessions, S3 data storage and Dynamo DB database are discussed.
In-skill purchasing, enabling users to buy items for your skill as well as certification and publication is outlined. Creating skills using AWS Lambda and ASK CLI is covered, along with the Visual Studio code editor and local debugging. Also covered is the process of designing skills for visual displays and interactive touch designs using Alexa Presentation Language.
The second half of the book starts by creating a Raspberry Pi IoT 'thing' to control a robot from your Alexa device. This covers security issues and methods of sending and receiving MQTT messages between an Alexa device and the Raspberry Pi.
Creating a smart home device is described including forming a security profile, linking with Amazon, and writing a Lambda function that gets triggered by an Alexa skill. Device discovery and on/off control is demonstrated.
Next, readers discover how to control a smart home Raspberry Pi display from an Alexa skill using Simple Queue Service (SQS) messaging to switch the display on and off or change the color.
A node-RED design is discussed from the basic user interface right up to configuring MQTT nodes. MQTT messages sent from a user are displayed on a Raspberry Pi.
A chapter discusses sending a proactive notification such as a weather alert from a Raspberry Pi to an Alexa device. The book concludes by explaining how to create Raspberry Pi as a stand-alone Alexa device.
The Raspberry Pi PoE+ Injector adds Power-over-Ethernet (PoE) functionality to a single port of a non-PoE Ethernet switch, delivering both power and data through one Ethernet cable. It provides a plug-and-play, cost-effective solution for incrementally introducing PoE capability into existing Ethernet networks.
The PoE+ Injector is a single-port, 30 W device suitable for powering equipment compliant with IEEE 802.3af and 802.3at standards, including all generations of Raspberry Pi PoE HATs. It supports network pass-through speeds of 10/100/1000 Mbps.
Note: A separate IEC mains cable is required for operation (not included).
Specifications
Data rate
10/100/1000 Mbps
Input voltage
100 to 240 V AC
Output power
30 W
Power output on pins
4/5 (+), 7/8 (–)
Nominal output voltage
55 V DC
Data connectors
Shielded RJ-45, EIA 568A and 568B
Power connector
IEC c13 mains power input (not included)
Storage humidity
Maximum 95%, non-condensing
Operating altitude
–300 m to 3000 m
Operating ambient temperature
10°C to +50°C
Dimensions
159 x 51.8 x 33.5 mm
Downloads
Datasheet
Thanks to its six sturdy slots, Breakout Garden enables the users to simply plug and play with various tiny breakout board.
Just insert one or more boards into the slots in the Breakout Garden HAT and you’re ready to go. The mini breakouts feel secure enough in the edge-connector slots and are very unlikely to fall out.
There are a number of useful pins along the top of Breakout Garden, which lets you connect other devices and integrate them into your project.
You shouldn't be worried if you insert a board the wrong way thanks to provided reverse polarity protection. It doesn't matter which slot you use for each breakout either, because the I²C address of the breakout will be recognised by the software and it'll detect them correctly in case you move them around.
Features
Six sturdy edge-connector slots for Pimoroni breakouts
0.1” pitch, 5 pin connectors
Broken-out pins (1 × 10 strip of male header included)
Standoffs (M2.5, 10 mm height) included to hold your Breakout Garden securely
Reverse polarity protection (built into breakouts)
HAT format board
Compatible with Raspberry Pi 3 B+, 3, 2, B+, A+, Zero, and Zero W
It's suggested using the included standoffs to attache Breakout Garden to your Raspberry Pi.
Software
Breakout Garden doesn't require any software of its own, but each breakout you use will need a Python library. On the Breakout Garden GitHub page you'll find an automatic installer, which will install the appropriate software for a given breakout. There are also some examples that show you what else you can do with Breakout Garden.
ModbusRTU and ModbusTCP examples with the Arduino Uno and ESP8266
Introduction to PLC programming with OpenPLC, the first fully open source Programmable Logic Controller on the Raspberry Pi, and Modbus examples with Arduino Uno and ESP8266
PLC programming is very common in industry and home automation. This book describes how the Raspberry Pi 4 can be used as a Programmable Logic Controller. Before taking you into the programming, the author starts with the software installation on the Raspberry Pi and the PLC editor on the PC, followed by a description of the hardware.
You'll then find interesting examples in the different programming languages complying with the IEC 61131-3 standard. This manual also explains in detail how to use the PLC editor and how to load and execute the programs on the Raspberry Pi. All IEC languages are explained with examples, starting with LD (Ladder Diagram) over ST (Structured Control Language) to SFC (Special Function Chart). All examples can be downloaded from the author's website.
Networking gets thorough attention too. The Arduino Uno and the ESP8266 are programmed as ModbusRTU or ModbusTCP modules to get access to external peripherals, reading sensors and switching electrical loads. I/O circuits complying with the 24 V industry standard may also be of interest for the reader.
The book ends with an overview of commands for ST and LD. After reading the book, the reader will be able to create his own controllers with the Raspberry Pi.
Program, build, and master over 60 projects with Python
The Raspberry Pi 5 is the latest single-board computer from the Raspberry Pi Foundation. It can be used in many applications, such as in audio and video media centers, as a desktop computer, in industrial controllers, robotics, and in many domestic and commercial applications. In addition to the well-established features found in other Raspberry Pi computers, the Raspberry Pi 5 offers Wi-Fi and Bluetooth (classic and BLE), which makes it a perfect match for IoT as well as in remote and Internet-based control and monitoring applications. It is now possible to develop many real-time projects such as audio digital signal processing, real-time digital filtering, real-time digital control and monitoring, and many other real-time operations using this tiny powerhouse.
The book starts with an introduction to the Raspberry Pi 5 computer and covers the important topics of accessing the computer locally and remotely. Use of the console language commands as well as accessing and using the desktop GUI are described with working examples. The remaining parts of the book cover many Raspberry Pi 5-based hardware projects using components and devices such as
LEDs and buzzers
LCDs
Ultrasonic sensors
Temperature and atmospheric pressure sensors
The Sense HAT
Camera modules
Example projects are given using Wi-Fi and Bluetooth modules to send and receive data from smartphones and PCs, and sending real-time temperature and atmospheric pressure data to the cloud.
All projects given in the book have been fully tested for correct operation. Only basic programming and electronics experience are required to follow the projects. Brief descriptions, block diagrams, detailed circuit diagrams, and full Python program listings are given for all projects described.