The ESP Is Better Than The Arduino For Smart Home DIY
When we are building smart devices ourselves, either to reduce cost or to customize the installation, there are a lot of choices to be made in terms of which components should be used. The most important component to projects in the smart home industry is arguably the microcontroller, which is responsible for keeping everything moving along smoothly. Many will immediately think of board such as the Arduino, while others might be thinking of the ESP8266 or ESP32. Which board should you use to build your DIY project?
Disclaimer: This post contains affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Table of Contents
What do we need for smart devices?
There are a lot of features that come on each one of these boards, such as EEPROM, Flash, PWM pins, voltage levels, WiFi, current consumption, and much more. Which of these is actually important for building smart devices? The truth is that they are all important in some ways, but there are certainly some features that are more important in the context of a smart device. A critical piece of any smart device is its ability to communicate with the outside world. In fact, most of the time, the only difference between a regular device and a smart one is the latter's ability to communicate with a controller.
It is common for a smart home controller to have automations that will trigger when specific events occur, which will then send an action to a device via some protocol. DIY projects can either be for smart inputs or smart outputs, which is to say you can either record information or perform an action when a command is received (sometimes even both!). Another consideration could be the board's current draw, which is important when running on batteries. To see how much of a pain that can be, check out my battery-powered IoT button here! For some projects, you don't want a super-powerful microcontroller as it will drain your batteries too quickly.
Points of comparison
There are many points to compare with each, but here are the ones I believe are the most important for shaping a decision. Keep in mind this is a general point of view, meaning that for some unique projects, the important factors will be quite different. These are meant as general guidelines rather than project-specific advice.
As we saw earlier, communication really is at the core of any good smart home, and as such is a critical factor in choosing one board over another. Both the ESP8266 and the ESP32 have a built-in WiFi antenna which allows it to connect to a 2.4GHz WiFi network right out of the box. The ESP32 is the same but also supports Bluetooth right out of the box, which can be useful for certain projects on a shorter range. The Arduino does not have any built-in WiFi or Bluetooth capabilities and most boards that do are insanely expensive, which makes it far too impractical to use.
While searching for a way to add WiFi to an Arduino, you will often find information on using an ESP8266 as a WiFi module that will bridge incoming messages over. The problem with this approach is that the ESP is a fully capable microcontroller of its own that actually has better features in many cases. So for someone to buy one only as a bridge for an Arduino would be a bit of a waste of money and space. Even the cheapest ESP-01 can still rival the Arduino in many ways, although it only has 2-4 IO pins compared to the Uno's 14. However, it does have WiFi connectivity which the Arduino is lacking.
An important feature to any programmable board, memory is both where the project software lives and where important runtime information is stored. There are three types of memory that are important to this discussion: Flash, SRAM, and EEPROM.
- Flash is the space where your program is stored.
- SRAM (static random access memory) is where variables and other temporary processing data is stored while it is being used
- EEPROM (electrically erasable programmable read-only memory) is a space where values can be stored while persisting power cycles. This memory is often emulated using Flash in the boards we are discussing today.
Both Flash and EEPROM are non-volatile memory, meaning they are not erased when the power is lost, while SRAM is volatile meaning it is erased when the power is lost.
The ESP8266 does not have a Flash chip built-in while the ESP32 does. That means that the size of your ESP8266 Flash will largely depend on the specific board you got. As an example, the NodeMCU will usually have an onboard chip of around 4MB. On the other hand, the ESP32 typically has 4MB directly built-in, though the sizes could vary a bit. That has an important implication for those who don't use development boards, as you will need to provide your own Flash chip. What about the Arduino? Well, the Arduino Uno only has a Flash size of around 32K - much smaller than the one in most ESP boards.
This value is significant for battery-operated devices as even a current draw of a few milliamps will quickly deplete a typical battery. Note that we are excluding Lithium-Ion batteries from this as they are much more difficult to work with than your typical alkaline type. As a result, low current consumption is essential to having a long-lasting battery. No one wants to be changing the batteries every week, so it's important to consider how long your circuit will last carefully. Let's use a typical AA battery which has a rated capacity of 2000mA-hours. With a single LED using 10mA, we would expect the battery to last 200 hours which is actually just over one week. It's easy to see how carefully the circuit must be designed with that comparison made!
The Arduino has mixed reports with various values, but it seems like most can agree the Uno will consume roughly 35mA at all times while connected via USB. It's important to note that a significant amount of that comes from the FTDI chip which allows USB communication with a computer, so a model without that could perform much better. The ESP8266 will typically draw around 70mA when idle with the WiFi modem on, which is much worse! Luckily, the ESP can deep-sleep, which is where only a few critical components remain powered. In this mode, it will only consume around 20uA. The ESP32 uses slightly more, consuming 115mA with everything active and 10uA in a deep sleep.
The important thing to note is that extra components will increase the current draw, so any board with a USB plug should be avoided in all battery applications. Even a simple transistor inverter circuit can draw 10-20mA, which is enough to ruin the otherwise great deep-sleep consumption of the Arduino or an ESP. This is why I had to use MOSFETs in my IoT button, as otherwise, the extra components ruined the performance. While we didn't cover them to keep things simple, Lithium-Ion batteries have much higher capacities than alkaline and should be considered if you need a lot of power for a project. They are just a lot more difficult to use due to the dangers of explosion if they overcharge or undercharge, so be careful and follow the instructions!
The price will vary immensely over time, but typically an ESP board can be obtained for around 7$ while an official Arduino board is likely to cost more around 20$. If you are willing to use an Arduino clone, which is compatible but built by a different manufacturer and could have some differences with an official board, you'll probably pay around 10$. Those who do want to use Arduino should consider using a high-quality clone as those will often have some of the improvements we mentioned earlier. For tiny projects, there is also the ESP-01 which only has about 4 IO pins but can cost as low as 2$ a piece. This is the board I used in my IoT button, as I needed something tiny but still capable.
Price is an important consideration in virtually every situation, but especially for smart homes, as it is likely, you will need to buy quite a few to get everything done. When buying 1 of something, a difference of 5$ is fairly negligible. On the other hand, when buying 50 of something, a difference of 5$ would result in a 250$ saving by using the cheaper one. Since it is much easier to maintain a system that is built on the same technology, I would recommend you try and use the same microcontroller in each project. As a bonus, if all the boards are similar, it becomes easy to swap one out should something break.
There are quite a few aspects we didn't even touch on here, but those will be quite specific to each situation. Overall, the ESP has become the king of smart home DIY projects through being the cheapest and having a WiFI chip built-in. If you want to build a project for your home, you are almost always better off using an ESP instead of an Arduino. As a bonus, those with previous Arduino knowledge can use the same IDE to program an ESP by using a plugin. Many of the important libraries have been ported from Arduino to the ESP as well, which makes it easy to use code found online no matter which platform it was written for!
As for the specifics, the ESP32 should only be used for power users who have a specific use in mind as most of its benefits aren't typically used in beginner projects. Anything involving a battery should avoid development boards like the NodeMCU or the Arduino Uno and instead either get the ESP chip directly or the ATMega328 chip. Another option is the ESP-01 which has no onboard USB and limited support components, allowing you to minimize power consumption. If an Arduino is desired, I recommend the use of a high-quality clone board that supports additional features.