9/18 Embedded Programming
Group Assignment: demonstrate and compare the toolchains and development workflow for alternative embedded architectures
Use case / Application #1: Wifi + Bluetooth + Servo
Chip:Xiao ESP32S3
Contributed by: Adi Kupershmidt
Capabilities:
- Dual-core processor that can support both communication and servo at the same time
- Multiple GPIO pins, including PWM for servo control
- Integrated Wifi and Bluetooth connectivity
- Low power consumption
- Robust (survives high and low temperatures, as well as external circuit imperfections)
- Plenty of libraries, examples, and community projects available) for ESP32
- Supports AI processing
- Compact (20X17.5mm)
Programming Workflow:
The ESP32, including the Xiao ESP32S3, can be used with either Arduino IDE or PlatformIO (an extension for VS Code).
I’ll probably choose the Arduino IDE for ease of use, here are the main stages for the workflow:
-
1. Set up the development environment for Arduino IDE
- a. Install Arduino IDE
- b. Install Xiao ESP32S3 board package, connect the board
- c. Set up a new project
- d. Install libraries
- 2. Write the code, and consider the pins you’ll be using for each component (like the servo engine). Optional: include Over-the-Air updates to update the software via Wifi in the future
- 3. Upload the code and flush the processor with it
Performance Considerations:
-
The XIAO ESP32S3 has 512 KB of SRAM and typically comes with 8 MB of Flash memory. Arduino IDE compiles code to run in RAM, so I might run into memory issues if the code or the data it uses is large (e.g., image processing or machine learning).
- Running complex operations (e.g., real-time video processing, AI tasks), might hit performance limits. It’s better to offload any possible computing tasks.
- Performance can degrade during heavy networking tasks like continuous data streaming or frequent image uploads. It’s better to limit the pictures taken with a cue.
Use case / Application #2: USB Communication + Sensor Data Acquisition
Chip:ATSAMD11D
Contributed by: Kareem El-Sisi
Capabilities:
- ARM Cortex-M0+ processor suitable for handling USB communication and sensor data processing concurrently.
- Multiple GPIO pins, including 10-bit ADC for precise sensor data acquisition.
- Integrated USB 2.0 Full-Speed Device for reliable USB communication.
- Low power consumption, ideal for battery-operated sensor devices.
- Small form factor, perfect for compact sensor modules.
- Robust and reliable, capable of operating in various environmental conditions.
- Compatible with a wide range of development tools (Microchip’s Atmel Studio, Arduino IDE).
- Simple architecture with focused features, making it easy to integrate into designs requiring USB and sensor interfaces.
Programming Workflow:
- Development Environment: Set up Microchip’s Atmel Studio or Arduino IDE.
- Code Development: Write and compile code using C/C++.
- Programming Interface: Use a programmer like the Atmel-ICE or a bootloader for USB-based programming.
- Testing: Deploy and test the code on the ATSAMD11D chip, monitoring USB communication and sensor data handling.
- Debugging: Utilize integrated debugging tools in Atmel Studio or external debuggers for troubleshooting.
Performance Considerations:
- Processing Speed: 48 MHz clock speed provides adequate performance for basic USB communication and sensor data processing.
- Memory Limitations: 16KB Flash and 4KB SRAM require efficient memory management for larger projects.
- Power Efficiency: Optimize for low-power modes during sensor data acquisition to extend battery life.
- Peripheral Management: Ensure proper configuration and timing of peripherals like ADC and USB to avoid bottlenecks.
- Data Throughput: Consider USB 2.0 Full-Speed limits (12 Mbps) when handling high data rates.
Use case / Application #3: Sleep Monitoring with Wi-Fi + Bluetooth Connectivity
Chip: Xtensa ESP32
Contributed by: Kenneth Oranga
Capabilities:
- Dual-core processor: can handle simultaneous sensor data collection and wireless communication.
- Multiple GPIO pins: allowing for connecting more sensors (heart rate, temperature, etc.).
- Integrated Wi-Fi and Bluetooth: enabling real-time data transmission to a smartphone app or cloud-based system for sleep analysis.
- Low power consumption: ideal for continuous overnight monitoring without excessive battery drain.
- Robust and reliable: suitable wireless communication in a home environment with potential external interferences.
- Compact design: perfect for embedding in the headboard without adding much bulk.
- Plenty of libraries and examples are available for sleep-related projects using sensors like heart rate monitors, accelerometers, and microphones.
Programming Workflow:
- The ESP32 can be programmed using Arduino IDE, Platform IO, or ESP-IDF.
- The workflow includes:
- Setting up the development environment in Arduino IDE.
- Installing the ESP32 board package and connecting the ESP32 to your computer.
- Setting up a new project and identifying the GPIO pins to connect to the sensors (e.g., for monitoring body movement or snoring).
- Installing necessary/relevant libraries, such as the Wi-Fi, Bluetooth, and sensor libraries.
- Write the code to read data from the sensors and transmit it via Wi-Fi/Bluetooth.
- Optionally, implement Over-the-Air (OTA) updates for future wireless software updates.
- Upload the code and test the processor with your sensor setup.
Performance Considerations:
-
Memory: ESP32 has 512 KB of SRAM and can come with 4 MB of Flash, which is sufficient for typical sensor data collection and transmission. However, careful memory management is needed for larger, more complex projects.
-
Networking tasks: Streaming or frequent data uploads (e.g., real-time sleep data to a cloud server) could affect performance. Optimizing how often data is sent (batch processing vs real-time) can mitigate potential slowdowns.
-
Power efficiency: Using the deep sleep mode during inactivity periods can significantly reduce power usage and extend battery life for overnight monitoring.
-
Dual-core advantage: One core can manage continuous data collection from sensors while the other handles Bluetooth or Wi-Fi transmission, ensuring smooth performance without interruptions.
Use case / Application #4: LED Control with Wifi
Chip: Xiao ESP32S3
Contributed by: Javier Ricardo Diaz
Capabilities:
- Dual-core processor that can handle communication and LED control simultaneously
- Multiple GPIO pins, including PWM for controlling LED brightness
- Integrated Wifi for wireless control of the LED (e.g., from a smartphone or web interface)
- Low power consumption, ideal for small, energy-efficient projects
- Compact (20X17.5mm), suitable for small embedded devices
- Plenty of libraries, examples, and community projects available for ESP32
- Supports simple AI tasks if needed for future enhancements
Programming Workflow:
The Xiao ESP32S3 can be programmed with the Arduino IDE. Here are the steps for this project:
- Set up the development environment:
- Install Arduino IDE, and Xiao ESP32S3 board package, connect the board
- Set up a new project:
- Install libraries needed for LED control (e.g., WiFi, LED strip libraries if needed)
- Write code to connect the chip to a Wifi network and control the LED via a web interface or smartphone
- Upload the code: Flash the chip with your code
- Test:
- Ensure the LED responds to Wifi-based commands
- Optionally include Over-the-Air updates to simplify future modifications
Performance Considerations:
- The Xiao ESP32S3's 512 KB of SRAM and 8 MB Flash should be sufficient for this basic application
- Code needs to be optimized to handle multiple tasks (Wifi communication and LED control) without noticeable delays
- Networking tasks like establishing a Wifi connection might cause slight delays when adjusting the LED, but these can be mitigated with good code management
- Power consumption can be reduced by entering low-power modes when the LED is not active
Use case / Application #5: Game of Life Activation on LCD Screen via Wifi
Chip: Xiao ESP32C3
Contributed by: Sergio Mutis
Capabilities:
- RISC-V 32-bit single-core processor (designed for efficiency and low power consumption).
- Integrated Wi-Fi for wireless control and communication with external devices.
- Multiple GPIO pins, including I2C/SPI for interfacing with an LCD screen.
- Compact size (21X17.5mm), suitable for small embedded projects.
- 400 KB SRAM and 4 MB Flash memory, sufficient for storing Game of Life logic and lightweight graphics.
- Low power consumption, ideal for continuously running simulations without excessive energy drain.
- Suitable for handling lightweight visual updates and communication tasks concurrently.
Workflow for programming:
- Set up the development environment:
- Install Arduino IDE, and the Xiao ESP32C3 board package, connect the board to your computer.
- Set up a new project:
- Install the required libraries for LCD display (e.g., U8g2 or TFT_eSPI) and Wi-Fi functionality.
- Write the code:
- Develop the Game of Life logic and implement functions to update the LCD screen and enable remote activation via Wi-Fi.
- Optionally, set up Over-the-Air (OTA) updates for future software modifications.
- Upload the code:
- Flash the Xiao ESP32C3 with the code and ensure all components are configured correctly.
- Test:
- Confirm that the Game of Life simulation displays on the LCD screen and can be controlled or reset remotely via Wi-Fi.
Performance Considerations:
- The Xiao ESP32C3’s 400 KB of SRAM and 4 MB Flash should be adequate for a simple Game of Life implementation. However, careful memory management is essential, particularly for graphical data and communication tasks.
- Wi-Fi connection stability may slightly impact screen updates, so it's advisable to handle communication tasks during inactive periods of the Game of Life.
- To minimize power consumption, low-power modes can be implemented during periods of inactivity.
Use case / Application #6: A wearable sensor to detect proximity and speed of incoming objects, and upon detecting objects within a specified distance threshold (e.g. 5 inches or nearer) and speed threshold (e.g. 5mph or faster), triggers a specified action (such as turning on a motor).
Chip: ATtiny412
Contributed by: He Yutian
Capabilities:
- Tiny (it’s in the name!) – 6.00mm x 4.90mm x 1.75mm, with 8 pins
- Ultra-low power consumption and low-cost
- 4 KB flash memory (in-system and reprogrammable for program storage), 256B SRAM data memory (for data storage and stack), 128B EEPROM data memory (supports single-byte read and write)
- Uses AVR 1 series architecture and is compatible with Microchip Studio (formerly Atmel Studio, producer of the well-documented legacy ATtiny85 chip).
- Uses a Unified Program and Debug Interface (UPDI) for precise debugging
Programming Workflow:
- Set up Microchip Studio (formerly Atmel Studio) to serve as the development environment. Alternatively, can also be programmed using MPLAB X IDE, or Arduino IDE with the megaTinyCore library.
- Also set up a UPDI programmer such as Microchip’s MPLAB Snap for debugging.
- Write a C program to configure pins to address the use case. For this application, we can assume the use of a sensor, a reader, and a motor, i.e. 3 General Purpose Input and Output (GPIO) pins.
- Specifically, we will configure a GPIO pin as an output to trigger a sensor for the proximity of incoming objects (e.g., an ultrasonic sensor like the HC-SR04), another GPIO pin as an input to measure/read the response from the sensor, and a third GPIO as an output to control movement (e.g., a servo motor).
- Simulate the code in Wokwi or Falstad to check if it works, and debug using the UPDI environment, before deploying it to the actual microcontroller + attached peripherals (sensor, reader, motor).
Performance Considerations:
- Low power consumption: ideal for battery-powered devices that need to conserve energy and can be left uncharged for a long time, i.e. most wearables.
- Compact memory: more suited for tasks where memory usage is minimal and basic.
- Low pin-count: sufficient for simple tasks like basic light/motion/temperature sensor reading, and simple control systems like small motors/buttons/LEDs.
- Since it is newer (as of 2024), the AVR 1 series architecture it uses is more compatible with newer AVR devices, making it easier to port code across the AVR family.
Use case / Application #7: Bluetooth keyboard case for Apple Watch resembling a Blackberry
Chip: Nordic nRF52840
Contributed by: Nate Wiegand
Capabilities:
- Size: 6mm x 6mm in QFN package, making it pretty tiny and suitable for small devices
- XIAO version: 21mm x 17.8mm
- ARM Cortex-M4 processor is a low-power processor suitable for real-time processing tasks like sensor data analysis, audio processing, and control systems
- Clocks at 64MHz, suitable for sensor applications
- 1MB Flash memory, 256KB RAM
- Bluetooth 5.4
- USB 2.0
- Multiple GPIOs, ADCs, and communication protocols (SPI, I2C, UART)
- Support for multiple wireless protocols (Zigbee, Thread, ANT+)
- NFC Capable
Programming Workflow:
- Set Up Development Environment: Install Nordic SDK or use Arduino IDE.
- Connect Hardware:
- USB Connection: Use a micro-USB cable to connect the nRF52840 development board to your computer.
- Drivers: Install the necessary drivers if your computer does not recognize the nRF52840.
- Install Drivers: Ensure the necessary drivers for the nRF52840 are installed.
- Write Code: Use Nordic SDK for robust BLE development or Arduino IDE for simpler projects.
- Upload Code: Compile and upload your code to the nRF52840.
- Debug: Use the serial monitor or Nordic tools to debug and test your code.
Performance Considerations:
- Excellent BLE Performance: Supports advanced Bluetooth features; ideal for BLE applications
- Low Power Consumption: Good for battery-powered devices
- Support for Multiple Wireless Protocols: High compatibility for IoT applications
- 64MHz clock speed: Great for sensors / applications requiring constant monitoring
- More Complex to Program: Requires familiarity with Nordic SDK and BLE protocols; more challenging than other options (circuitpython also usable on XIAO model)
- Low flash memory: Only 1MB vs the 4-8MB of many others; need to be mindful of program size
- Higher Cost: Roughly double the cost of ESP32C3
Use case / Application #8: Dimmable motion sensor LED with tracking abilities
Chip: Raspberry Pi RP2040
Contributed by: Reishan McIntosh
Capabilities:
- 32-bit dual-core
- 133 MHz clock (250 MHz+ over-clocked)
- 264k SRAM - running programs and handling variables
- 2 MB of onboard flash memory - for storing programs and data
- 26 general purpose input/output GPIO pins
- 3 Analog Input (ADC) pins
- Digital I/O pins
- Up to 16 PWM channels
- Programmable peripherals
- Can be powered via:
- Micro-USB port (5V input)
- 3.3V or 5V from an external power supply
Programming Workflow:
- Will use MicroPython firmware on Pico to write and upload scripts
- Download Thonny IDE
- Install MicroPython on Pico via USB
- Use MicroPython language – PWM on Pico to control LED brightness; map distance detected by the sensors to a corresponding PWM value
- Can also use C++ for better optimization and control over timing
- Use LED / PIR sensors for detecting movement, and ultrasonic sensors (HC-SR04) for detecting distance of the moving object or person.
- Debugging through Thonny IDE – can print sensor values and adjust the PWM mappings based on real-world testing
Performance Considerations:
- Responsiveness: ensure sensor readings and PWM adjustments happen fast enough for smooth transitions of LED dimming
- Use interrupts instead of polling for motion detection to improve responsiveness. E.g., PIR sensor can trigger an interrupt to wake the PICO from low power state and adjust instantly.
- Power consumption: if power consumption is a concern, you can put Pico into sleep modes when no motion is detected
- Multiple sensors and pin usage: Pico has enough GPIO pins to support multiple motion and proximity sensors, but may need to plan pin assignments carefully
- Since I’m using a couple sensors, I may use I2C or SPI sensors to reduce the number of GPIO pins required for analog inputs (will need to do more research)
Use case / Application #9: Using sensors to detect light levels; turning motors and activating a solar-powered light when light levels are low enough; reversing motors and turning off light once light levels are high enough again
Chip: RP2040
Contributed by: Alex Stewart
Capabilities:
- Manufacturer: Raspberry Pi Foundation
- Core: Dual-core ARM Cortex-M0+
- Clock Speed: Up to 133 MHz
- RAM: 264 KB SRAM
- Flash Storage: No built-in flash; external flash via QSPI
- GPIO Pins: Up to 30 GPIOs
- Peripherals: ADC, I2C, SPI, UART, PWM, etc.
- Power Consumption: Generally lower, optimized for battery-operated devices
- Development Environment: Compatible with C/C++, MicroPython, and CircuitPython
- Main Use Cases: Education, DIY projects, low-power applications
Programming Workflow:
- Choose a programming language (I will be using MicroPython).
- Download the MicroPython firmware and install it on the RP2040.
- Use a USB cable to connect the RP2040 board to my computer.
- Create a new project in an IDE that supports Python.
- Write and compile code and check for errors.
- Upload Python scripts using Thonny or by copying them directly to the RP2040.
- Use the interactive REPL (Read-Eval-Print Loop) for testing and debugging code.
Performance Considerations:
- Simple and straightforward for beginners.
- Cost-effective and widely available.
- Excellent for GPIO-intensive applications due to the number of I/O pins.
- Good support for real-time applications with a focus on simplicity.
- RP2040 tends to be more power-efficient, making it suitable for battery-operated projects.
Use case / Application #10: Warmth faxing - when your long-distance friend/partner puts their hand on a temperature sensing device, your device warms up to match their temperature. (Ideally there is also a display that maps the heat)
Chip: XIAO ESP32C3
Contributed by: Ahzin Nam
Capabilities:
- Needs to use temperature data/sensor as an input (Xiao ESP32C3 integrated WiFi and Bluetooth)
- Needs to be able to generate heat to a desired temperature
- Needs to connect to wifi
- Can be stationary / No size limitation
Workflow for programming:
- Temperature Sensing: Use a sensor like the DS18B20 (accurate, 1-wire) or DHT11/22 (simpler, but less precise).
- Heating Control: Use a Peltier module or another heating element controlled via PWM (pulse-width modulation) using a MOSFET or H-bridge.
- WiFi Communication: The built-in WiFi on the ESP32C3 that allows sending temperature data over the internet to a paired device, enabling real-time warmth sharing.
- Display: A small OLED display to show the received temperature or heating status.
Performance Considerations:
- Low Power Consumption: The XIAO ESP32C3 is efficient, making it good for battery-powered warmth devices.
- Adequate Processing Power: The 160MHz RISC-V core can easily handle temperature sensing, WiFi communication, and heating control.
- Compact Form Factor: Perfect for space-constrained projects where size is critical.
Use case / Application #11: Monitor sleep
Chip: currently reaching out to TA
Contributed by: Alicia Ramirez
Capabilities:
- Needs to work with bluetooth and a heartrate sensor
- Needs to be small in size and comfortable
- Needs to be able to recharge aka no need to replace batteries
Workflow for programming:
Performance Considerations: