members
Basics: Project 021g ESP8266 ESP-01 WI FI module - Wi-Fi Button
of Acoptex.com in ESP8266 ESP-01
Basics: Project 021g
Project name: ESP8266 ESP-01 WI FI module - Wi-Fi Button
Tags: SP, ESP8266, WI FI module, ESP-01, V090, update firmware, Ai Thinker, AI-Cloud, SOC, GPIO, General Purpose Input Output, System On a Chip, IOT, internet of things, FTDI232, FTDI 232, USB to TTL, ESP8266 ESP-01 module, Arduino, Wi-Fi Button, DIY Amazon Dash Button
Attachments: sketch
In this project, you need these parts :
1. ESP8266 ESP-01 WI FI module 1pc
2.Arduino IDE ( you can download it from here )
3.Jumper cables F-M, F-F, M-M
4. Resistor 1 pc (10 KOhm)
5. Momentary switch 1 pc
6. Breadboard 1 pc
7. USB to TTL serial converter 1 pc
8. USB mini cable 1 pc (optional)
9. Any voltage regulator LD1117V33, AMS1117 3.3 V or 78R33 (to get 3.3V) or 1 pc
or
or
General
We will learn how to build an ESP8266 ESP-01 Wi-Fi Button that can trigger any home automation event. This is like a remote control that you can take in your pocket or place anywhere that when pressed sends out an email.
The Wi-Fi button is not a new idea and this concept was popularized by Amazon that created the Dash button, which is a small button that instantly orders a product to your home. Since the ESP8266 ESP-01 WiFi modules are very cheep, we can make a similar project that works like the Dash button but instead of ordering a product we can turn on a light, send a value, trigger an email notification and much more, as you’re going to see by the end of this project.
Understanding the USB to TTL converter
You can read more about them here.
Understanding the ESP8266 WI FI module
You can read more about it here.
Signals and connections of the ESP8266 ESP-01 WI FI module
TXD (TX, TXO or UTXD) - transmit pin. Connected to Arduino Uno pin 1.
RXD (RX, RXI or URXD) - receive pin. Connected to Arduino Uno pin 0.
VCC (3V3 or 3.3V) - power supply pin (3-3.6V). Connected to 3.3V DC 1A and more external power supply. The current required for the ESP-01 during Wi-Fi operation vary from 250mA to 750mA.
RST (RESET) - reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.
CH_PD (CHIP_EN or EN) - Chip enable. Keep it on high (3.3V) for normal operation.
GND - Ground. Connected to Arduino board GND pin
GPIO0, GPIO2 (IO0, IO2) - General Purpose Input Output pins. GPIO0 also controls the module mode (programming or normal operation). In our case (normal operation), it shall be connected to 3.3V (high). GPIO2 is not used in this example.
Wiring
1. Programming (uploading sketch) using ESP01 programmer UART
It is very easy. Simply insert ESP8266 ESP-01 module to ESP01 programmer UART. However to go to flash mode you need to have GPIO0 pin grounded (attached to GND pin). A small modification on the back of ESP01 programmer UART posible to make the life more easy. You can just shift jumper from GND-GND to GND-GPIO0 position.
2. Programming (uploading sketch) using USB to TTL converter with DTR Pin or without DTR Pin
3. Programming (uploading sketch) using Arduino Uno board
The ESP8266 powered up using a separate 3.3 V power source or a voltage regulator AMS1117 3.3 V or 78R33 or a voltage divider. Note: Do not plug in ESP8266 ESP-01 module directly to 3.3V Arduino Uno board pin as the ESP8266 ESP-01 module may draw more current than the 3.3V regulator on your Arduino can supply so you can damage your Arduino board.
4. Final wiring after sketch uploaded to ESP8266 ESP-01 module
Step by Step instruction
1. Adding ESP8266 platform to Arduino IDE
The Arduino environment has to be set up to make it compatible with the ESP8266 ESP-01 module. It is required to have Arduino IDE version 1.6.4 or higherin order to install the ESP8266’s platform packages.
- Open Arduino IDE.
- Open the Preferences window from the Arduino IDE. Go to File -> Preferences.
- Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button. If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)
- Open Boards manager. Go to Tools -> Board -> Boards Manager…
- There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. or scroll down to the ESP8266 entry (usually at the bottom). Select the ESP8266 entry. When you click it an install option will appear. Select the latest version and click install.
- The board definitions and tools for the ESP8266 include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.
- Choose your ESP8266 board. Go to Tools -> Board -> Generic ESP8266 Module
- You will see Generic ESP8266 Module on the bottom of the Serial Monitor window.
2. Creating the Applet in IFTTT
For this project we’re going to use a free service called IFTTT (If This Than That). This service is used to automate a wide variety of tasks online. In this case, we will send an email when the ESP8266 ESP-01 module pushbutton is pressed.
- You need to create your IFTTT account. It's free of charge. Go the official site: ifttt.com and enter your email to get started. Go to the ifttt.com website, enter your email address and click on get started button.
- Enter password and click on Sign up button.
- You need to create a new applet. Go to My Applets and create a new applet by clicking the New Applet button.
- Click on the this word that is in a blue color.
- Search for the Webhooks service and select the Webhooks icon.
- Choose the Receive a web request trigger.
- Give a name to the event, for example button_pressed and click on Create trigger button. With the Webhooks service you can trigger an action when you make an HTTP request to a specific URL.
- Click on that word to proceed ahead and search for the Gmail service.
- Select the Gmail icon.
- If it’s the first time using the Gmail service with IFTTT, a new window opens and you’ll have to grant access, so IFTTT can send out emails through your account. Choose Send email option and enter the email address in the To address field where you want to receive your notification.
- You can customize the subject and body of the email, but for demonstration purposes we will leave the default values. Finally click on Create action button.
- Your Applet will be created after clicking on Finish button:
- We need to test applet. Go to the Webhooks Service page and click on Documentation button.
- Here you can find your unique API KEY that you must keep private. Type in the event name, button_pressed. Your final URL should appear in the bottom of the web page. Copy that URL.
- Open a new tab in your browser, paste the URL and hit enter. You should see this message saying Congratulations!.
- Open your email client and the new message should be there.
- In case the email didn’t arrive after a few seconds, we recommend to check the URL and see if you’re using the correct event name, both in your Applet and in your URL.
- Save your unique URL as you’ll need it later in this project.
3. Uploading sketch to ESP8266 ESP-01 module using USB to TTL converter with DTR Pin or without DTR Pin or Using ESP01 programmer UART
- Do wiring.
- Open Arduino IDE.
- Plug your USB to TTL converter with DTR Pin or without DTR Pin or ESP01 programmer UAR into your PC USB port.
- Choose your ESP8266 board. Go to Tools -> Board -> Generic ESP8266 Module
- Select the correct com port.
- Modify (with your SSID, password and URL), verify and upload the sketch to your ESP8266 ESP-01 module. AT commands will not work after that. You need to Flash the firmware to enable them again.
- When you press the momentary switch the ESP8266 ESP-01 wakes up, performs an action (send an email) and goes back to Deep Sleep mode to save battery power.
Code:
How the code works:
- It starts the serial communication at a baud rate of 115200;
- Runs the initWifi function that establishes a Wi-Fi connection between your ESP8266 ESP-01 and your router;
- Then it executes the makeIFTTTRequest function that will make a request to the IFTTT service and ultimately IFTTT will send out an email.
- We’re using the Deep Sleep function, so that the ESP8266 ESP-01 is always off and consumes very little power.
Summary:
We have learnt how to build an ESP8266 ESP-01 Wi-Fi Button that can trigger any home automation event.
You can use this idea for other projects :
- Use this WiFi button as doorbell button it to know if someone is at your house or appartment;
- You can also replace the momentary switch with other sensors or actuators - PIR motion sensor (you will be notified when someone enters a room in your house), smoke detector (to detect smoke in a room), magnetic reed switch (allows you to detect if someone opened a door or window , attach it to a mailbox to see when you receive actual letters in the mail or other packages).
Library:
- No library required in this project
Sketch:
- You can find it on the beginining of this project description
Other projects of Acoptex.com










Viewed: 8366 times