ESP8266 Projects

ESP8266 Projects

If you’re looking for a comprehensive guide to ESP8266 projects, you’ve come to the right place. In this article, we’ll answer some of the most common questions about these amazing microcontrollers, and provide useful tips to help you get started. Whether you’re just starting out or you’re already familiar with the ESP8266, there’s something here for everyone. So let’s get started!

ESP8266 in General

The ESP8266 is an incredibly small microcontroller that has revolutionized the world of electronics and IoT development.

The chip was first released in 2014 by Espressif Systems and has since become one of the most popular microcontrollers used for embedded projects.

It’s small size, low price tag, versatility, and ease of use have made it a great choice for hobbyists and professional makers alike. It can be programmed using Arduino IDE, NodeMCU firmware, or AT commands. It also supports a wide range of protocols such as Wi-Fi (2.4GHz), SPI, I2C, UART etc making it ideal for wireless applications like motion sensing alarms, remote sensors and more.

ESP8266 in General

All this makes it easy to enable IoT (internet of things) projects. This means it can act as a server or client with minimal coding required from the user. Additionally, because it has low power consumption, it can operate on battery power for extended periods of time without needing to be recharged.

As an integrated chip, the ESP8266 can perform a variety of tasks in larger systems. For example, it can be used as a control center for home automation projects by connecting to various sensors and devices over Wi-Fi. By doing this, users can access and control their home from anywhere with internet access. Additionally, it can be used for data logging or network security applications due to its support for encryption protocols like WEP and WPA2. [1]

Best ESP8266 Projects

Now that you know what the ESP8266 is capable of, let’s look at some of the best projects you can do with it. In this article, we’ll list some of the most common and best projects to do with an ESP8266.

ESP8266 NodeMCU: Send Messages to WhatsApp

A great way to use the ESP8266 NodeMCU module is to send messages to WhatsApp. This can be useful for a number of different applications such as home automation, monitoring systems and more.

WhatsApp is one of the most popular messengers in the world and is widely used, so sending messages via it can be a great way to get your projects noticed.

To get started with this project you’ll need an ESP8266 NodeMCU board, USB data cable, and a computer running Windows or MacOS. To actually get everything working, you will need to use a CallMeBot API. This API will enable you to send messages from the ESP8266 NodeMCU board directly to WhatsApp.

Best ESP8266 Projects

To get started, first create a CallMeBot account and generate an API key. This key will be used by your ESP8266 NodeMCU board when sending requests to the CallMeBot API.

This can be done by entering your phone number, sending a sample message and grabbing your key.

In order to actually use the CallMeBot’s API by sending a message with only one POST request to this specified URL.

https://api.callmebot.com/whatsapp.php?phone=[phone_number]&text=[message]&apikey=[your_apikey]

Just replace the blanks with your own information!

Now, for this project we will be using an Arduino IDE to write the code for our ESP8266 NodeMCU. First, make sure you have installed the necessary drivers and connect it to your computer’s USB port.

Now install the URLEncode library. This will be used to encode the parameters of your POST request. To do this, simply open up the Arduino IDE and go to Sketch -> Include Library -> Manage Libraries.

Now search for URLEncode and install it. After that, we can start writing the code to actually send our message from the ESP8266 NodeMCU board. Start by defining your API key, phone number, and message as variables in your sketch.

#include
#include
#include
#include

const char* ssid = “REPLACE_WITH_YOUR_SSID”;
const char* password = “REPLACE_WITH_YOUR_PASSWORD”;

// +international_country_code + phone number
// Portugal +351, example: +351912345678
String phoneNumber = “REPLACE_WITH_YOUR_PHONE_NUMBER”;
String apiKey = “REPLACE_WITH_API_KEY”;

void sendMessage(String message){

// Data to send with HTTP POST
String url = “http://api.callmebot.com/whatsapp.php?phone=” + phoneNumber + “&apikey=” + apiKey + “&text=” + urlEncode(message);
WiFiClient client;
HTTPClient http;
http.begin(client, url);

// Specify content-type header
http.addHeader(“Content-Type”, “application/x-www-form-urlencoded”);

// Send HTTP POST request
int httpResponseCode = http.POST(url);
if (httpResponseCode == 200){
Serial.print(“Message sent successfully”);
}
else{
Serial.println(“Error sending the message”);
Serial.print(“HTTP response code: “);
Serial.println(httpResponseCode);
}

// Free resources
http.end();
}

void setup() {
Serial.begin(115200);

WiFi.begin(ssid, password);
Serial.println(“Connecting”);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print(“Connected to WiFi network with IP Address: “);
Serial.println(WiFi.localIP());

// Send Message to WhatsAPP
sendMessage(“Hello world!”);
}

void loop() {

}

This is just a sample code! Here you can see that we are using the CallMeBot API, our phone number and API key, and the URLEncode library for encoding our message.

Once you have written your code just compile it, upload it, and press reset on the ESP8266 NodeMCU board. When the process is done, if everything went well you should receive a notification on your WhatsApp with the message that was sent from your ESP8266 NodeMCU board!

Best ESP8266 Projects

TDS Sensor With ESP8266 NodeMCU

TDS (Total Dissolved Solids) is a measure of the amount of minerals, salts and metals dissolved in water. Knowing TDS levels can be important for monitoring water purity, as well as for other purposes such as hydroponics.

A Total Dissolved Solids (TDS) Sensor is a device used to measure the concentration of dissolved solids in a solution, such as water. It works by sending out an electrical charge that is affected by the amount of ions present in the solution, and then measuring the strength of that charge. This reading can be used to determine the amount of dissolved solids present in the solution.

TDS sensors are mainly used for aquariums, soil, and hydroponic testing. They can also be used to monitor water quality in residential, commercial, and industrial settings.

Using an ESP8266 NodeMCU board, it’s possible to build a device that can measure TDS levels with relative accuracy. This guide will provide step-by-step instructions on how to do this using readily available components.

First things first you need to get your hands on a TDS sensor, along with a few other components. Once you have acquired it, connect it to the ESP8266.

The TDS Sensor is usually connected to an analog port, but some models also have i2c bus capabilities. If it’s an i2c model, you will need to add a few extra components for proper connection.

In our case, we had to connect the GND, VCC 3.3V and Data to A0 ports of the ESP8266. Next, you will need to calibrate your sensor. This can be done by testing something with a known tds level, such as distilled water.

Next, you need to write code for the ESP8266 board which will allow communication with the TDS sensor and read out its values. Depending on your knowledge of coding, this could be very easy or quite complicated. We will provide you with a sample code for a basic setup.

Best ESP8266 Projects

#define TdsSensorPin A0
#define VREF 3.3 // analog reference voltage(Volt) of the ADC
#define SCOUNT 30 // sum of sample point

int analogBuffer[SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0;
int copyIndex = 0;

float averageVoltage = 0;
float tdsValue = 0;
float temperature = 23; // current temperature for compensation

// median filtering algorithm
int getMedianNum(int bArray[], int iFilterLen){
int bTab[iFilterLen];
for (byte i = 0; i<iFilterLen; i++)
bTab[i] = bArray[i];
int i, j, bTemp;
for (j = 0; j < iFilterLen – 1; j++) {
for (i = 0; i < iFilterLen – j – 1; i++) { if (bTab[i] > bTab[i + 1]) {
bTemp = bTab[i];
bTab[i] = bTab[i + 1];
bTab[i + 1] = bTemp;
}
}
}
if ((iFilterLen & 1) > 0){
bTemp = bTab[(iFilterLen – 1) / 2];
}
else {
bTemp = (bTab[iFilterLen / 2] + bTab[iFilterLen / 2 – 1]) / 2;
}
return bTemp;
}

void setup(){
Serial.begin(115200);
pinMode(TdsSensorPin,INPUT);
}

void loop(){
static unsigned long analogSampleTimepoint = millis();
if(millis()-analogSampleTimepoint > 40U){ //every 40 milliseconds,read the analog value from the ADC
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin); //read the analog value and store into the buffer
analogBufferIndex++;
if(analogBufferIndex == SCOUNT){
analogBufferIndex = 0;
}
}

static unsigned long printTimepoint = millis();
if(millis()-printTimepoint > 800U){
printTimepoint = millis();
for(copyIndex=0; copyIndex<SCOUNT; copyIndex++){
analogBufferTemp[copyIndex] = analogBuffer[copyIndex];

// read the analog value more stable by the median filtering algorithm, and convert to voltage value
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF / 1024.0;

//temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(fTP-25.0));
float compensationCoefficient = 1.0+0.02*(temperature-25.0);
//temperature compensation
float compensationVoltage=averageVoltage/compensationCoefficient;

//convert voltage value to tds value
tdsValue=(133.42*compensationVoltage*compensationVoltage*compensationVoltage – 255.86*compensationVoltage*compensationVoltage + 857.39*compensationVoltage)*0.5;

//Serial.print(“voltage:”);
//Serial.print(averageVoltage,2);
//Serial.print(“V “);
Serial.print(“TDS Value:”);
Serial.print(tdsValue,0);
Serial.println(“ppm”);
}
}
}

The code should then take this value and convert it into parts per million (PPM) using a formula found on most datasheets. You can also set thresholds for high or low mineral concentrations and add extra functionality such as LED lighting or notifications.

Best ESP8266 Projects

Once you have the ESP8266 board programmed, the next step is to actually put it to some use. You can begin by testing the tap water with it and measuring the electrical conductivity of different liquids! [2], [3]

FAQ

Is ESP8266 used in industry?

Unfortunately no, ESP8266 is not used in the industry. It is mostly used in hobby projects and similar applications. The ESP8266 has limited capabilities, making it difficult to use for industrial applications such as power monitoring or automation systems.

In addition, ESP8266 does not have the support infrastructure needed for industry use such as a reliable software platform, robust networking protocols, and advanced debugging tools.

However, ESP8266 can be a valuable learning tool for people interested in developing their own low-cost IoT devices. It is relatively simple to use, with plenty of resources available online to help you get started on your next project. Many of these tutorials will show you how to integrate the device into other platforms like Arduino or Raspberry Pi to take your projects to the next level.

Is ESP8266 obsolete?

The ESP8266 is not obsolete and is still very much alive. The chip was first released in 2014, but it has been continuously updated with new features and improvements since then. For example, the Wi-Fi module has become more powerful over time, making it capable of connecting to more devices and networks.

There are also several add-on modules available for the ESP8266, such as external flash memory and peripherals. This further enhances its capabilities, allowing it to be used in more complex projects.

What can I build with ESP8266?

The ESP8266 is a powerful, low-cost microcontroller that can be used to build a wide variety of projects.

For example, you can use it to control appliances, monitor environmental conditions and even create your own custom IoT-enabled devices. The possibilities are nearly endless!

You could, for instance, use the ESP8266 as a WiFi enabled remote control for lights or fans in your home. You could also use it to sense temperature and humidity levels in different rooms so that you always know what’s happening inside your house. And with the right programming skills, you could even create an automated watering system that would take care of your plants while you’re away on vacation.

On top of all this, the ESP8266 is capable of running web servers, so you could also use it to create a custom website or mobile app that can be used to control the devices in your home. There are countless possibilities with this amazing chip! So if you’re looking for an inexpensive and versatile project platform, then the ESP8266 is definitely worth considering.

Can ESP8266 replace Arduino?

ESP8266 can be used as a replacement for Arduino in some projects, but it doesn’t offer the same level of features and capabilities. For example, when it comes to analog pins, ESP8266 only has one GPIO pin capable of performing an analog function while Arduino boards typically have more than one. Furthermore, the ESP8266 also lacks many of the advanced serial communications protocols present on Arduinos such as I2C and SPI.

However, where ESP8266 shines is its ability to connect to Wi-Fi networks which makes it suitable for IoT applications. It also requires less power compared to most Arduino boards making it better suited for battery-powered projects or those that need to conserve energy in order to remain operational for long periods of time.

Overall, it is best to decide on a case-by-case basis whether ESP8266 or Arduino is the better choice for a particular project. Both boards offer different levels of power and features so it’s important to understand the capabilities and limitations of each in order to make an informed decision.

Is ESP8266 better than ESP32?

The answer to this question depends on the application you plan to use it for. ESP32 is more capable in many ways, but it also uses more power and has a higher cost.

When compared directly, ESP8266 has a much lower power consumption than ESP32, making it more suitable for battery-operated projects. Additionally, due to its low cost, small size and low power requirement, it can be integrated into many projects that would not have been possible with other microcontroller platforms.

ESP32 has more GPIO pins, more memory, and supports faster Wi-Fi throughput than ESP8266. This makes it better suited for applications that require a lot of I/O or need to process large amounts of data quickly. Additionally, its Bluetooth capabilities allow for a wider range of projects.

Still because of its extra complexity, the ESP32 is often seen as harder to work with than its simpler counterpart, the ESP8266.

Is ESP8266 better than Arduino?

The answer to this question depends on the type of project you are planning. ESP8266 is a great choice for projects that involve connecting to the internet, or require networking protocols such as MQTT and HTTP. The board is also very cheap compared to other solutions like Arduino or Raspberry Pi, making it an excellent option when cost and size are factors.

On the other hand, Arduino boards have much better support for analog inputs/outputs and often come with built-in hardware peripherals like an LCD display which can be used without adding any extra components. ESP8266 has 1024 levels of pulse width modulation (PWM) compared to Arduino’s 256 and it offers a much better value for power and price!

Useful Video: 10 Learning projects using ESP8266 for Beginners

Conclusion

ESP8266 is a powerful and attractive platform for creating innovative projects. It is a low-cost, easy-to-use Wi-Fi module with many features that can connect to the Internet and make it easier for users to perform different tasks. The abundance of tutorials, libraries, framework and support from communities like ESP8266 Community Forum makes it even more attractive.

In this article, we have discussed several important aspects of using the ESP8266 for projects. We looked at the different types of projects that can be created as well as some useful tips to make your project successful. From sending messages via WhatsApp to using one with TDS sensor, the ESP8266 can help you achieve your goals.

With the increasing number of applications, the possibilities are endless when it comes to developing projects based on ESP8266. From home automation to robotics, there are a lot of amazing projects that you can build using this tiny little device. All you need is a bit of creativity and imagination! So what are you waiting for? Go ahead and get started on your own project today! Good luck!

References

  1. https://fabacademy.org/archives/2015/doc/networking-esp8266.html
  2. https://randomnerdtutorials.com/esp8266-nodemcu-tds-water-quality-sensor/
  3. https://randomnerdtutorials.com/esp8266-nodemcu-send-messages-whatsapp/