Micro:bit IoT In C, Second Edition (I/O Press)
Friday, 02 April 2021

The BBC micro:bit is capable of taking on a variety of roles including that of a powerful IoT device. In order to gain full access to its features and to external devices, however, you need to use C which delivers the speed which is crucial when you are writing programs to communicate with the outside world. The updated, expanded, 2nd Edition covers the new V2 version of the micro:bit and uses the VS Code for offline development. Writing for the electronics enthusiast with a programming background, Harry Fairhead presents details of sensors and circuits with several complete programs and provides downloadable templates for both V1 and V2 of the micro:bit to help you get started.

<ASIN:1871962676>

Author: Harry Fairhead
Publisher: I/O Press
Date: February 2021
Pages: 267
ISBN: 9781871962676
Print: 1871962676
Kindle: B08XPRMK97
Audience: Iot developers, C programmers interestested in electronics
Level: Intermediate
Category: IoT; Electronics   

microbite2360

 

Having started with the traditional "Blinky" program, the equivalent of "Hello World" for hardware, we are ready to discover how to control the micro:bit’s I/O lines, exploring the basis of using the GPIO. For speed, however, we need to work directly with the raw hardware and also master memory mapping, pulse width modulation and other more sophisticated bus types.  From here we can start connecting sensors using first the I2C bus, then by implementing a custom protocol for a one-wire bus, and eventually adding eight channels of 12-bit A-to-D with the SPI bus, which involves overcoming some subtle difficulties. We then look at serial connections, one of the oldest ways of connecting devices, but still very useful. The micro:bit lacks WiFi connectivity but using a low-cost device we enable a connection to the Internet via its serial port which allows it to become a server. Next we look at the micro:bit’s LED display. This may only be 5x5, but it is very versatile, especially when you use pulse width modulation to vary the brightness level, something we demonstrate in a classic game, written of course in C. The book rounds out with a new chapter on the micro:bit’s radio and the V2’s sound capabilities.