Thursday, June 28, 2018

ESP32: a microcontroller with WiFi

I have been learning how to program microcontrollers lately, starting with the Arduino Uno, then the Arduino Nano, and then moving on to the ESP8266 and ESP32. My favorite is the ESP32 by Espressif Systems, a company based in China.

Unlike the Arduino UNO and Nano, which are based on the Atmel's ATmega328 8-bit processor, the ESP32 is a 32-bit microcontroller with built-in WiFi. Yes, built-in WiFi. Its predecessor is the ESP8266, also by Espressif. But the ESP32 is much faster, at 240 MHz, and has more on-board RAM (520KB). And it only costs a few dollars.

Besides being able to connect to existing networks via WiFi, it can also act as its own access point, which means that even in places without WiFi, people can still connect to it. And there is also a function called ESPNow which allows two ESP32s to communicate directly with each other wirelessly. No need for a router in between. Cool!

A lot of information on the ESP32 can be found at esp32.net. This includes information on the versions of the chip itself, modules, and development boards. Many development boards can be found on eBay or Aliexpress; just search for "ESP32 development board" on these sites. You can also buy a PCB module (such as the ESP-32S) and solder it onto a breakout board. A development board which seems quite interesting is the MH-ET ESP32 MiniKit. There is also the ESP32-DevKitC V2 from Espressif. There are also development boards with OLED, with battery holders, and even LoRA. Andreas Spiess has compiled a great comparison of what's available here.

Programming the ESP32 used to be via C using the development framework provided by Espressif, but there is now support for Arduino-style programming too.
https://github.com/espressif/arduino-esp32

If you only needs a few GPIO pins to do simple stuff, an 8-bit controller like the ATmega328, or even ATtiny85 would be enough. But once you start to do something more complex, I guess the ESP32 would be a better candidate. Personally, that's what I do now. 8-bit controllers for the simple stuff, ESP32 for everything else.

There are even people trying to design controller boards for 3D printers using the ESP32.
ESPRamps
ESP32 3D printer controller
Even Marlin 2.0 (still under development, available as bugfix-2.0.x branch) is trying to include support for the ESP32 as a 3D printer controller. Wow!

That's all for now. I will subsequently touch on the boards that I use, which includes the M5Stack series that aims to make prototyping with the ESP32 that much easier. Until then!

No comments: