Skip to content

Mahin-W/OH-Insole

Repository files navigation

Project: OH Insole - sensor read example

What I added

  • src/main.cpp: Reads an analog FSR on GPIO34 and reads PPG values from a MAX30105-style sensor over I2C (SDA=21, SCL=22). Prints values over Serial.
  • platformio.ini: added lib_deps for Adafruit MAX30105 and Adafruit BusIO.

Wiring

  • FSR (analog) -> GPIO34 (ADC1_CH6) on ESP32
  • PPG sensor (MAX30102/MAX30105 compatible) -> I2C:
    • SDA -> GPIO21
    • SCL -> GPIO22
    • VCC -> 3.3V
    • GND -> GND

Assumptions

  • The PPG sensor is MAX30102 / MAX30105 compatible and works with Adafruit_MAX30105 library. If you have a different PPG, change the library and code accordingly.

How to build/run (locally)

  1. Open the project in PlatformIO (VS Code + PlatformIO extension) and run Build or Upload.
  2. Or from a terminal with PlatformIO CLI installed:
cd /Users/mahin/Documents/PlatformIO/Projects/OH\ Insole
# Build the project
pio run

# Upload to the esp32dev environment (ensure board is connected)
pio run -t upload -e esp32dev

# Open serial monitor at 115200
pio device monitor -b 115200

# Or use the provided helper script:
./scripts/pio_commands.sh build
./scripts/pio_commands.sh upload
./scripts/pio_commands.sh monitor

Notes

  • I attempted to run pio run in this environment, but the PlatformIO CLI is not installed here ("pio: command not found"). Please run the build on your machine where PlatformIO is available.
  • The code prints raw FSR ADC and an IR value from the PPG sensor. You can refine filtering and algorithms (e.g., beat detection) later.

Troubleshooting & diagnostics

  • FSR (analog) garbage readings:

    • Ensure the FSR is wired as part of a proper voltage divider. FSRs are variable resistors — you must pair it with a fixed resistor to produce a measurable voltage.
    • Common wiring: VCC -> fixed resistor -> FSR -> GND, measure voltage across FSR/fixed resistor midpoint to ADC pin.
    • Check that the ADC pin (GPIO34) is not driven and is input-only. Avoid connecting it directly to 5V; use 3.3V safe voltages.
    • Use analogReadResolution(12) and analogSetPinAttenuation(pin, ADC_11db) in code (already added) to cover 0-3.3V range.
  • PPG (MAX3010x) garbage readings:

    • Power: ensure the module VCC is 3.3V (many breakouts accept 3.3V or 5V but check your board). Wrong supply can saturate readings.
    • I2C wiring: SDA->GPIO21, SCL->GPIO22. Ensure good GND connection between ESP32 and sensor.
    • Pull-ups: many modules include I2C pull-ups. If yours doesn't, add 4.7k pull-ups to 3.3V on SDA and SCL.
    • Sensor placement: for finger or insole readings, ambient light and placement matter. Cover the sensor to reduce ambient light when testing.
    • Use the library examples in lib/SparkFun_MAX3010x_Sensor_Library/examples to compare behavior.

If the readings still look wrong, run the helper script and paste the serial log here and I'll analyze the values:

./scripts/pio_commands.sh build
./scripts/pio_commands.sh upload
./scripts/pio_commands.sh monitor

If you want, I can:

  • Add a simple moving-average filter for FSR and PPG.
  • Add example code to compute heart rate/SpO2 using existing libraries.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors