Skip to content

6. Embedded Programming

cover This week I worked on Embedded programming. We learn how to program the XIAO RP2040 board to interact with. It’s just amazing.

Assignement requirements

Group assignment:

  • browse through the data sheet for your microcontroller
  • compare the performance and development workflows for other architectures

Individual assignment:

  • write a program for a microcontroller development board that you made, to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)
  • extra credit: use different languages &/or development environments
  • extra credit: connect external components to the board

Group Assignement

Here you can fin the link to the group assignement.

When comparing the Seed RP2040, Arduino UNO, and Seed ESP32C3 in terms of performance and development workflows, here’s a breakdown:

Seed RP2040 vs. Arduino UNO

Performance:

  • Seed RP2040: Uses a dual-core ARM Cortex-M0+ processor running at up to 133 MHz, providing significantly higher computational power compared to the Arduino UNO.
  • Arduino UNO: Utilizes an 8-bit ATmega328P microcontroller running at 16 MHz, which is less powerful compared to the RP2040.

Development Workflows:

  • Seed RP2040: Often programmed using C/C++ in the Arduino IDE or MicroPython, benefiting from a more modern development environment and libraries. It also supports CircuitPython, expanding its versatility.
  • Arduino UNO: Typically programmed using the Arduino IDE with C/C++. It has a large community and extensive libraries, making it beginner-friendly and well-supported.

Seed RP2040 vs. Seed ESP32C3

Performance:

  • Seed RP2040: As mentioned earlier, dual-core ARM Cortex-M0+ processor running at up to 133 MHz.
  • Seed ESP32C3: Uses a single-core Xtensa LX7 processor running at up to 160 MHz, which gives it slightly better processing power than the RP2040 in single-threaded applications.

Development Workflows:

  • Seed RP2040: Supports Arduino IDE, MicroPython, and CircuitPython, offering flexibility in programming languages and environments.
  • Seed ESP32C3: Typically programmed using the ESP-IDF (Espressif IoT Development Framework) or Arduino IDE with support for both C/C++ and MicroPython. It offers more options for low-level customization through the ESP-IDF.

Summary:

  • Seed RP2040 generally offers better performance and a modern development experience with support for multiple programming languages, suitable for a wide range of projects including IoT and robotics.
  • Arduino UNO is simpler and very beginner-friendly with extensive community support, making it ideal for educational purposes and basic projects.
  • Seed ESP32C3 provides a balance between performance and development flexibility, with a focus on connectivity and applications requiring wireless communication.

Choosing between them would depend on specific project requirements, preferred programming languages, and the level of performance needed.

Individual Assignement

Here is the datasheet and other specifications of the microcontroller RP2040 i’m using :

Features

Item Value
CPU Dual-core ARM Cortex M0+ processor up to 133MHz
Flash Memory 2MB
SRAM 264KB
Digital I/O Pins 11
Analog I/O Pins 4
PWM Pins 11
I2C interface 1
SPI interface 1
UART interface 1
Power supply and downloading interface Type-C
Power 3.3V/5V DC
Dimensions 20×17.5×3.5mm

CAUTION

“For general I/O pins: Working voltage of MCU is 3.3V . Voltage input connected to general I/O pins may cause chip damage if it’ higher than 3.3V .”

“For power supply pins: The built-in DC-DC converter circuit able to change 5V voltage into 3.3V allows to power the device with a 5V supply via VIN-PIN and 5V-PIN.”

“XIAO RP2040 currently only supports battery power supply and cannot connect to Type-C while a battery is connected, as it may pose a safety risk.”

“Please pay attention to use, do not lift the shield cover.”

Programming

IDE Configuration

For more information on the RP2040 go on the official seed studio website It will give you everything you need to learn how to use your xiao.

  • Step 1 Open Arduino IDE software

  • Step 2 Add the Seeed Studio XIAO RP2040 board package to your Arduino IDE Go to File > Preferences and fill in the additional board manager URLs with the URL below: https://github.com/earlephilhower/arduinopico/releases/download/global/package_rp2040_index.json

  • Step 3 Go to the Board Manager by clicking on the board icon at the left side of the IDE and then enter the keyword RP2040 in the search bar. Select the latest version of Raspberry Pi Pico/RP2040 and install it.

  • Step 4 Now you can program and upload code for RP2040 by selecting the RP2040 board in Tools -> Boards -> Raspberry PI Pico/ RP2040 -> Seeed XIAO RP2040

Button interaction

For this program to interact with the microcontroller development board, I have used the push button as a local input device and the LED as an output device.

Here you will find the code :

const int LED = 26;
const int Button = 27;
boolean oldbuttonState = LOW;
boolean newbuttonState = LOW;
boolean LEDstatus = LOW;


void setup() {
  pinMode(LED, OUTPUT);
  pinMode(Button, INPUT_PULLUP);
  digitalWrite(LED, LOW);
}

void loop() {
  newbuttonState = digitalRead(Button);

  if (newbuttonState != oldbuttonState) {
    if (newbuttonState == HIGH) {
      if (LEDstatus == LOW) {
        digitalWrite(LED, HIGH);
        LEDstatus = HIGH;
      }
      else {
        digitalWrite(LED, LOW);
        LEDstatus = LOW;
      }
    }
    oldbuttonState = newbuttonState;
  }
}

Here the video of testing

Files


Last update: June 29, 2024