Raspberry Pi IoT In C Using Linux Drivers Second Edition

Errata None

Program Listings

Resources

First Edition Resources

DriverC2E360

ISBN: 978-1871962857

Buy from: Amazon

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. These provide a very easy-to-use, high-level way of working. The problem that this book solves is that there is very little documentation to help you get started. In it Harry Fairhead explains the principles so that you can tackle new devices and he also guides you through using external hardware via standard Linux drivers. Throughout this book you will find a practical approach to understanding electronic circuits and datasheets and translating this to code, specifically using the C programming language. 

This second edition was prompted by the advent of the Pi 5, welcomed as the fastest member of the Raspberry Pi family. What came as a shock is that, from the point of view of IoT, it is incompatible with all other Raspberry Pis due to the use of a custom chip. Luckily, although the Pi 5 cannot work with the standard IoT libraries it does behave in the same way under Linux drivers and so this new book does include the Pi 5 on an equal footing. Coverage also includes the Pi Zero 2W, which has a quad-core chip making it more capable than both the original Pi Zero and the WiFi-enabled Pi ZeroW.

After a quick tour of the Raspberry Pi ecosystem, Visual Studio Code (VS Code) and how it can be used to develop remotely, is introduced. 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 it uses the Linux LED driver – no hardware and no fuss. The GPIO isn’t left out, however, as the next three chapters focus on its use via the new GPIO character driver. A key component in any look at Linux and its relationship to hardware is the 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 the DHT22 temperature and humidity driver. 

After a brief detour into some basic electronics, we look at Pulse Width Modulation supported via a driver rather than needing to be implemented using the GPIO. 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. We also look at the 1-Wire bus. 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 has worked with microprocessors and electronics in general for many years and is an enthusiastic proponent of the IoT. C is his programming language of choice and he has written several books on programming the Raspberry Pi and other devices in an IOT context, including Raspberry Pi IoT In C, 3rd EditionProgramming the Raspberry Pi Pico/W in C, 2nd Edition, Programming the ESP32 in MicroPython and Fundamental C: Getting Closer To The Machine.

Paperback

  • Publisher ‏ : ‎ I/O Press (January 27, 2024)
  • Language ‏ : ‎ English
  • Paperback ‏ : ‎ 288 pages
  • ISBN-10 ‏ : ‎ 1871962854
  • ISBN-13 ‏ : ‎ 978-1871962857
  • Item Weight ‏ : ‎ 1.4 pounds
  • Dimensions ‏ : ‎ 7 x 0.65 x 10 inches

Kindle

  • ASIN ‏ : ‎ B0CTGF8XQ5
  • Publisher ‏ : ‎ I/O Press; 2nd edition (January 27, 2024)
  • Publication date ‏ : ‎ January 27, 2024
  • Language ‏ : ‎ English
  • File size ‏ : ‎ 15744 KB

 

 Hardback

  • Publisher ‏ : ‎ I/O Press (January 27, 2024)
  • Language ‏ : ‎ English
  • Hardcover ‏ : ‎ 288 pages
  • ISBN-10 ‏ : ‎ 1871962161
  • ISBN-13 ‏ : ‎ 978-1871962161
  • Item Weight ‏ : ‎ 1.4 pounds
  • Dimensions ‏ : ‎ 7 x 0.84 x 10 inches