Chat
Welcome to Flux
Treat Flux like your intern. Tell it what you'd like to build and it'll get to work. You can also ask it questions, brainstorm ideas, and teach it your preferences. Learn More
Table
| Function | ESP32 GPIO | Net | Connected To | Notes |
|---|---|---|---|---|
| USB D- | 19 | USB_DN | USB-C Dn1/Dn2 | Native USB programming/data |
| USB D+ | 20 | USB_DP | USB-C Dp1/Dp2 | Native USB programming/data |
| BOOT | 0 | ESP_BOOT | BOOT button + 10k pull-up | Hold BOOT, tap RESET to enter download mode |
| EN/RESET | EN | ESP_EN | RESET button + 10k pull-up + 1uF | Active low reset |
| IMU SPI SCK | 12 | SPI_SCK | ICM-42688-P AP_SCLK + header pin 3 | SPI clock |
| IMU SPI MOSI | 11 | SPI_MOSI | ICM-42688-P AP_SDI + header pin 4 | SPI data to sensor |
| IMU SPI MISO | 13 | SPI_MISO | ICM-42688-P AP_SDO + header pin 5 | SPI data from sensor |
| IMU CS | 10 | IMU_CS | ICM-42688-P AP_CS + 10k pull-up | Active low |
| IMU INT1 | 9 | IMU_INT1 | ICM-42688-P INT1 | Motion/data-ready interrupt |
| External CS/GPIO | 14 | EXT_CS_GPIO | Header pin 6 | Spare chip-select/GPIO for external SPI sensor |
Ini
[env:esp32-s3-devkitc-1] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 upload_protocol = esptool build_flags = -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 lib_deps =
Cpp
#include <Arduino.h> #include <WiFi.h> #include <SPI.h> #define PIN_IMU_SCK 12 #define PIN_IMU_MOSI 11 #define PIN_IMU_MISO 13 #define PIN_IMU_CS 10 #define PIN_IMU_INT1 9 #define PIN_EXT_CS_GPIO 14 #define ICM_REG_WHO_AM_I 0x75 #define ICM_REG_DEVICE_CONFIG 0x11 #define ICM_REG_PWR_MGMT0 0x4E #define ICM_SPI_READ 0x80 const char* WIFI_SSID = "YOUR_SSID"; const char* WIFI_PASSWORD = "YOUR_PASSWORD"; SPIClass imuSPI(FSPI); unsigned long lastReadMs = 0; uint8_t icmReadReg(uint8_t reg) { digitalWrite(PIN_IMU_CS, LOW); imuSPI.transfer(reg | ICM_SPI_READ); uint8_t value = imuSPI.transfer(0x00); digitalWrite(PIN_IMU_CS, HIGH); return value; } void icmWriteReg(uint8_t reg, uint8_t value) { digitalWrite(PIN_IMU_CS, LOW); imuSPI.transfer(reg & 0x7F); imuSPI.transfer(value); digitalWrite(PIN_IMU_CS, HIGH); } bool initICM42688() { pinMode(PIN_IMU_CS, OUTPUT); digitalWrite(PIN_IMU_CS, HIGH); pinMode(PIN_IMU_INT1, INPUT); pinMode(PIN_EXT_CS_GPIO, OUTPUT); digitalWrite(PIN_EXT_CS_GPIO, HIGH); imuSPI.begin(PIN_IMU_SCK, PIN_IMU_MISO, PIN_IMU_MOSI, PIN_IMU_CS); delay(10); uint8_t who = icmReadReg(ICM_REG_WHO_AM_I); Serial.printf("ICM WHO_AM_I = 0x%02X\n", who); icmWriteReg(ICM_REG_DEVICE_CONFIG, 0x01); // soft reset delay(2); icmWriteReg(ICM_REG_PWR_MGMT0, 0x0F); // accel+gyro low-noise mode delay(50); return true; } void initWiFi() { WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting WiFi"); for (int i = 0; i < 20 && WiFi.status() != WL_CONNECTED; ++i) { delay(500); Serial.print("."); } if (WiFi.status() == WL_CONNECTED) { Serial.printf("\nWiFi OK: %s\n", WiFi.localIP().toString().c_str()); } else { Serial.println("\nWiFi not connected; continuing offline."); } } void setup() { Serial.begin(115200); delay(1000); Serial.println("IRMA vibration IoT firmware starting"); initICM42688(); initWiFi(); } void loop() { if (millis() - lastReadMs >= 1000) { lastReadMs = millis(); uint8_t who = icmReadReg(ICM_REG_WHO_AM_I); Serial.printf("ICM42688 alive, WHO_AM_I=0x%02X, INT1=%d\n", who, digitalRead(PIN_IMU_INT1)); } if (WiFi.status() != WL_CONNECTED) { // Optional: reconnect or buffer vibration data locally. } }
pio runpio run -t uploadpio device monitorPlatform & Toolchain
Pin Mapping
platformio.ini
Complete Firmware Source
Build & Flash