A couple of weeks ago I posted four things to know about the ESP8266 before using one. The biggest surprise from that post is people seem to think I do not like the ESP8266! This idea is not the case; the ESP8266 is awesome. I like them so much that my Adafruit Feather HUZZAH with ESP8266 has become my go-to Arduino board.
Wait what? James uses something other than Arduino? Yes, I do! I have many different boards and have used most of them for one task or another.
However, when it came to day-to-day “make something quickly” type work, I relied on my Uno. But not anymore. Here are the 5 reasons the ESP8266 is my go-to Arduino board.
1. ESP8266 is ideal for Internet of Things (IoT)
My current project involves home automation and IoT stuff. That is why my last two tutorials introduced MQTT and showed how to make MQTT work with an ESP8266. With built-in WiFi, these boards are ideal for Internet activities.
One area I have not worked in yet is putting the boards to sleep. WiFi causes the board to draw about 700 mA. When hooked up my Adafruit HUZZAH Feather to a 2500 mAh Lithium Ion battery, it ran for almost two days. The code was basic. It would send the status of a PIR Sensor over WiFi to an MQTT broker every 2.5 seconds.
That is pretty impressive battery life without doing any optimizations or sleep modes.
2. Programmable PWM Frequency
While building an RGB PWM controller with my Uno, I found the Uno’s PWM created a buzzing noise. Running close to 600Hz, that is not a surprise. My decoupling capacitors were singing due to piezoelectric effects. One option is to change the PWM frequency, but that would mean digging in the Arduino libraries. Possible, but more work than I wanted to put in at the moment.
The ESP8266 core of the Arduino library, however, has a built-in PWM frequency call. Changing the PWM frequency is easy.
Another bonus is the PWM resolution. The ESP8266 core has 1024 (0-1023) levels of pulse-width instead of Arduino’s 256 (0-255). This resolution means smoother LED fading and more precise motor speed control.
Lastly, any of the GPIO pins can be used for PWM. With clever software, you can make any pin on an Arduino do PWM using Software PWM. Being able to use hardware PWM on any pin makes the ESP8266 very flexible.
3. You can I2C on any pins.
Along with PWM, you can use any of the GPIO pins for I2C communication. I2C is done through bit-banging. The Adafruit HUZZAH board identifies GPIO “4” and “5” as I2C for convenience. A simple call before initializing the wire library allows for I2C communication on any of the module’s pins.
For I2C testing, my test device is a high-side current sensor, part of my RGB LED strip controller. It is monitoring the current, to make sure I do not overload the supply.
Not having dedicated I2C hardware might seem like a performance issue, but in my limited testing, I have not noticed. In fact, I was not aware it was bit-bang until I looked a little deeper into the core.
4. Works with Arduino IDE
This reason for switching might seem a little counter-intuitive: the ESP8266 works well with the Arduino IDE. Just install ESP8266 support through the Arduino IDE’s board manager and most of the function in the Arduino Library work out of the box.
I did run into some issues with EEPROM. Turns out the EEPROM library is different and requires a few changes from “standard Arduino code.”
EEPROM.begin(1024) // size: 4 to 4096 bytes EEPROM.write(0,0xFF); // write to EEPROM EEPROM.commit(); // commits&nbsp;
Once you add “EEPROM.begin(size)” and EEPROM.commit(), it works just like EEPROM on any other Arduino board.
5. ESP8266 Breakout boards are inexpensive
My choice is the Adafruit HUZZAH and Adafruit ESP8266 breakout. These do cost a few dollars more than the modules found on eBay. However, as I said in my previous ESP8266 post, I’m not a fan of those cheap modules.
The Adafruit ESP8266 boards have incredible build quality, nice features (like all the necessary pull-ups), and support a company that supports the maker community in countless ways.
The key reason I picked the HUZZAH Feather is the built-in serial adapter. The built-in battery charger is nice to have as well, but I don’t seem to be using it as much as I originally thought.
When I get a chance to use the Arduino 101, I may change my mind. However, for now the ESP8266 is my go-to IoT board and general purpose “Arduino.”
The ability to quickly switch my “Arduino code” from an Uno to an ESP8266 is a huge draw. The seamless WiFi connectivity makes internet communications very easy. Incredibly flexible GPIO with programming PWM frequency and high resolution even eliminated the need for a dedicated PWM chip. All of these reasons are why I have a nerd crush on the Adafruit HUZZAH Feather ESP8266 module.