Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Eye Pressure Monitor with OLED Display and Multiple Sensors

View and Edit Project In Cirkit DesignerImage of ESP32-Based Eye Pressure Monitor with OLED Display and Multiple Sensors

Circuit Documentation

Summary

The circuit in question is designed to monitor eye deformation and pressure using a combination of sensors, including a photodiode, a TCRT 5000 IR sensor, and a VL53L0X sensor. The data collected from these sensors is processed by an ESP32 microcontroller and displayed on a 0.96" OLED screen. The circuit is powered by the ESP32's 3.3V output, and the ground connections are shared among the components. The ESP32 also handles communication with the OLED display and the VL53L0X sensor via I2C protocol, while the photodiode and IR sensor are connected to the ESP32's analog and digital pins, respectively.

Component List

Wiring Details

ESP32 (30 pin)

0.96" OLED

Photodiode

VL53L0X

TCRT 5000 IR SENSOR

Documented Code

ESP32 (30 pin) Code

/*
 * This Arduino Sketch reads data from a photodiode, TCRT 5000 IR sensor, and
 * VL53L0X sensor to determine eye deformation and pressure. The results are
 * displayed on a 0.96" OLED display. Safety features and calibration are
 * included.
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VL53L0X.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

VL53L0X sensor;

const int photodiodePin = 12;
const int irSensorPin = 5;

int photodiodeBaseline = 0;
int irSensorBaseline = 0;
int distanceBaseline = 0;

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize OLED display
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  // Initialize VL53L0X sensor
  Wire.begin();
  sensor.init();
  sensor.setTimeout(500);
  sensor.startContinuous();

  // Initialize photodiode and IR sensor pins
  pinMode(photodiodePin, INPUT);
  pinMode(irSensorPin, INPUT);

  // Calibrate sensors
  calibrateSensors();
}

void loop() {
  // Read photodiode value
  int photodiodeValue = analogRead(photodiodePin);

  // Read IR sensor value
  int irSensorValue = digitalRead(irSensorPin);

  // Read distance from VL53L0X sensor
  int distance = sensor.readRangeContinuousMillimeters();

  // Convert distance to mmHg (example conversion, adjust as needed)
  float pressure = distance * 0.1; // Placeholder conversion factor

  // Determine eye pressure status
  String eyePressureStatus;
  if (pressure < 10) {
    eyePressureStatus = "Low";
  } else if (pressure <= 21) {
    eyePressureStatus = "Normal";
  } else {
    eyePressureStatus = "High";
  }

  // Safety feature: Check for sensor errors
  if (sensor.timeoutOccurred()) {
    eyePressureStatus = "Sensor Error";
  }

  // Display results on OLED
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Photodiode: ");
  display.println(photodiodeValue);
  display.print("IR Sensor: ");
  display.println(irSensorValue);
  display.print("Distance: ");
  display.print(distance);
  display.println(" mm");
  display.print("Pressure: ");
  display.print(pressure);
  display.println(" mmHg");
  display.print("Eye Pressure: ");
  display.println(eyePressureStatus);
  display.display();

  // Delay before next loop
  delay(1000);
}

void calibrateSensors() {
  // Calibrate photodiode
  photodiodeBaseline = analogRead(photodiodePin);
  // Calibrate IR sensor
  irSensorBaseline = digitalRead(irSensorPin);
  // Calibrate VL53L0X sensor
  distanceBaseline = sensor.readRangeContinuousMillimeters();
  delay(1000); // Allow time for calibration
}

Photodiode Code

The photodiode does not have associated code as it is a passive component. Its output is read by the ESP32's analog pin D12.

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

(Note: The above code is a placeholder as the photodiode does not require specific code for operation; it is directly read by the ESP32 microcontroller.)