Preface
Acknowledgements
Contents
Introduction
ESP32
Choosing an ESP32 Development Board
The ESP32 Lite and ESP32 DevKit 1
General Purpose Input Output Pins
Programming
Summary
Getting Started
USB Drivers
Installing the Thonny Editor
Installing Python on your ESP32
Thonny
Summary
MicroPython Basics
The Thonny Shell
Numbers
Variables
Strings
Programs
Looping Forever and Blinking
Example Code
Blinking SOS
For Loops
if and else
Summary
Functions
What are Functions?
Parameters
Return Values
Random Numbers
Named Parameters
Summary
Lists and Dictionaries
Lists
A List Example
Strings as Lists
Dictionaries
A Morse Code Translator
Summary
Modules, Classes and Files
Importing from Modules
Documentation
Useful Built-in Modules
Classes
String Methods
Files
Exceptions
File Counter Example
Summary
Inputs and Outputs
Digital Outputs
Digital inputs
Analog Outputs
Analog Inputs
Summary
Electronics
Solderless Breadboard
Components
Making an LED Blink
RGB LEDs
ESP32 Lite ESP32 Devkit 1
Servomotors
sensor
ESP32 Lite ESP32 Devkit 1
Battery Power
Summary
Sensors
Variable Resistors
ESP32 Lite ESP32 Devkit 1
fritzing
Sensing Light
ESP32 Lite ESP32 Devkit 1
Sensing Temperature
ESP32 Lite
ESP32 Devkit 1
fritzing
Summary
WiFi
Connecting to WiFi
Running a Web Server
Hello from ESP32
A WiFi Lightmeter
Calling a Web Service
Summary
Displays
OLED Displays
An OLED Clock
A Self-Setting OLED Clock
NeoPixel Displays
Summary
Advanced Input Output
Interrupts
Timer Interrupts
High-Speed PWM
Multicore Support
Analog Outputs
Generating Sounds using the DAC
Playing a Sound File
Touch
GPIO Drive Current
Summary
ESP32 Pinouts
Troubleshooting
Index
Biography
This book will teach you Python programming and some basic electronics without assuming any prior knowledge of either subject. The book initially focusses on Python programming, building up a Morse Code example.
The book is suitable for most ESP32 boards, but concentrates on the most popular ESP32 Lite and the ESP32 DevKit 1. In the chapters on electronics, breadboard layouts are provided for both of these boards.
Flash Python firmware onto an ESP32 board
Install and use the Thonny Python editor and upload programs on to your ESP32
Write simple programs to control the ESP32 in Python
Structure you programs with functions and modules
Make effective use of Python Lists and Dictionaries
Attach sensors, LEDs, displays and servomotors to an ESP32 and to program them
Make use of the ESP32s WiFi capabilities to use the ESP32 as a web server and to call web services on the Internet