Gør som tusindvis af andre bogelskere
Tilmeld dig nyhedsbrevet og få gode tilbud og inspiration til din næste læsning.
Ved tilmelding accepterer du vores persondatapolitik.Du kan altid afmelde dig igen.
The Raspberry Pi makes an ideal match for the Internet of Things. To put it to good use in IoT you need two areas of expertise, electronics and programming, and this presents a barrier to getting started. However, there is an overlooked route that can provide a shortcut. Pi OS, the Raspberry Pi's operating system, is Linux- based and Linux drivers are available for many off-the-shelf IoT devices. Using Linux drivers saves the effort of implementing low-level code and has the advantage of working the same on all versions of the Pi, including the recently launched Pi 5 which isn't hardware compatible with earlier versions. This Second Edition has been updated to cover the Pi 5 and also the Pi Zero 2W, which is an ideal candidate for use in IoT projects. It has also been updated to use the latest versions of Pi OS, Bullseye and Bookworm. Throughout this book you will find a practical approach to understanding electronic circuits and datasheets and translating this to code, specifically using Python and VS Code. The first IoT program anyone writes is "Blinky" to flash an LED and this book is no exception, but it might not be quite what you expect. Instead of using a GPIO line driver, it uses the Linux LED driver. The GPIO isn't left out, however, as the next three chapters focus on its use via the GPIO character driver, which replaces the old, but very common, sysfs GPIO driver. This is the way to do modern GPIO. A key component in any look at Linux and its relationship to hardware is the relatively new Device Tree. While most accounts of this resource are aimed at device driver writers, this one is aimed at device driver users and to this end we look at several devices, including the DHT22 temperature and humidity sensor. After a brief detour into some basic electronics, we see how Pulse Width Modulation is supported via a driver. From here we tackle the two standard buses, I2C and SPI, first going through the basics and then looking at the two attempts to impose a higher organization, the hardware monitoring system, hwmon, and Industrial I/O, IIO. The 1-Wire bus is also covered in detail. The final chapter takes things to the next level and considers creating your own custom overlays by writing fragments to the device tree. Harry Fairhead's other books include Applying C For The IoT With Linux; Programming the Raspberry Pi Pico/W, 2nd Ed, Raspberry Pi IoT in C, 3rd Ed, Raspberry Pi IoT in C Using Linux Drivers, 2nd Ed, Programming the Raspberry Pi Pico/W, 2nd Ed and Programming the ESP32 in MicroPython. 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.
Writing a C extension for Python is good for fun and profit! The fun part is that adding Python to C gives you so much more power and a deeper understanding of how Python works. The internals of Python are worth knowing about because they suggest new approaches to other problems. As well as being interesting, it is also a valuable skill. Extending & Embedding Python Using C tells you everything you need to know about the C API, which is what you use to create an extension. It is essentially the Python runtime and so exploring it tells you a lot about Python. You don't need to be an expert Python programmer to create an extension, but it helps. As you are going to be writing mostly C code, programming in C is a more important skill for this task. While you don't have to be a C expert, you do need to be reasonably competent and C aficionados will enjoy finding out about some of the clever techniques in use in the C API. Extending Python is a way of bringing any C-based application or library to a much wider audience. Converting Python functions into C functions is also a way of speeding things up. Moreover, you can provide access to hardware or system features that are usually inaccessible by creating an extension. The final chapter explains how to convert the skills you have gained in creating a Python extension to embed Python in a C program. This is a less common requirement, but it has some interesting advantages and possibilities and once you know how to create a Python extension it is easy. Mike James has a BSc in Physics, an MSc in Mathematics, a PhD in Computer Science and in a long career as a programmer he has mastered many programming languages. He is the founder and chief editor of I-Programmer, the online magazine written by programmers for programmers and the author of dozens of books. His previous three books on Python, Programmer's Python: Everything Is An Object, Programmer's Python: Everything Is Data and Programmer's Python: Async form a set of "Something Completely Different" books that look at what makes Python special and sets it apart from other programming languages. While not part of the series, this book shares the same overall philosophy.
Second Edition Now Available.The Raspberry Pi makes an ideal match for the Internet of Things. But to put it to good use in IoT you need two areas of expertise, electronics and programming and because of the way hardware and software engineering tend to occupy separate niches you may need help with combining the two. This book teaches you to think like an IoT programmer.In Raspberry Pi IoT in C you will find a practical approach to understanding electronic circuits and datasheets and translating this to code, specifically using the C programming language. The main reason for choosing C is speed, a crucial factor when you are writing programs to communicate with the outside world. If you are familiar with another programming language, C shouldn't be hard to pick up. Here it is used in conjunction with NetBeans and with the bcm2835 library.The main idea in this book is to not simply install a driver, but to work directly with the hardware. So rather than using Raspberry Pi HATs or other expansion boards we use the Pi's GPIO (General Purpose Input Output) and connect off-the-shelf sensors. If you want to know how to work with the GPIO lines directly, how to work with near realtime Linux and generally take control of the Pi this is the book you need. It explains how to use the standard bus types - SPI, I2C, PWM - and with custom protocols including an in-depth exposition of the 1-wire bus. You will also discover how to put the Internet into the IoT using sockets and the low cost ESP8266.After reading this book you will be in a better position to tackle interfacing anything-with-anything without the need for custom drivers and prebuilt hardware modules.Having written a Blinky program to check that everything we need is installed and working we move on to exploring the basics of using the GPIO and also master memory mapping, pulse width modulation and other more sophisticated bus types. From here we can start connecting sensors, which is a core requirement for IoT. First we'll meet the ubiquitous I2C bus, next we'll implement a custom protocol for a one-wire bus, and eventually we'll add eight channels of 12-bit AtoD with the SPI bus, which involves overcoming some subtle difficulties. Next we look at the traditional serial interface how to use it to communicate with other devices. This paves the way for getting the Pi on the web - after all this is a book about the Internet of Things -using first a USB WiFi adapter and sockets and then the low cost ESP8266, which is particularly useful with the Pi Zero which has only one USB port. Having transformed the Pi into both a web client and a web server we can then use them to exchange information.
Tilmeld dig nyhedsbrevet og få gode tilbud og inspiration til din næste læsning.
Ved tilmelding accepterer du vores persondatapolitik.