Skip to content

Embedded Programming

MCU Arch. MHz Flash/SRAM GPIO IDE $ Use Case
ATtiny85 8-bit AVR 20 8KB / 512B 6 Arduino, AVR GCC 2-3 Small IoT, LEDs
ESP32 Xtensa 32-bit 240 4MB / 520KB 34 Arduino, ESP-IDF 4-10 IoT, Wi-Fi, Smart Home
ESP32-C6 RISC-V 32-bit 160 4MB / 512KB 22 ESP-IDF, PlatformIO 5-10 Low-power IoT, Wi-Fi 6
RP2040 ARM M0+ 133 2MB / 264KB 26 MicroPython, C++ 4 Robotics, DIY gaming

ATtiny85

Instead of using a bare ATtiny85 we worked with the Digispark ATtiny85 development board and to be honest this probably wasn’t the smartest choice. The ATtiny85 still is an amazing microcontroller in and of itself but setting up the development board for programming was a gigantic pain in the rear because most of the “official” resources were no longer available. After way too much time searching and combing through Reddit threads for useful information we finally got it to work. Here is how we did it:

  • first of all install the Arduino IDE and make sure to accept all the popups that ask you to install drivers

  • upon opening the software for the first time you should be looking at somthing like this

  • in the top left corner click on File and head into the Preferences menu

  • scroll all the way down to Additional boards manager URLs and paste the following link into the box:

https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json

  • click OK in the bottom right corner and wait for the download/installation to finish

  • next click on the boards manager icon on the left

  • search for digistump avr boards and install the package

  • the last thing to do is installing the drivers

  • head to this link and download the Digistump.Drivers.zip file

  • open DPinst64.exe or DPinst.exe depending on if you have a 64 or 32 bit system installed

  • there will be a lot of security warnings asking you if you are absolutely, 100% sure you want to install these but multiple virus scans have shown that everything is fine

  • if you see this in your device manager, you are good to go

  • we could have saved a whole lot of time if the manufacturer had given us these infos instead of dead links at the start but here we are…

  • after restarting the Arduino IDE you should now be able to change the board to ATtiny85 w/Mirconucleus (Digispark)

  • the COM port strangely doesn’t matter all that much because flashing the board works by first compiling your code, clicking the Upload button and only after that connecting the development to your computer via USB

  • another quirk when uploading is that you cannot have the VCC or GND pins connected to anything or the board will skip the short period in which it can be flashed

  • we took the simulated code from Julian’s page, removed the serial monitor parts changed up some pins and built this circuit to test it live
  • here is the code if you want to test it for yourself:
#define RED PB1
#define GREEN PB2
#define POT PB3

void setup() {
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(POT, INPUT);
}

void loop() {
if(analogRead(POT)<=512){
  digitalWrite(GREEN, LOW);
  digitalWrite(RED, HIGH);
  delay((1024-analogRead(POT))/2);
  digitalWrite(RED, LOW);
  delay((1024-analogRead(POT))/2);
}
else{
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, HIGH);
  delay(analogRead(POT)/2);
  digitalWrite(GREEN, LOW);
  delay(analogRead(POT)/2);
}
}

RP2040

The RP2040 is a dual-core 32-bit ARM Cortex-M0+ microcontroller made by Raspberry Pi. It is designed for low-cost and high-performance embedded projects. It runs at a clock speed of 133 MHz, making it efficient for embedded applications that require real-time processing. Unlike microcontrollers like the ESP32, the RP2040 usually does not have built-in Wi-Fi or Bluetooth (but there are some development boards on the market that do)

The microcontroller includes 2 MB of onboard Flash storage and 264 KB of SRAM, providing enough space for complex applications and multiple tasks running simultaneously. It supports up to 26 GPIO pins, with built-in features such as PWM, I2C, SPI, UART, and programmable I/O (PIO), which allows for custom communication protocols. The RP2040 is well-suited for hardware control, real-time signal processing, and robotics.

The RP2040 can be programmed using several development environments (IDEs) and toolchains.

There are multiple options available on the market. The two we worked with are the Raspberry Pi Pico and the Arduino RP2040 Connect, that has build in sensors (microphone, accelerometer, gyroscope, temperature) and connectivity like bluetooth and WiFi (Nina W102 uBlox module) 1) Arduino IDE Suitable for Arduino RP2040 and Raspberry Pi Pico. Uses C/C++ with the Arduino framework and it is possible to one-click-upload via USB. It has a broad support for libraries for sensors and modules and is very beginner friendly.

1) MicroPython (Thonny IDE or Mu Editor) With Thonny IDE or Mu Editor you can flash the MicroPython firmware onto the RP2040. It is easy to write and test simple scripts and great for sensor interfacing and quick projects. Python scripts must be written using REPL (Read-Eval-Print-Loop). Using Thonny IDE or Mu Editor you can upload and run your script on the board.

2) VSCode and Platformio

Another possibility is to combine Visual Studio Code (also called VS Code) and PlatformIO. It provides a development environment for both, Arduino RP2040 and Raspberry Pi Pico and offers advantages such as: Git integration, advanced debugging and the support for multiple programming frameworks including Arduino framework (C++), Pico SDK (C/C++) and MicroPython.

The RP2040 is an affordable microcontroller, and costs around $4. While it lacks wireless connectivity, its dual-core processing, flexible GPIO, and support for multiple development environments make it highly versatile for robotics, gaming projects, real-time control systems, and DIY electronics.

Programming the RP2040 Connect with Arduino IDE

First we started the Arduino IDE and selected the RP2040.

  • We wrote a simple blink sketch and used two LEDs and two resistors
    • We selected the designated port in the software
  • we uploaded the sketch and voilá - the leds were blinking!

Programming the RP2040 Connect with Micropython

  • Place a jumper wire between the REC and GND pins on the board, then connect the board to your computer.
  • A detailed description can be found at https://docs.arduino.cc/tutorials/nano-rp2040-connect/rp2040-openmv-setup/

  • When the board is connected, it will open a mass storage device. You can now remove the jumper wire.

  • Install Thonny IDE from https://thonny.org

  • Open Thonny IDE and select “Options” and “Interpreter”

  • Before you can program your RP2040 with MicroPython you need to install the firmware on your microcontroller via clicking on “Install or update MicroPython”

  • Once you have installed MicroPython you can simply program you controller using Thonny IDE and MicroPython.

ESP32-Wroom

Programming the ESP32 Wroom with Micropython and Visual Studio

  1. Preparation
  2. Download MicroPython for the ESP32 Click here for the Link

  3. Download the Silicon Labs VCP driver Click here for the driver

  1. Install Drivers & Find the Port
  2. Install the USB driver (if not already installed)

  3. Connect the ESP32 and find the COM port in the Windows Device Manager

  1. Set Up the Development Environment
  2. (Optional) Create a virtual Python environment if working with Python

  • Install ESPTool to flash the ESP32:
    bash pip install esptool

  1. Prepare ESP32 (Erase Flash)
  2. Verify that esptool is correctly installed:
    bash esptool.py version

  3. Erase the flash memory:
    bash esptool --port [PORT] erase_flash

  4. Flash the Firmware

  5. Flash the MicroPython firmware onto the ESP32:
    bash esptool --port [PORT] write_flash -z 0x1000 [FIRMWARE_LINK.bin]

  1. Set Up VS Code
  2. Download and install VS Code Click here for the download

  • Install the Serial Monitor extension (Extensions -> Search for ‘Serial Monitor’)

  1. Write & Run MicroPython Code
  2. Install ampy to upload files to the ESP32:
    bash pip install adafruit-ampy

  • Connect to the ESP32 via the serial monitor

  • Write a simple MicroPython program and upload it:
    bash ampy --port [PORT] put [PYTHON_FILE_LINK.py]

Our Code for blink an LED:

import machine
import time

led_pin = 2
sleep_time = 0.5
led = machine.Pin(led_pin, machine.Pin.OUT)
print('Configuration done...')
while True:
print(f'Turning LED on PIN{led_pin} on for {sleep_time} seconds...')
led.on()
time.sleep(sleep_time)
print(f'Turning LED on PIN{led_pin} off for {sleep_time} seconds...')
led.off()
time.sleep(sleep_time)
  1. Run the Program
  2. After uploading, restart the ESP32 (press the reset button)

  • Check the output in the serial monitor and start the program with:
    python import [PYTHON_FILE_NAME]

Now you can see the setting is working: