Название: Automate Your Home Using Go: Build a Personal Data Center with Raspberry Pi, Docker, Prometheus, and Grafana Автор: Ricardo Gerardi, Mike Riley Издательство: Pragmatic Bookshelf Год: August 2024 (v.P1.0) Страниц: 275 Язык: английский Формат: pdf, epub, mobi Размер: 10.1 MB
Take control of your home and your data with the power of the Go programming language. Build extraordinary and robust home automation solutions that rival much more expensive, closed commercial alternatives, using the same tools found in high-end enterprise computing environments. Best-selling Pragmatic Bookshelf authors Ricardo Gerardi and Mike Riley show how you can use inexpensive Raspberry Pi hardware and excellent, open source Go-based software tools like Prometheus and Grafana to create your own personal data center. Using the step-by-step examples in the book, build useful home automation projects that you can use as a blueprint for your own custom projects.
With just a Raspberry Pi and the Go programming language, build your own personal data center that coordinates and manages your home automation, leveraging the same high-powered software used by large enterprises. The projects in this book are easy to assemble, no soldering or electrical engineering expertise required.
Build a temperature monitor that can send alerts any time defined thresholds are exceeded and report the temperature readings on a time-based series chart. Change the color of lights to visually indicate the current outdoor weather status. Create a networked motion detector that triggers an alert any time motion is detected, such as a door opening or closing, a pet wandering around, or deliveries or visitors arriving on your front porch. Even have these triggers initiate a more complex Go-based automation sequence. Integrate a small, high-resolution camera into a bird feeder that takes excellent, up-close photos whenever a bird perches at the feeder, and broadcasts them to your Discord server where your family and friends can see these wildlife captures in real time.
Control your home with hardware you configure, and manage it with Go code that you create and modify any time you want to enhance your home automation capabilities.
What You Need:
Readers should be familiar with the Go programming language and have working knowledge of Linux. Free, open source Go-based libraries and utilities are available for download from the Internet. Readers will also need a working Raspberry Pi 3+ or higher, and a Pi Pico W microcontroller. Several other inexpensive electronic parts (touch sensors, motion detectors) are also needed for some of the projects. A Philips Hue base lighting system is also needed for the weather monitor project.
Our objective for the book was to avoid as much electrical engineering and wiring as possible. You can complete each project in this book without ever picking up a soldering gun. While it’s commendable to use one for appropriate cases, this book focuses more on software than hardware. We also didn’t want to have hardware components fail as a result of poor soldering or confusing wiring diagrams, so we opted to make the hardware configuration for these projects as simple as possible to avoid any frustration or expensive mistakes.
As you gain more confidence in your home automation skills using Go, we recommend expanding your horizons with a good basic electronics tutorial and a quality soldering gun. We also recommend continuing to advance your newly acquired skills by experimenting with a variety of electric components found on popular electronics project websites.
Who This Book Is For: This book is for developers familiar with the Go programming language who want to do more with it than just the usual integration and microservices that Go is typically used for. It is also for home automation tinkerers and electronics hobbyists interested in learning how a language like Go can be more powerful and make software projects easier to build and maintain, especially when compared to other languages used in home automation like Perl and Python.
In Chapter 1, Getting Started , you’ll review the hardware and software requirements necessary to follow along with building the projects in this book. You’ll also learn how to configure some of the software prerequisites and how to select and configure a code editor to write your Go programs. Next, in Chapter 2, Building a REST API Server , you’ll use the Go programming language to build a basic REST API service and deploy it on a Raspberry Pi. You’ll use this API server later in the book to send notifications from your home automation projects. In Chapter 3, Deploying Your Personal Data Center , you’ll deploy your personal data center by assembling and configuring software on a Raspberry Pi that includes the key components for the enterprise-level monitoring and alerting environment. You’ll learn how to build containers, capture and report on metrics, and pick up some of our own best practices experiences working with these tools along the way. Then, in Chapter 4, Networking a Temperature Monitor , you’ll build your first automation project: a networked temperature monitor that uses a tiny Raspberry Pi Pico W and TinyGo to gather the ambient temperature and send it to your central monitoring application running on your personal data center. In Chapter 5, Checking the (Garage) Door , you’ll build a garage door checker that uses a magnetic switch sensor and the Raspberry Pi Zero 2 GPIO interface to report whether your garage door is open or closed. Next, in Chapter 6, Lighting the Weather , you’ll design a dynamic lighting solution that offers a unique way to visually identify the current outdoor temperature in your area by controlling the colors on a Hue lighting system via APIs. As the final project, in Chapter 7, Watching the Birds , you’ll discover how to build a custom bird feeder that captures high-resolution images of birds—and other wildlife—perched at the feeder, and send those images as attachments to your own designated Discord server channel. Finally, in Chapter 8, Go Build , you’ll review some ideas on how to further improve your skills and how to use the knowledge and experience acquired in this book in other projects.