Arduino

Is ESP32 Better than Arduino

Both Arduino and ESP32 are microcontroller-based boards that can take inputs and generate output accordingly. Both these boards are famous among students and researchers because they don’t need any extra hardware like CPU to process the information, one just needs a tiny board that can fit in your pocket and perform tasks easily. But a question comes to everyone’s mind is ESP32 better than Arduino.

ESP32 vs Arduino

ESP32 is a low-cost microcontroller board having a 32-bit microcontroller chip that can run on low power. ESP32 has integrated Wi-Fi and dual Bluetooth available. It is created by the Espressif system. ESP32 is the successor of ESP8266 boards created by the same manufacturer. Based on ESP32 cost, size, and power consumption it’s the best fit for an IoT based DIY project. ESP32 chip contains Tensilica Xtensa LX6 microprocessor having dual core and clock rate of frequency over 240MHz.

While on the other side when we hear the word microcontroller the first name that comes to our mind is Arduino, as Arduino is leading the microcontroller boards for so long time because of its wide support available along with a series of different boards starting from 8-bit Uno to 32-bit zero. Arduino boards are based upon ATmega AVR microcontrollers. Arduino boards start from nano that are perfect fit for small size projects to Arduino mega that can handle multiple devices thanks to its 54 digital input/output pins.

Is ESP32 Better than Arduino

Yes, ESP32 is a better and more powerful microcontroller board than Arduino. ESP32 has inbuilt dual Wi-Fi and Bluetooth support. It has full TCP/IP support for full stack internet connection. Thanks to its Wi-Fi module it can act as an access point as well as a Wi-Fi station. Because of its 32-bit microcontroller and clock frequency of up to 240MHz it is far ahead than Arduino.

Following highlights gives a better perspective of why ESP32 is better than Arduino:

  • ESP32 have 32-bit microcontroller
  • Dual Wi-Fi and Bluetooth support
  • Works on low voltage level (3.3V)
  • ESP32 has 18 ADCs channels while Arduino Uno has only six
  • ESP32 comes with 48 GPIO pins while Uno has only14 digital input/output pins and 6 analog pins
  • The ESP32 board is cheaper than the Arduino Uno

To read a comparison between Arduino and ESP32 click here.

Speed Comparison of ESP32, Arduino Uno and Arduino Mega

Following are the clock frequencies of microcontroller board ESP32, Arduino Uno and Mega.

Arduino Uno: 16MHz internal clock

Arduino Mega: 16MHz internal clock

ESP WROOM 32: Adjustable between 80MHz to 240MHz.

We all know microcontrollers rely on their clock source. A more powerful clock means less time to execute instructions. Let’s see the difference between the speed of all above three microcontrollers boards.

unsigned long Start_Time, Time_Taken ;
#define pin 5     /*pin 5 defined to change its state*/    
void setup() {
  Serial.begin(9600);  /*Baud rate defined for serial communication*/
  pinMode(pin, OUTPUT); /*pin 5 defined as output*/
}
void loop() {
  Start_Time = millis(); /*start time equals to Millis counter*/
  for (int i = 0; i < 20000; i++) {  /*for loops runs for 20000 time*/
    digitalWrite(pin, HIGH);  /*pin state changes to HIGH*/
    digitalWrite(pin, LOW);   /*pin state changes to LOW*/
  }
  Time_Taken = millis()-Start_Time ;  /*Time difference calculated to return time taken*/
  Serial.print("Time Taken to change state at PIN 5: ");
  Serial.print(Time_Taken); /*Total time taken is printed*/
  Serial.println("ms");
}

First, we have initialized two variables Start_Time and Time_Taken. One will store the starting time in Millis while the second one will store the total time taken by the microcontroller to switch between two states that are HIGH and LOW.

Next in the loop part of the code a for loop is used that will rotate 20,000 times and makes pin 5 as HIGH and LOW alternatively. Next, we take the difference of starting time with current Millis once the state changes from HIGH to LOW. Here the time difference between present Millis and previous Millis will define the time taken by board to switch states.

ESP32 Output

As ESP32 has greater clock frequency than Uno and Mega so it will switch between states very fast. Here output represents it takes 5ms to switch from HIGH to LOW state.

Arduino Uno Output

The Arduino Uno board has an external clock of 16MHz so it will take 172ms to switch a pin state.

Arduino Mega Output

The Arduino Mega board will take 227ms to switch between states.

From the above result we concluded that ESP32 is faster than Arduino Uno and Mega.

Brief Comparison of ESP32 vs Arduino Uno vs Arduino Mega

Here is a brief comparison of ESP32 boards with Arduino competitors Uno and Mega.

Characteristics ESP32 Arduino Uno Arduino Mega
Digital I/O Pins 36 14 54
DC current per I/O pin 40mA 20mA 20mA
Analog Pins Up to 18 6, 10-bit ADC 6, 10-bit ADC
Processor Xtensa Dual Core 32-bit LX6 microprocessor ATmega328P ATmega2560
Flash Memory 4 MB 32 KB 256 KB
SRAM 520 kB 2 KB 8 KB
EEPROM None 1 KB 4 KB
Clock Speed 80MHz to 240Mhz 16 MHz 16 MHz
Voltage Level 3.3V 5V 5V
Wi-Fi  802.11 b/g/n None None
Bluetooth v4.2 BR/EDR and BLE None None
I2C Support Yes (2x) Yes Yes
SPI Support Yes (4x) Yes Yes
Hardware Serial Port 3 1 1
USB Connectivity  Micro-USB USB-B USB-B

 

Conclusion

While buying a first microcontroller board or working on multiple boards a question which comes in everyone’s mind is which of the microcontroller boards is best. So, we concluded that ESP32 is better than Arduino board because of its affordable price, low power consumption and super-fast external clock with WiFi and Bluetooth support. ESP32 provides more functionality compared to Arduino boards.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.