Skip to content

5. Embedded Programming

Adam Durrett: Documentation, Template for Microcontroller Comparison, Comparison Dan Stone: Documentation, Added ESP32s2 Specs to Comparison Table from Datasheet Zack Budzichowski: Added ESP32s2 Specs to Comparison Table from Datasheet

This week, the Charlotte Latin Fablab worked on researching and documenting 3 different microcontrollers:

  1. The ever-popular rp2040
  2. An energy efficient king, the ATtiny1614
  3. Last but not least, the one that's always doing the talking: the ESP32

What did we compare?

Below, you can see a table that we all worked on containing different specs and sources to documentation for each controller.

How we tested the read/write speeds

To compare operating speeds, we used the Flip-Bit test suggested by Neil during his lecture. This consisted of a simple operation of connecting two pins on the board, and setting one to input and one to output. The output pin will write out the opposite of what the input pin reads, making it constantly switch between states. We then used an oscilloscope to measure the frequency of these rising and falling edges (a read/write per edge).

Here is some example code of what that might look like using the Arduino library:

void setup(){
  pinMode(5, OUTPUT);
  pinMode(4, INPUT);
}

void loop(){
  while(1){
    digitalWrite(5, !digitalRead(4));
  }
}

Here is what the output looked like on the oscilloscope:
Note the frequency in the top right corner of the oscilloscope. This is the frequency we used to compare performances between the chips.

Analysis and Conclusions

It would be unfair to say which micocontroller is the best, because these each have their own use cases. The RP2040 seems to be the most robust, containing 2 cores, a 264kB of SRAM and 16MB of flash. The performance of the flip-bit test was 4 times better than the esp32s2, and 200 times faster than the ATtiny1614. The rp2040 would be more ideal for projects that need the processing power, such as machine learning, managing multiple peripherals and other resource intensive tasks.

While all of the above chips can run at 3.3V, meaning the ability to be battery powered, the ATtiny can run on as low as 0.55V, making this ideal for low power or simple applications. The fairly reasonable 20MHz clockspeed on this chip is very capable of managing a few peripherals. While limited to 16Kb flash and 2Kb of SRAM, the ATtiny1614s can be used as the heart of a simple project such as a spectrum analyzer, or as an addition to a main microcontroller, to manage some task to reduce the load on the main microcontroller. An example of this could be using the ATtiny to receive serial data from a sensor, and send it to the rp2040. Then, the 2040 can focus on whatever machine learning algorithm you decided to use with your data from the ATtiny peripheral. Cheap, simple, and convenient!

The ESP32 series definitely takes the spotlight for wireless and IoT applications. The popular dual-core processer comes with wifi, radio and ESPNOW protocols for wireless communication. The ESP32s2 however, takes the approach of using a faster single-core processor, unlike the other ESP32 series which use less-efficient(individually) dual-core processors. This removes the option of doing parallel processing and simultaneous multitasking, but the speed of the XTensa LS7 can make up for this. Since it uses one core, the ESP32s2 uses a lot less energy than the original ESP32 series. The use cases for the ESP32s2 are similar to that of the rp2040. It has a lot of peripherals and added features, a speedy 240Mhz clock and can be programmed in almost any language. The rp2040 will be better at tough computations thanks to the dual core processor, but it usually doesn’t come with wireless coms built in. You have to use a component attached to it externally for that. From the bit-flip test, I was surprised to see that it was 4 times slower than the rp2040. But this could be due to a number of factors, such as using the arduino library as opposed to bare-metal. Further tests on bare-metal processing speeds will need to be done in the future. It even includes a RISC-V ULP coprocessor which can be useful for sleep mode, or small computations during normal operation.

In short, each chip has its own use-cases. All of them use accessible architectures, and give you plenty of opportunities to be used in your circuits and applications.


Last update: March 2, 2023