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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

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 : 9781787288102
Category :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Apr 27, 2017
Length: 268 pages
Edition : 1st
Language : English
ISBN-13 : 9781787288102
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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela