Then, upload the code to the board, and connect the jumper cable again. Also modify the WiFi credentials inside the code. It’s now time to test the project! First, remove the connection between DTR and XPD, so you can actually program the board. You can get the whole code from the GitHub repository of the project: Note that here we need to put the whole code inside the setup() function of the sketch, as whenever the chip goes out of deep sleep mode, it starts again at the start of the setup() function. Then, inside the setup() function of the sketch, after sending the request to Dweet.io we put the chip in deep sleep mode: Serial. For test purposes, I set it to 10 seconds here: const int sleepTimeS = 10 First, we define how long we want the chip to stay in deep sleep mode. This code is quite long, but let’s now focus on what we need for the deep sleep functions. String line = client.readStringUntil('\r') Read all the lines of the reply from server and print them to Serial This will send the request to the serverĬlient.print(String("GET /dweet/for/myesp8266?message=lowpower") + " HTTP/1.1\r\n" + Use WiFiClient class to create TCP connections Serial.println("ESP8266 in normal mode") This is the complete code for this part: // Library This will for example illustrate a data logger project that will only make measurements every 10 minutes for example, and sleep the rest of the time. As a simple example, we are going to log a simple dummy message to Dweet.io, which is a cloud service that is used to log data online. To do that, we are going to use the deep sleep functions of the chip, that will simply sleep when no actions are required. We are now going to see how to lower the power consumption of your ESP8266 WiFi chip. Reducing the Power Consumption of Your ESP8266 This is a picture from farther away, showing the connections to the multimeter: Here is a closeup picture of the project: Here, I want to measure the power consumption as well, so I’ll also be using a breadboard power supply, and connect the power to a multimeter so I can measure the current flowing through the chip. If you just want to use the project with a low power consumption, you simply need to connect the DTR pin of the board to the XPD pin, which will make sure the chip can wake up from the deep sleep mode. As we just want to lower the power consumption of the board, the configuration will be quite simple here. You will also need the latest version of the Arduino IDE, as well as the ESP8266 board definitions. This is the list of the required components for this project: You will also need a 3.3V FTDI USB adapter, as well as a breadboard and jumper wires. Optionally, to test the power consumption part, you will also need a breadboard power supply, a multimeter, and a LiPo battery. Here, I choose the SparkFun ESP8266 Thing as it allows to work at very low powers. Here, as we want the project to be low-power, the most important is to choose a board without a lot of features, so there are no extra components to reduce the battery life of your project. The first thing you need is an ESP8266 board. Let’s first see what we need to build this project. Let’s dive in! Hardware & Software Requirements That’s why in this article, I will show you how to significantly reduce the power consumption of your ESP8266 boards using the deep sleep mode of the chip, so you can build projects that will last for years on a single battery. For example, an ESP8266 chip with a standard 2500mAh LiPo battery would last for about 30 hours. This is for example the case for a motion sensor that you will install in your home, or a data logger you would put in a remote location.įor those cases, you don’t want to be changing the batteries constantly. However, in some cases, we want to build projects that are only powered by batteries. I for example build data loggers that are constantly connected to the mains electricity, and appliances controller which also have an easy access to power. For most of the projects I am building with the ESP8266 WiFi chip, I usually don’t care too much about the power consumption aspect.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |