Creative DIY Microcontroller Projects with TinyGo and WebAssembly
Book information
Description
While often considered a fast and compact programming language, Go usually creates large executables that are difficult to run on low-memory or low-powered devices such as microcontrollers or IoT. TinyGo is a new compiler that allows developers to compile their programs for such low-powered devices. As TinyGo supports all the standard features of the Go programming language, you won't have to tweak the code to fit on the microcontroller. This book is a hands-on guide packed full of interesting DIY projects that will show you how to build embedded applications. You will learn how to program sensors and work with microcontrollers such as Arduino UNO and Arduino Nano IoT 33. The chapters that follow will show you how to develop multiple real-world embedded projects using a variety of popular devices such as LEDs, 7-segment displays, and timers. Next, you will progress to build interactive prototypes such as a traffic lights system, touchless hand wash timer, and more. As you advance, you'll create an IoT prototype of a weather alert system and display those alerts on the TinyGo WASM dashboard. Finally, you will build a home automation project that displays stats on the TinyGo WASM dashboard. By the end of this microcontroller book, you will be equipped with the skills you need to build real-world embedded projects using the power of TinyGo. What you will learn Discover a variety of TinyGo features and capabilities while programming your embedded devices Explore how to use display devices to present your data Focus on how to make TinyGo interact with multiple sensors for sensing temperature, humidity, and pressure Program hardware devices such as Arduino Uno and Arduino Nano IoT 33 using TinyGo Understand how TinyGo works with GPIO, ADC, I2C, SPI, and MQTT network protocols Build your first TinyGo IoT and home automation prototypes Integrate TinyGo in modern browsers using WebAssembly Who this book is for If you are a Go developer who wants to program low-powered devices and hardware such as Arduino UNO and Arduino Nano IoT 33, or if you are a Go developer who wants to extend your knowledge of using Go with WebAssembly while programming Go in the browser, then this book is for you. Go hobbyist programmers who are interested in learning more about TinyGo by working through the DIY projects covered in the book will also find this hands-on guide useful. Cover Title Page Copyright and credits Contributors Table of Contents Preface Chapter 1: Getting Started with TinyGo Technical requirements Understanding what TinyGo is How TinyGo works Comparing TinyGo to Go Setting up TinyGo Installing on Linux Installing on Windows Installing on macOS Installing on Docker Understanding IDE integration VS Code integration General IDE integration Setting up Goland Integrating any editor The Arduino UNO Getting to know the technical specifications Exploring pinout Checking out the Hello World of Things Getting the requirements ready Preparing the project Programming the microcontroller Flashing the program Using TinyGo Playground Summary Questions Chapter 2: Building a Traffic Lights Control System Technical requirements Lighting an external LED Lighting an LED when a button is pressed Building the circuit Programming the logic Building traffic lights Building the circuit Creating a folder structure Writing the logic Building traffic lights with pedestrian lights Assembling the circuit Setting up the project structure Writing the logic Summary Questions Further reading Chapter 3: Building a Safety Lock Using a Keypad Technical requirements Writing to the serial port Monitoring the serial port Monitoring input from a keypad Building the circuit Understanding the workings of a 4x4 keypad Writing the driver Driver variables Configure GetIndices GetKey main Finding drivers for TinyGo Contributing drivers to TinyGo Controlling a servomotor Understanding SG90 servomotors Building the circuit Writing the servo control logic Building a safety lock using a keypad Building the circuit Writing the logic Summary Questions Chapter 4: Building a Plant Watering System Technical requirements Reading soil moisture sensor data Assembling the circuit Finding thresholds Understanding ADC in TinyGo Writing a library for the sensor Testing the library Reading water level sensor data Writing a water level sensor library Controlling a buzzer Writing a buzzer library Controlling a pump Working with relays Writing a pump library Watering your plants Summary Questions References Chapter 5: Building a Touchless Handwash Timer Technical requirements Introducing the Arduino Nano 33 IoT Installing Bossa Learning to measure distances Understanding the HC-SR04 sensor Assembling the circuit Writing a library Unit testing in TinyGo Writing an example program for the library Using 4-digit 7-segment displays Using a MAX7219 Writing a library to control the MAX7219 Writing a library to control the hs42561k display Putting it all together Summary Questions Chapter 6: Building Displays for Communication using I2C and SPI Interfaces Technical requirements Exploring the TinyGo drivers Displaying text on an HD44780 16x2 LCD display Building the circuit Understanding I2C Writing the code Displaying user input on the display Building a CLI Understanding SPI Displaying a simple game Building the circuit Using an ST7735 display Developing a game Summary Questions Chapter 7: Displaying Weather Alerts on the TinyGo Wasm Dashboard Technical requirements Building a weather station Assembling the circuit Programming the weather station Sending MQTT messages to a broker Implementing the Wi-Fi package Implementing an MQTT client abstraction layer Implementing the weather station Introducing Wasm Displaying sensor data and weather alerts on a Wasm page Serving the application Implementing the weather app Summary Questions Chapter 8: Automating and Monitoring Your Home through the TinyGo Wasm Dashboard Technical requirements Building a home automation dashboard Creating a reusable MQTT component Setting up the Wasm instantiation code Creating the HTML template Implementing the login view logic Implementing the dashboard component Implementing the main logic Serving the app Building the home automation client Setting up the circuit Implementing the logic Requesting data from the microcontroller Checking other implementation ideas Summary Questions Appendix – "Go"ing Ahead Blocking a goroutine Reading from a channel A select statement Sleeping is a blocking call Finding heap allocations Assessments Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Afterword Why subscribe? About Packt Other Books You May Enjoy Index
Similar books
Creative DIY Microcontroller Projects with TinyGo and WebAssembly: A practical guide to building embedded applications for low-powered devices, IoT, and home automation
2021 · PDF
Creative DIY Microcontroller Projects with TinyGo and WebAssembly
2021 · MOBI
Creative DIY Microcontroller Projects with TinyGo and WebAssembly
2021 · EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF