In this ESP8266 project repository, we will present some of the most recommended DIY projects. A very small yet highly powerful WiFi module that serves as a one-stop destination for a wide range of IoT-based tasks and home automation projects. These projects are quite similar to Arduino projects, however, ESP8266 projects are created with built-in WiFi.
Did you know that for a long time the world was unaware of the existence of the ESP8266? About five years ago, developers hit the jackpot called ESP-01, which allowed microcontrollers to connect to a Wi-Fi network and simplify the TCP/IP connection through Hayes-style commands. It's come a long way since then. The projects covered below will give you a better insight into how it can improve the IoT projects around you.
1) ESP8266 Weather Predictor
How about having a device next to your doorknob that reminds you to carry an extra bottle of water if temperatures are higher than normal in your area. We are talking about a simple device that allows you to know the time with a simple change in the color of the LED.
Things you will need
-
- Jumper Wire
- Test board
- 4 x Resistors
- 4 LEDs
- ESP8266 12-E
What else will you need?
You will need an Open Weather Map API. The API key can be obtained by signing up to the platform. Just get the key, copy it and paste it somewhere. To get weather information for a selected location, you will have to enter the URL below while entering the location in braces.
http://api.openweathermap.org/data/2.5/forecast?q= {your city} , {your country code} &APPID= {your API key} &mode=json&units=metric&cnt=2
Copy this URL into your browser and it will give you all the information you need about your local weather forecast.
ArduinoJson library installation
To install the ArduinoJson library you will need to download the file from Unzip the downloaded folder and you will have the ArduinoJson-master folder. Move it to the Arduino IDE installation libraries folder and reopen the Arduino IDE >
Uploading the code
Once you have the ESP8266 add-on for Arduino IDE, just go to the tools segment and click on “NodeMCU (ESP-12E Module)”. Copy the code into the Arduino IDE and upload it to the ESP8266 board. You will need to add some other details like country code, city name, SSID password and Open Weather Map API key in the code. You can check all coding details at:
Schemes
The circuit given below will give you a good idea about the wiring of the circuit.
The final image should look something like this
2) Blu Bug
You may have heard about creating sensor shields, Bluetooth shields or Wi-Fi shields. BluBug brings all these shields together. It is a consolidated format with sensor, engine, Bluetooth, Wi-Fi and wireless programming shield on a single board. It allows you to control sensor data and check engines online from a distant location. It eliminates the need to connect Arduino to PC by loading codes from Arduino IDE via Bluetooth. What's more, it's easier because BluBug comes with an Android app that monitors robots using virtual joysticks.
Why do you need this?
The list of disadvantages associated with purchasing different shields for each purpose is endless. A complete solution looks simple and solves all problems. With BluBug you can upload code wirelessly from an Arduino IDE over Wi-Fi or Bluetooth (whichever you prefer). It is quite useful when your system has been deployed in some distant location and you cannot afford wires running all over for monitoring data, debugging, serial monitor as well as uploading sketches. It also allows you to connect servo motors, stepper devices, DC, AC, analog sensors and so on. There can be no better choice for your robotics and IoT projects.
Required Supplies and Components
- 1 x Expressif ESP8266 ESP-01
- SparkFun, step-up voltage regulator – 3.3V x1
- 1x Genuine UNO and Arduino UNO
- 1 x Texas Instruments Dual H-Bridge L293D engine units
- 1x HC-05 Bluetooth Module
- Soldering Iron
What else can you do with BluBug?
BluBug is perfect for all robotics and IoT projects. It can play a key role in building your own IoT-based home automation system to turn on fans and lights in your apartment through your smartphone. It can also help in monitoring soil characteristics such as temperature, humidity, humidity and others for agricultural purposes.
You can find all assembly details of this device at
3) Hacking the PIR motion sensor with an ESP8266
The project revolves around modifying a commercial motion sensor through the ESP8266 to record data whenever movement is detected. The data is then sent to Node-RED with MQTT communication protocol. Here ESP8266 absorbs power through motion sensor phase-kill wire with the help of AC/DC converter HLK-PM03.
Requirements
- 220V PIR motion sensor
- ESP8266-01
- ESP8266-01 serial adapter
- Small breadboard
- Raspberry Pi
- 47 uF electrolytic capacitor
- Slow blow fuse (200mA)
- Hello-Link HLK-PM03
Overview
It is divided into three different parts:
- Circuit construction
- Creating and Uploading ESP8266 Code
- Creating the Mode-RED flow
Let's discuss the process step by step
-
Circuit Building :
To start, you will need to remove the PIR motion sensor cover. You will see three wires: phase output wire, phase input and neutral wire. It is also suggested that you add a slow blow fuse just before the HKL-PM03 converter as well as a capacitor at the output. The final assembly will be something like this: -
Writing and Uploading ESP8255 Code
For this project, the ESp8266 will be programmed with Arduino IDE. You will need to start by installing the ESP8266 add-on. Also, install the PubSubClient library which will help in creating MQTT client for basic message publishing with the server. Now, copy the code to the Arduino IDE and start making modifications to it. You will need to add your own MQTT broker IP address, password and SSID. You can check the complete coding details at
Next, you will need to include your network credentials and finally the MQTT broker IP.
So how does the code work? It's a simple thing that just publishes a message. Here, the LED will light up whenever the ESP8266 is turned on. Once the code is rectified with the required network credentials, it can be uploaded directly. You will need an FTDI programmer or a serial adapter for this purpose.
-
Node-RED flow creation :
Just before creating the flow, you need to install Mosquito Broker, Node-RED Dashboard, and Node-RED on the Raspberry Pi.
Next, you will need to import the Node-RED stream from the GitHub repository. This is what the imported flow looks like when it gets the logs and messages from the ESP8266 MQQTT whenever any movement is felt or identified. You can see the two added buttons for refreshing and clearing the log in the image below.
Node-RED Panel
Once the necessary changes are made, simply tap the Deploy tab to save the changes. To access your application on the local network you will need to type http:// Seu_RPi_IP_address:1880 /ui
The project helps hack a motion sensor and turn it into a smarter sensor. The HLK-PM03 can be used to power the ESP8266 directly from mains voltage. Whenever motion is detected, the ESP8266 turns on and performs the task. It then subscribes to the MQTT message to record the exact moment the motion was detected. Similarly, other code can be written to perform any other requirement.
Final Words
These projects provide a clear view of the ESP8266's potential. The projects covered here have been carefully chosen to show the range of tasks covered by this device. There are several other useful purposes served by the ESP8266 such as building home automation projects, creating a multi-sensor shield, web servers, DIY Amazon button clone, creating your own voltage regulator, door status monitor, and so on. We will probably talk more about this in our next blog.
References