{"id":31466956,"url":"https://github.com/bobbymannino/esp32-rust-demo","last_synced_at":"2026-05-17T17:10:35.050Z","repository":{"id":311817351,"uuid":"1041642441","full_name":"bobbymannino/esp32-rust-demo","owner":"bobbymannino","description":"A very simple demo of programming an ESP32 in Rust","archived":false,"fork":false,"pushed_at":"2025-09-14T14:55:34.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-01T18:51:28.349Z","etag":null,"topics":["esp32","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bobbymannino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-20T19:44:46.000Z","updated_at":"2025-09-13T17:28:49.000Z","dependencies_parsed_at":"2025-08-27T03:33:06.867Z","dependency_job_id":"83c6580f-1212-42c0-8896-4178235e6e50","html_url":"https://github.com/bobbymannino/esp32-rust-demo","commit_stats":null,"previous_names":["bobbymannino/esp32-rust-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bobbymannino/esp32-rust-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbymannino%2Fesp32-rust-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbymannino%2Fesp32-rust-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbymannino%2Fesp32-rust-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbymannino%2Fesp32-rust-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bobbymannino","download_url":"https://codeload.github.com/bobbymannino/esp32-rust-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobbymannino%2Fesp32-rust-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33147342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32","rust"],"created_at":"2025-10-01T18:49:19.052Z","updated_at":"2026-05-17T17:10:35.032Z","avatar_url":"https://github.com/bobbymannino.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP32 Rust Demo\n\nA very simple demo of programming an ESP32 in Rust\n\n## Components\n\nThis demo includes drivers for:\n- Button input (GPIO19)\n- RGB LED output (GPIO16, GPIO5, GPIO17)\n- Reed switch input\n- **ADXL345 Accelerometer** - 3-axis accelerometer via I2C\n- **GY521 (MPU6050) IMU** - 6-axis IMU (3-axis accelerometer + 3-axis gyroscope) with temperature sensor via I2C\n\n## Accelerometer (ADXL345) Usage\n\nThe accelerometer module provides a clean, object-oriented API for interfacing with the ADXL345 3-axis accelerometer over I2C.\n\n### Hardware Connections\n- **VCC**: 3.3V\n- **GND**: Ground  \n- **SDA**: GPIO21 (I2C data line)\n- **SCL**: GPIO22 (I2C clock line)\n\n### Code Examples\n\n```rust\nuse crate::accelerometer::{Accelerometer, AccelerationReading};\n\n// Initialize accelerometer\nlet peripherals = Peripherals::take().unwrap();\nlet mut accel = Accelerometer::new(\n    peripherals.i2c0,\n    peripherals.pins.gpio21, // SDA\n    peripherals.pins.gpio22, // SCL\n).unwrap();\n\n// Read acceleration data\nlet reading = accel.read().unwrap();\nprintln!(\"X: {:.3}g, Y: {:.3}g, Z: {:.3}g\", reading.x, reading.y, reading.z);\nprintln!(\"Magnitude: {:.3}g\", reading.magnitude());\n\n// Power management\naccel.sleep().unwrap();  // Put device to sleep to save power\naccel.wake().unwrap();   // Wake up for measurements\n\n// Check connection\nif accel.is_connected() {\n    println!(\"Accelerometer is connected and responding!\");\n}\n```\n\n### Power Management\n\nThe accelerometer supports sleep/wake functionality to conserve power:\n\n- **`sleep()`**: Puts the device in low-power sleep mode. The device stops taking measurements but maintains its configuration.\n- **`wake()`**: Wakes the device and puts it in measurement mode. Required before taking readings.\n\nPower management is especially useful in battery-powered applications where the accelerometer isn't needed continuously.\n\n### Continuous Reading\n\nFor applications that need continuous acceleration monitoring:\n\n```rust\nuse crate::accelerometer::run_continuous_reading;\n\n// This runs an infinite loop printing acceleration readings every 50ms\nrun_continuous_reading().unwrap();\n```\n\n## GY521 (MPU6050) IMU Usage\n\nThe GY521 module provides a clean, object-oriented API for interfacing with the MPU6050 6-axis IMU (3-axis accelerometer + 3-axis gyroscope) with built-in temperature sensor over I2C.\n\n### Hardware Connections\n- **VCC**: 3.3V or 5V (GY521 module has voltage regulation)\n- **GND**: Ground\n- **SDA**: GPIO21 (I2C data line)\n- **SCL**: GPIO22 (I2C clock line)\n- **AD0**: Usually connected to GND on GY521 modules (sets I2C address to 0x68)\n\n### Code Examples\n\n```rust\nuse crate::gy521::GY521;\n\n// Initialize GY521 with default ranges\nlet peripherals = Peripherals::take().unwrap();\nlet mut gy521 = GY521::new(\n    peripherals.i2c0,\n    peripherals.pins.gpio21, // SDA\n    peripherals.pins.gpio22, // SCL\n).unwrap();\n\n// Read rotation data (gyroscope)\nlet rotation = gy521.read_rotation().unwrap();\nprintln!(\"Rotation - X: {:.2}°/s, Y: {:.2}°/s, Z: {:.2}°/s\", \n         rotation.x, rotation.y, rotation.z);\nprintln!(\"Rotation Magnitude: {:.2}°/s\", rotation.magnitude());\n\n// Read movement data (accelerometer)  \nlet movement = gy521.read_movement().unwrap();\nprintln!(\"Movement - X: {:.2}g, Y: {:.2}g, Z: {:.2}g\", \n         movement.x, movement.y, movement.z);\nprintln!(\"Movement Magnitude: {:.2}g\", movement.magnitude());\n\n// Read temperature\nlet temp = gy521.read_temperature().unwrap();\nprintln!(\"Temperature: {:.1}°C\", temp);\n\n// Power management\ngy521.sleep().unwrap();  // Put device to sleep to save power\ngy521.wake().unwrap();   // Wake up for measurements\n\n// Check connection\nif gy521.is_connected() {\n    println!(\"GY521 is connected and responding!\");\n}\n```\n\n### Advanced Configuration\n\n```rust\nuse crate::gy521::{GY521, AccelRange, GyroRange};\n\n// Initialize with custom ranges for high-performance applications\nlet mut gy521 = GY521::new_with_ranges(\n    peripherals.i2c0,\n    peripherals.pins.gpio21,\n    peripherals.pins.gpio22,\n    AccelRange::Range8G,    // ±8g accelerometer range\n    GyroRange::Range1000,   // ±1000°/s gyroscope range\n).unwrap();\n```\n\n### Continuous Reading\n\nFor applications that need continuous IMU monitoring:\n\n```rust\nuse crate::gy521::run_continuous_reading;\n\n// This runs an infinite loop printing rotation, movement, and temperature every 100ms\nrun_continuous_reading().unwrap();\n```\n\n## Commands\n\nSee connected serial devices, you should see something like\n`/dev/cu.usbserial-110`\n\n```shell\nls /dev/tyy.*\n```\n\nRun the project with dev profile on the board\n\n```shell\ncargo run\n```\n\nRun the project in release on the board\n\n```shell\ncargo run --release\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbymannino%2Fesp32-rust-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobbymannino%2Fesp32-rust-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbymannino%2Fesp32-rust-demo/lists"}