New Release

IoT Development for ESP32 and ESP8266 with JavaScript

A Practical Guide to XS and the Moddable SDK

The software that powers IoT is changing rapidly as customers demand more sophisticated products. Developers creating the software for embedded products need to adopt new techniques to meet these increased customer expectations.

This book introduces the Moddable SDK, a breakthrough in embedded software that gives professional developers the tools they need to deliver products today. The Moddable SDK combines the ease of use of modern JavaScript with the speed of C/C++ code. Developers working this way are more productive, without compromising performance or flexibility.

The book focuses on the ESP32 and ESP8266 microcontrollers because they deliver a major leap in capabilities at a very low cost. These chips are found in commercial products from major companies worldwide and are also popular with students and makers.

The authors are both members of the team that created the Moddable SDK. This book draws on their years of experience using it to deliver products. They wrote this book for embedded developers, web developers, product designers, and makers.



What’s in the book

This book introduces a powerful new approach to embedded development, grounded in modern JavaScript. Each chapter goes in‑depth on a single topic, providing both practical knowledge and examples for you to learn from, run, modify, and incorporate into your products.

Examples are available in the book's repository on GitHub. The book includes instructions for building the examples using macOS, Windows, and Linux computers.

JavaScript

JavaScript is the language of the web, popular for communication and building user interfaces. It just makes sense to use it in connected IoT products too. You'll learn how to use JavaScript efficiently in IoT products. For embedded developers, JavaScript is a new tool for creating more reliable, more powerful products more quickly. For web developers, JavaScript is a way apply their skills to IoT products. The book also includes a fast-paced, practical introduction to JavaScript for embedded programmers more familiar with C or C++.

Network

Network connections are fundamental to IoT. The examples include secure communication with the essential IoT cloud protocols HTTP, WebSockets, and MQTT. You'll also learn to scan for Wi‑Fi networks using the built-in Wi‑Fi on the ESP32 and ESP8266, and how to use mDNS to advertise and discover local network services.

Graphics

Displays make products easier to understand and use, so it is no surprise they are becoming more common in IoT products. You'll learn how to overcome the constraints of inexpensive microcontrollers to deliver high-quality, high-performance graphics using the APIs and build tools in the Moddable SDK.

Sensors

Sensors are a key hardware component in most IoT products. You'll learn how to read data from a widely used temperature sensor, configure the resoution of its readings, and manage its energy use. More importantly, you'll see how to use a sensor's data sheet to write the software to communicate with it, so you can support whatever sensors your project needs.

User interface

Getting pixels on the screen is only the first step in building a user interface. It is challenging to create an interface that looks and feels like it belongs next to a modern mobile phone. The Piu user interface framework brings powerful ideas from the web to inexpensive microcontrollers. That includes cascading styles, responsive layout, timeline driven animation, and declarative user interface specification.

A series of step-by-step examples shows you how to use Piu to create a beautifully animated interface for your project, including an expanding touch keyboard for small screens.

Hardware

When writing software for an IoT product, eventually you need to write code that interacts directly with the hardware. You'll learn how to detect presses of tactile buttons, control single and tri‑color LEDs, turn servo motors commonly used in robotics, retrieve readings from sensors, and play sound on a speaker.

For web developers getting started with embedded development the book introduces hardware communication protocols used in microcontrollers. It also includes color wiring diagrams for connecting inexpensive hardware components to your development board. No soldering required!

Bluetooth Low Energy (BLE)

BLE is the most energy efficient way for IoT products to communicate wirelessly. It is found in electric toothbrushes, ovens, phones, lightbulbs, and more. Starting with a simple JSON device description, you'll see how to implement a heart rate monitor peripheral for ESP32 that communicates with your phone. You'll also learn how to advertise services over BLE and discover nearby BLE devices.

If you are just getting started with BLE, the book introduces key terms and concepts from the BLE standard.

Who should read this book

This book is for professionals creating IoT products. It explains the capabilities and constraints of microcontrollers and provides a wealth of practical example code to perform common tasks.

The book is written for both embedded developers getting started with JavaScript and web developers getting started with embedded development. It is also a valuable resource for students, makers, and hobbyists looking to get the most out of their ESP32 and ESP8266 development boards.

Embedded developers

The ever increasing demand for more features in IoT products means embedded developers are expected to move at web development speed. Using the high level JavaScript language lets developers move faster. The many powerful modules built into the Moddable SDK — graphics, user interface, networking, BLE, sensors — augment the capabilities of the embedded platform. The book also shows you how to bridge between JavaScript and C code for a speed boost or to reuse existing native code.

Web developers

Web developers are constantly learning new tools and techniques to grow their skills. With modern JavaScript now a reality on low cost IoT hardware, web developers have a head start in extending their skills to an entirely new field, to move from animating elements on a web page to animating objects the real world. This book introduces key concepts in embedded development, so you don't need any prior embedded knowledge.

Product designers

The choice of hardware to use in a product has far reaching consequences, from the product's features and performance to its price. Many product designers, unfamiliar with just how powerful modern microcontrollers are, choose unnecessarily powerful hardware that costs more. This book shows how much can be done with hardware that costs just a few dollars. It also includes a detailed discussion about adding a cost effective display to an IoT product.

Makers

Makers are looking for the fastest way to bring their project to life. Using JavaScript and the Moddable SDK lets makers focus more on achieving their vision because they need to spend less time on technical details. The forgiving nature of the JavaScript language is particularly valuable when exploring and prototyping. Once you've finished reading this book, you'll be ready to use many modules in the Moddable SDK in your own projects.

About the authors

Peter Hoddie and Lizzie Prader have been working together for years to bring the power and flexibility of JavaScript to embedded developers. Before founding Moddable in 2017, they worked together on the KinomaJS, Kinoma Create, and Kinoma Element projects at Marvell Semiconductor. Both contribute to Ecma TC53, a new standard for JavaScript APIs in embedded systems.

Peter and Lizzie's provocative talk "Resuscitating IoT with JavaScript" at OpenJS World 2020 is available for viewing. Their follow-up interview with Bruno Couriol of InfoQ goes in depth about their vision for an IoT powered by standard, open JavaScript.

Peter Hoddie

Peter Hoddie is an engineer and entrepreneur focused on client software. He is recognized for crafting compact and efficient code that pushes the boundaries of user experience on consumer hardware. The software he and his teams have built has powered mass-market consumer products from companies including Apple, Palm, Sling, HP, Sony, and Whirlpool. Peter recognizes that the first users of any product are the developers creating it, and that those developers cannot build compelling consumer products on a foundation that’s unstable, complex, or confusing.

Peter has founded several companies including Moddable and Kinoma, which merged into Marvell Semiconductor. He led QuickTime development at Apple during the 1990s as a Distinguished Engineer. He contributed to the development of the QuickTime file format and its adoption by ISO into the MPEG-4 standard. He is a member of the JavaScript language standards committee (Ecma TC39) and chair of ECMAScript Modules for Embedded Systems (Ecma TC53).


Lizzie Prader

Lizzie Prader is an engineer, educated in theoretical computer science, currently focused on developers’ success. She recognizes the importance of customer support during all stages of a project, and enjoys working with developers to smooth the on-ramp to embedded development. Working with users of all skill levels—from professional engineers to makers and hobbyists to absolute programming beginners—has made her an advocate of well-organized documentation and readable code.

Prior to Moddable, Lizzie worked as a developer relations engineer at Kinoma. Her main goal was to help customers get the most out of Kinoma’s software and hardware prototyping products, both through direct contact with developers and by creating a variety of resources including sample code, tutorials, and blog posts.

Special Promotions from Moddable

All book orders from Moddable include FREE shipping

Moddable book orders are only available in the United States

Book and device bundle

Get our new book along with Moddable Two, our most popular and most powerful development board. Shipping is free!

With a Moddable Two, you'll be ready to run the examples in the book including networking, BLE, graphics, and user interface. Moddable Two includes an ESP32 microcontroller with Wi‑Fi and BLE built in, plus a high quality color IPS display with capacitive touch. The bundle also includes the Moddable Programmer for installing and debugging over USB.

Just the book

Get "IoT Development for ESP32 and ESP8266 with JavaScript" and the shipping is on us!

You can run the examples on popular development boards including Moddable One, Moddable Two, Moddable Three, M5Stack, M5Stack Fire, M5Stack Core2, M5Atom Matrix, M5Atom Echo, M5Atom Lite, M5Stick C, ESP32 Thing, NodeMCU ESP8266, NodeMCU ESP32, and ESP32-WROVER.

Book availability

Purchase this book through your favorite book seller and these vendors:

Amazon
Keplers
Keplers
Keplers
ACM
Available in ACM Learning Center (ACM members only)