Overview
This guide will walk you through setting up PhysisLab on your computer. The installation process varies depending on which experiments you plan to run:- Camera-based experiments: Python + OpenCV setup
- Microcontroller experiments: Arduino IDE + ESP32 setup
- Audio-based experiments: Python + audio libraries
Step 1: Python Environment Setup
Install Python
Create a Virtual Environment (Recommended)
Navigate to your PhysisLab project directory and create an isolated Python environment:When activated, your terminal prompt will show
(physislab-env).Install Required Python Packages
Install all required libraries using pip:Verify OpenCV installation:
Step 2: Arduino IDE Setup for ESP32
Skip this section if you’re only doing camera-based experiments.
Install Arduino IDE
Download and install Arduino IDE 2.0 or later from arduino.ccAlternative: Advanced users can use PlatformIO with VS Code.
Add ESP32 Board Support
Open Arduino IDE and add ESP32 boards:
- Go to File → Preferences (or Arduino IDE → Settings on macOS)
- In “Additional Board Manager URLs”, add:
- Click OK
- Go to Tools → Board → Boards Manager
- Search for “esp32”
- Install “esp32” by Espressif Systems (latest version)
Select ESP32 Board
After installation:
- Go to Tools → Board → esp32
- Select your board model:
- ESP32 Dev Module (most common)
- ESP32-WROOM-DA Module
- Or your specific board variant
- Connect ESP32 via USB
- Select the correct port under Tools → Port
- Windows:
COM3,COM4, etc. - macOS:
/dev/cu.usbserial-*or/dev/cu.SLAB_USBtoUART - Linux:
/dev/ttyUSB0or/dev/ttyACM0
- Windows:
Install Required Arduino Libraries
For experiments using sensors, install libraries via Library Manager:
- Go to Tools → Manage Libraries (or Sketch → Include Library → Manage Libraries)
- Search and install:
- Adafruit VL53L0X (for kinematics with time-of-flight sensor)
Step 3: Download PhysisLab Source Code
Clone or Download Repository
Option A: Using Git (Recommended)Option B: Download ZIP
- Download the repository as ZIP from GitHub
- Extract to your desired location
- Navigate to the extracted folder
Step 4: Verify Installation
Test Camera-Based Experiment
Run the free fall camera detection script:Expected behavior:
- Camera window opens showing live feed
- Press SPACE to capture a snapshot
- Select ROI (region of interest) for the colored object
- Click two horizontal lines for start/end detection
- System begins tracking
- Color detection works (green circle on object)
- Line crossing is detected
- Data is saved to
datos_tiempo.txt
Test ESP32 Firmware (If Applicable)
Upload and test a microcontroller experiment:
- Open
FreeFall/Micro-procesador/FreeFallEpsfreeRTOSFunciona/FreeFallEpsfreeRTOSFunciona.ino - Upload to ESP32
- Open Tools → Serial Monitor (set to 115200 baud)
- Connect IR sensors to pins 18 and 5
- Trigger sensors (break beam)
Test Audio Detection (If Applicable)
Run the sound-based detection:Expected behavior:
- Lists available audio devices
- System arms after 2.5 seconds
- RMS level bar shows microphone input
- Detects two impact events
- Displays Δt (time difference)
Run Analysis Script
Test data analysis with a complete experiment:Required:
- Video file of pendulum motion
- Follow prompts to select frames and ROIs
- Position, velocity, and angle plots
- Period and gravitational acceleration measurement
- Saved figures:
fig1_posicion_velocidad.png,fig2_angulo.png,fig3_trayectoria.png
Common Installation Issues
OpenCV Camera Not Detected
OpenCV Camera Not Detected
Problem:
cap.isOpened() returns FalseSolutions:- Try different camera indices:
- Check camera permissions (macOS/Linux)
- Close other applications using the camera
- On Linux, install v4l-utils:
ESP32 Port Not Appearing
ESP32 Port Not Appearing
Problem: No serial port shows up in Arduino IDESolutions:
- Install USB drivers:
- CP210x: Silicon Labs drivers
- CH340: Search “CH340 driver” for your OS
- Try a different USB cable (must support data transfer)
- Check Device Manager (Windows) or
ls /dev/tty*(macOS/Linux) - Try a different USB port (USB 2.0 ports may work better)
Adafruit_VL53L0X Library Error
Adafruit_VL53L0X Library Error
Problem:
Adafruit_VL53L0X.h: No such file or directorySolution:- Verify library installation: Tools → Manage Libraries
- Search “VL53L0X” and install Adafruit VL53L0X
- Also install dependency: Adafruit Unified Sensor
- Restart Arduino IDE
- Check installation path:
- Windows:
Documents\Arduino\libraries\Adafruit_VL53L0X - macOS:
~/Documents/Arduino/libraries/Adafruit_VL53L0X
- Windows:
Python Audio Device Error
Python Audio Device Error
Problem:
sounddevice cannot find audio inputSolutions:- List available devices:
- Set device index explicitly:
- On Linux, install PortAudio:
Import Errors Despite pip install
Import Errors Despite pip install
Problem:
ModuleNotFoundError: No module named 'cv2' even after installationSolutions:- Ensure you’re using the correct Python:
- Install with full path:
- Check if using virtual environment:
Optional: Advanced Setup
Install Jupyter Notebook for Interactive Analysis
GPU-Accelerated OpenCV (Optional)
For faster processing on systems with NVIDIA GPUs:Next Steps
Run Your First Experiment
Start with the free fall camera experiment
Camera Tracking Guide
Learn how to calibrate cameras and track objects
Data Analysis
Understanding the analysis scripts and results
Experiments Overview
Explore all available experiments
Installation Complete! You’re now ready to perform physics experiments with PhysisLab. Each experiment folder contains specific instructions and README files with additional details.