Getting Started
Everything you need to begin ESP32 development
C Starter Kit
My comprehensive C starter kit includes everything you need for ESP32 development:
Installation
# Clone the starter kit
git clone https://github.com/your-username/esp32-c-starter
cd esp32-c-starter
# Install ESP-IDF
./install.sh
# Set up environment
. ./export.sh
What's Included
- Project Template: Pre-configured CMake build system
- Example Code: GPIO, Wi-Fi, UART, I2C, SPI examples
- Debugging Setup: JTAG configuration for OpenOCD
- VSCode Integration: Tasks and launch configurations
- Documentation: Comprehensive guides and API references
Quick Start
# Build the blink example
cd examples/blink
idf.py build
# Flash to device
idf.py -p /dev/ttyUSB0 flash
# Monitor output
idf.py -p /dev/ttyUSB0 monitor
Rust Setup
Get started with Rust on ESP32 using the esp-rs ecosystem:
Install Rust Toolchain
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install espup
cargo install espup
# Install ESP toolchain
espup install
# Source the environment
. $HOME/export-esp.sh
Create New Project
# Install cargo-generate
cargo install cargo-generate
# Generate from template
cargo generate esp-rs/esp-idf-template cargo
# Build and flash
cd your-project-name
cargo build
cargo run
Key Crates
esp-idf-hal- Hardware abstractionesp-idf-sys- ESP-IDF bindingsembedded-hal- Generic embedded traits
embedded-svc- Service abstractionsesp-idf-svc- ESP servicesanyhow- Error handling
Hardware Requirements
Recommended Boards
ESP32-DevKitC
General purpose development board with all GPIO exposed
Beginner FriendlyESP32-C3-DevKitM-1
RISC-V based, great for Rust development
Rust OptimizedEssential Tools
- USB-to-UART bridge (usually built into dev boards)
- USB cable (micro-USB or USB-C depending on board)
- Breadboard and jumper wires for prototyping
- Optional: JTAG debugger for advanced debugging
Your First Project
Let's create a simple Wi-Fi-enabled LED controller:
Project Goal: Control an LED remotely via HTTP requests
C Implementation
#include "esp_wifi.h"
#include "esp_http_server.h"
#include "driver/gpio.h"
#define LED_PIN GPIO_NUM_2
esp_err_t led_handler(httpd_req_t *req) {
const char* state = strchr(req->uri, '=') + 1;
gpio_set_level(LED_PIN, strcmp(state, "on") == 0);
httpd_resp_send(req, "OK", HTTPD_RESP_USE_STRLEN);
return ESP_OK;
}
void app_main() {
// Initialize Wi-Fi and HTTP server
// Register handler for /led?state=on|off
}
Rust Implementation
use esp_idf_hal::gpio::*;
use esp_idf_svc::http::server::*;
fn main() {
let mut led = PinDriver::output(
peripherals.pins.gpio2
).unwrap();
let server = EspHttpServer::new(&Default::default())?;
server.fn_handler("/led", Method::Get, move |req| {
let state = req.query_string()
.contains("state=on");
led.set_level(state.into())?;
req.into_ok_response()?
.write_all(b"OK")?;
Ok(())
})?;
}
Resources
Rust Resources