Arduino to ESP8266, 5 reasons to switch

Move over Uno, there's a new board on my bench

Adafruit ESP8266 HUZZAH Feather

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.

AnalogWriteFreq(1000);

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.

Wire.pins(sda, scl)

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 

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.

Conclusion

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.

Long comments, URLs, and code tend to get flagged for spam moderation. No need to resubmit.

Leave a comment

10 thoughts on “Arduino to ESP8266, 5 reasons to switch

  1. I use the ESP8266 for most of my projects as well. I know what you mean about the cheap imports. A strong contender is the Wemos D-1 Mini’s. But you have to be careful and only get them from WEMOS.CC. $4.00 each.
    At 1st I had purchased a few of the bare-bones chips and building power modules, then I was introduced to Wemos D-1 minis! I have yet to use a Huzzah. Maybe next purchase from Adafruit, I’ll throw one in the basket.

    THANKS for all the great tutorials and assistance. I have leaned a lot

  2. Hi James,

    Thanks for the nice blog post! I must say that 700mA is quite a lot. I am using the Atmel ATMEGA328P with an NFR24L01 RF module to measure temperature, humidity and pressure. That one draws only about 40mA when transmitting.

    Power consumption was one of the reasons for me not to opt for the ESP8266. In addition that would have me use a pretty large LiPo battery as well.

    Cheers! Sacha

    • It’s something I want to study more. The ESP8266 is drawing around 50mA while idle. But when my LiPo lasted overnight, I realized it must be more dynamic. Really though, for battery operations, I’m looking at ZigBee radios connected to MSP430s.

  3. Hi James.
    Another great blog post – thank you. I especially enjoyed the MQTT ones – great stuff.

    I am a little confused on this one. If the battery is 2500mAh and the board draws 700mAh, how is it that it ran for almost two days? I would expect around 3-4 hours. It may be a typo, 70mA works better from a calculation point of view, but sounds a little low. Have I missed something?

    Thanks.
    Pete.

    • I measured the board drawing up to 700mA when the WiFi radio was transmitting. Since the board doesn’t transmit continuously, it is not drawing the full 700mA at all times. (This is why it isn’t 700mAh).

      • Have you looked at “ESPEasy”? It is an incredibly easy to use firmware for the ESP8266, It includes a lot of features, like deep sleep, OTA updates (from a browser interface and drivers / easy configuration for multiple sensors. It is designed to work with several different home automation systems, as well as MQTT. It took me several weeks to get anything working before I found this one. With this I had 2 modules with multiple sensors running and recording data to my computer in a day. It is the easiest and most flexible software for the ESP8266 I have found. esp8266.NU Documentation is good but not perfect, the forum is good and there is a link their github with the source. Uses Arduino IDE.