ESP32 Programming for the Internet of Things
Minimum price
Suggested price

ESP32 Programming for the Internet of Things

HTML, JavaScript, AJAX, MQTT and Websockets Solutions

About the Book

This book is not intended to comprehensively teach you the theory, but to give you practical and fully functional solutions, in the form of complete programs. Much of the theory is already known by some of you, or may be found in many other textbooks. But the programs presented here include a great effort and have many original solutions, following one of the basic paradigms of programming: "Keep i(o)t simple". And - the most important thing for such a book - all the programs have already been verified by third parties, in this case students from Hyperion University, who have provided a very valuable feedback.

About the Author

Table of Contents

Part I. IoT Communications using classic HTML / JavaScript technologies 8

1. General presentation of the book and hardware modules 9

1.1.            General Objectives of the Work 9

1.2.            Structure and method of using the paper 16

1.3.            Hardware implementation. Coupling the inputs and outputs of the ESP32 module 17

1.4.            Examples of boards with ESP microcontrollers 19

2.     Developping ESP32 / ESP8266 IoT applications by using HTML / JavaScript 26

2.1.            Arduino environment installation for ESP microcontrollers 26

2.2.            Simple server using the ESP32 board 27

2.3.            Assigning a static address for external access 30

2.4.            Android Application using MIT App Inventor 37

3.     The command of a GPIO port via WiFi 41

3.1.            Creating a web page for submitting commands from a browser 41

3.2.            Developing a Mobile Application for ESP32 Command Using MIT App Inventor 45

3.3.            The use of a port different from 80 49

4.     Analog and digital commands transmission to an ESP32 server from a MIT App Inventor application 54

4.1.            General principles of analogue and digital transmissions 54

4.2.            Performing digital-analog conversion via PWM in Arduino IDE 55

4.3.            Analog command in MIT App Inventor 60

5.     Bidirectional communication between client and server using MIT App Inventor 63

5.1.            Requirements of bidirectional client-server communications 63

5.2.            Periodically refreshing the web page through MIT App Inventor 65

5.3.            Complete application for bidirectional communication in MIT App Inventor 68

5.4.            The full ESP32 program for bidirectional communication with a MIT App Inventor client 71

6.     Bidirectional transfer via web page. AJAX Technologies 73

6.1.            Methods and Objects of AJAX Technology 73

6.2.            Example of program for controlling a digital output with AJAX transmission 79

6.3.            Example of program for controlling two digital outputs with AJAX transmission 84

7.     Automatic refresh of the web page via AJAX 88

7.1.            Principles of the automatic refresh 89

7.2.            Example of program with automatic refresh via AJAX 90

7.3.            Controlling of digital state and reading of digital and analog value via AJAX, with refresh 94

7.4.            Program for controlling for two logic states and reading two logical values and one analog value, using AJAX, with refresh 100

8.     Monitoring and command HTML/JS/CSS of analog values 108

8.1.            Progressbar type elements designed through CSS 108

8.2.            Example of program for monitoring four digital inputs and an analog one and control of two digital outputs. 111

9.     Client-sever commands with receipt confirmation 115

9.1.            Ensuring coherence in disrupted networks 115

9.2.            Program with confirmation/retransmission of commands for two digital outputs and monitoring of four digital inputs and an analogue input 117

9.3.            Slider-type analog control elements 125

10.        ESP8266/32 programming using the ESP-IDF development environment and ECLIPSE 137

10.1.          Installing the ESP-IDF development environment and setting the toolchain 138

10.2.          Testing an example project 139

10.3.          Installing and configuring Eclipse 142

Part II.  IoT communications using MQTT technology 147

11.        Using MQTT - Message Queuing Telemetry Transport technology 147

11.1.          General presentation of MQTT technology 147

11.2.          Installing and testing the PubSubClient library 154

12.        Examples of applications dedicated to MQTT technology 158

12.1.          Installing and using the HelloIoT application 158

12.2.          Commands of some digital outputs of the ESP32 module 160

12.3.          Analog command via PWM   165

12.4.          Reading of digital and analog inputs 171

13.        Programming MQTT communications using Node-Red development environment 182

13.1.          Installing the Node-Red in Windows 183

13.2.          Installing mosquitto in windows 186

13.3.          Making MQTT communications via Node-Red 186

13.4.          Programming in Node-Red 187

14.        Controlling some outputs using Node-Red and Mosquitto on a Windows computer 188

14.1.          Controlling digital outputs 188

14.2.          Controlling an analog output using Node-Red 203

15.        Monitoring some entries using Node-Red and Mosquitto on a Windows computer 207

15.1.          Monitoring of analog inputs 207

15.2.          Monitoring digital inputs 213

16.        Using Node-Red and Mosquitto broker on Raspberry Pi 226

16.1.          Installing Raspbian on Raspberry Pi 226

16.2.          Install Mosquitto broker 227

16.3.          Installing Node-Red 228

16.4.          Installing Node-Red Dashboard on Raspberry Pi 232

Part III. Internet communications using WebSockets technology 240

17.        Using WebSockets technology on ESP32 240

17.1.          General features of WebSockets technology 241

17.2.          Transmission of a command to a digital output 244

17.3.          Controlling three digital outputs 253

17.4.          Analogic controlling of outputs, using the PWM technique 258

18.        Monitoring of inputs through WebSockets 267

18.1.          Monitoring of digital inputs through WebSockets 267

18.2.          Monitoring an analog input via Websockets 275

18.3.          Displaying an analog value through text and progress bar 279

18.4.          Displaying of an analog value through text, progress bar and gauge 285

18.5.          Displaying an analog value through text, progress bar, Gauge, and Line Chart 291

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$12,136,230writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub