Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
ESP8266 Internet of Things Cookbook
ESP8266 Internet of Things Cookbook

ESP8266 Internet of Things Cookbook: Over 50 recipes to help you master ESP8266 functionality

eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

ESP8266 Internet of Things Cookbook

Chapter 2. Your First ESP8266 Projects

In this chapter, we will cover:

  • Functionalities of the ESP8266
  • Reading digital signals
  • Reading analog signals
  • Controlling an LED
  • Dimming an LED
  • Controlling a servo motor
  • Measuring data from a digital sensor
  • Controlling an OLED screen
  • Troubleshooting usual issues with ESP8266 basics

Introduction

In this second chapter of the book, we will learn how to use the General Purpose Input/Output (GPIO) pins to read input signals and produce output signals. With that knowledge,we will create simple projects to control outputs and read sensor inputs. This will give way to the development of more complex projects in later chapters.

Functionalities of the ESP8266

The first thing we will tackle is the functionality of the ESP8266. We will look at the features and functions of the ESP8266, and learn about all the available GPIO pins and how we can use them to read and write digital signals.

Features

The ESP8266 chip provides a self-contained, standalone Wi-Fi networking solution that allows you to host applications and to provide a Wi-Fi network that you can use to transfer data and instructions in your projects.

In normal use, the ESP8266 boots up directly from an external flash memory. It also has a cache that improves the performance of the system and reduces the amount of memory needed during operation.

The ESP8266 can also be used as a Wi-Fi adapter. In this case, the chip provides wireless Internet access to a microcontroller-based project through either the CPU AHB bridge or UART interface.

The on-board processing and storage capabilities of the ESP8266 enable easy integration with sensors and other devices via the...

Reading digital signals

One of the uses of the ESP8266's GPIO pins is to read digital signals. This allows you to control your project using input devices and also to monitor sensor data. In this recipe, we will look at how to read digital signals using GPIO pins.

Getting ready

Connect your ESP8266 board to your computer via a USB cable and set up your Arduino IDE (refer back to Chapter 1, Configuring the ESP8266). Once that is done, you can proceed to make the other connections.

In this recipe, we will need a few extra components. They include:

  • Breadboard
  • Jumper wires

Mount the ESP8266 board onto the breadboard and then connect a jumper wire from pin 5 to the GND pin. The connection should be as shown in the following figure:

Getting ready

How to do it…

We will configure pin 5 as an input, then read it using the digitalRead() function and display the state of the input signal on the serial monitor. This will be repeated every 1 second:

// LED pin
int inputPin = 5;
int val = 0;

void setup() {
  Serial...

Reading analog signals

The ESP8266 has one analog pin that we can use to read analog signals. In this recipe, we will be looking at how to write a sketch that reads analog signals. This will enable us to read input from analog sensors.

Getting ready

Connect your ESP8266 board to your computer via a USB cable and set up your Arduino IDE (refer back to Chapter 1, Configuring the ESP8266). Once that is done, you can proceed to make the other connections.

In this recipe, we will need a breadboard and jumper wires in addition to the ESP8266 board. Mount the ESP8266 board onto the breadboard and then connect a jumper wire from the analog ADC pin to the GND pin. The connection should be as shown in the following diagram:

Getting ready

How to do it…

We will use the analogRead() function to read the analog signal on the ADC pin and display the analog signal value on the serial monitor. This will be repeated every 1 second:

// LED pin
int val = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  
  /...

Controlling an LED

This recipe is going to look at how to control an LED using an ESP8266 board. This will basically involve changing the state of an LED either ON or OFF, using the ESP8266 board's GPIO pins. The exercise will enable you to understand how to use the digital output function on the ESP8266.

Getting ready

Connect your ESP8266 board to your computer via a USB cable and set up your Arduino IDE (refer back to Chapter 1, Configuring the ESP8266). Once that is done, you can proceed to make the other connections.

In this recipe, we will need the following components:

Start by mounting the LED onto the breadboard. Connect one end of the 220 Ω resistor to the positive leg of the LED (the positive leg of an LED is usually the taller one of the two legs). Connect the other end of the resistor to another rail of the breadboard and...

Dimming an LED

In this section, we are going to look at how to dim an LED using the analog output function. This will involve controlling the brightness of an LED that is attached to one of the GPIO pins of the ESP8266.

Getting ready

You will need an ESP8266 board and a USB cable to do this tutorial. There will also be some additional components required for this project. They include:

Start by mounting the LED onto the breadboard. Connect one end of the 220 Ω resistor to the positive leg of the LED (the positive leg of an LED is usually the taller one of the two legs). Connect the other end of the resistor to another rail of the breadboard and connect one end of the jumper wire to that rail and the other end of the jumper wire to pin 4 of the ESP8266 board. Take another jumper wire and connect one of its ends to the negative leg of the LED and connect the...

Introduction


In this second chapter of the book, we will learn how to use the General Purpose Input/Output (GPIO) pins to read input signals and produce output signals. With that knowledge,we will create simple projects to control outputs and read sensor inputs. This will give way to the development of more complex projects in later chapters.

Functionalities of the ESP8266


The first thing we will tackle is the functionality of the ESP8266. We will look at the features and functions of the ESP8266, and learn about all the available GPIO pins and how we can use them to read and write digital signals.

Features

The ESP8266 chip provides a self-contained, standalone Wi-Fi networking solution that allows you to host applications and to provide a Wi-Fi network that you can use to transfer data and instructions in your projects.

In normal use, the ESP8266 boots up directly from an external flash memory. It also has a cache that improves the performance of the system and reduces the amount of memory needed during operation.

The ESP8266 can also be used as a Wi-Fi adapter. In this case, the chip provides wireless Internet access to a microcontroller-based project through either the CPU AHB bridge or UART interface.

The on-board processing and storage capabilities of the ESP8266 enable easy integration with sensors and other devices via the...

Reading digital signals


One of the uses of the ESP8266's GPIO pins is to read digital signals. This allows you to control your project using input devices and also to monitor sensor data. In this recipe, we will look at how to read digital signals using GPIO pins.

Getting ready

Connect your ESP8266 board to your computer via a USB cable and set up your Arduino IDE (refer back to Chapter 1, Configuring the ESP8266). Once that is done, you can proceed to make the other connections.

In this recipe, we will need a few extra components. They include:

  • Breadboard

  • Jumper wires

Mount the ESP8266 board onto the breadboard and then connect a jumper wire from pin 5 to the GND pin. The connection should be as shown in the following figure:

How to do it…

We will configure pin 5 as an input, then read it using the digitalRead() function and display the state of the input signal on the serial monitor. This will be repeated every 1 second:

// LED pin
int inputPin = 5;
int val = 0;

void setup() {
  Serial.begin(9600...

Reading analog signals


The ESP8266 has one analog pin that we can use to read analog signals. In this recipe, we will be looking at how to write a sketch that reads analog signals. This will enable us to read input from analog sensors.

Getting ready

Connect your ESP8266 board to your computer via a USB cable and set up your Arduino IDE (refer back to Chapter 1, Configuring the ESP8266). Once that is done, you can proceed to make the other connections.

In this recipe, we will need a breadboard and jumper wires in addition to the ESP8266 board. Mount the ESP8266 board onto the breadboard and then connect a jumper wire from the analog ADC pin to the GND pin. The connection should be as shown in the following diagram:

How to do it…

We will use the analogRead() function to read the analog signal on the ADC pin and display the analog signal value on the serial monitor. This will be repeated every 1 second:

// LED pin
int val = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  
  // read pin...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Leverage the ESP8266's on-board processing and storage capability
  • Get hand- on experience of working on the ESP8266 Arduino Core and its various libraries
  • A practical and enticing recipe-based book that will teach you how to make your environment smart using the ESP8266

Description

The ESP8266 Wi-Fi Module is a self contained System on Chip (SOC) with an integrated TCP/IP protocol stack and can give any microcontroller access to your Wi-Fi network. It is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. This book contains practical recipes that will help you master all ESP8266 functionalities. You will start by configuring and customizing the chip in line with your requirements. Then you will focus on core topics such as on-board processing, sensors, GPIOs, programming, networking, integration with external components, and so on. We will also teach you how to leverage Arduino using the ESP8266 and you'll learn about its libraries, file system, OTA updates, and so on. The book also provide recipes on web servers, testing, connecting with the cloud, and troubleshooting techniques. Programming aspects include MicroPython and how to leverage it to get started with the ESP8266. Towards the end, we will use these concepts and create an interesting project (IOT). By the end of the book, readers will be proficient enough to use the ESP8266 board efficiently.

Who is this book for?

This book is targeted at IOT enthusiasts who are well versed with electronics concepts and have a very basic familiarity with the ESP8266. Some experience with programming will be an advantage.

What you will learn

  • Measure data from a digital temperature and humidity sensor using the ESP8266
  • Explore advanced ESP8266 functionalities
  • Control devices from anywhere in the world using MicroPython
  • Troubleshoot issues with cloud data monitoring
  • Tweet data from the Arduino board
  • Build a cloud-connected power-switch with the ESP8266
  • Create an ESP8266 robot controlled from the cloud

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 27, 2017
Length: 268 pages
Edition : 1st
Language : English
ISBN-13 : 9781787283558
Category :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 27, 2017
Length: 268 pages
Edition : 1st
Language : English
ISBN-13 : 9781787283558
Category :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 95.97
Internet of Things with ESP8266
€32.99
ESP8266 Home Automation Projects
€29.99
ESP8266 Internet of Things Cookbook
€32.99
Total 95.97 Stars icon
Banner background image

Table of Contents

8 Chapters
1. Configuring the ESP8266 Chevron down icon Chevron up icon
2. Your First ESP8266 Projects Chevron down icon Chevron up icon
3. More ESP8266 Functions Chevron down icon Chevron up icon
4. Using MicroPython on the ESP8266 Chevron down icon Chevron up icon
5. Cloud Data Monitoring Chevron down icon Chevron up icon
6. Interacting with Web Services Chevron down icon Chevron up icon
7. Machine to Machine Interactions Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2
(5 Ratings)
5 star 20%
4 star 40%
3 star 0%
2 star 20%
1 star 20%
Carlos Mateos Oct 20, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Seleccione entre varios con similar tema. Desde la selección, seguimiento hasta la entrega todo fue muy bien. Llego en buen estado. El contenido muy bueno para nosotros los aprendices.
Amazon Verified review Amazon
Brendan Ryan May 08, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good intro to ESP8266 and all things IOT
Amazon Verified review Amazon
P. Brown Nov 04, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Quite a good book, felt there was something missing but apart from that I still recommend it to anyone starting off with esp8266 devices.
Amazon Verified review Amazon
Derek S. Jun 28, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I would have bought the Kindle version because this sounds like a good book but did not. The simple reason is that a downloadable version has no "hardware" costs and so should be considerably cheaper. This is way overpriced for a downloadable version of anything. The author should accept that a lot of downloads at low price is better than none at a high price.
Amazon Verified review Amazon
Ike Mitchell May 02, 2020
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Is only applicable to a specific board. Can’t easily use with generic cheap but good node mcu versions. Hard to return once you figure that out
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.