This project simulates the TI OPT4048 4‑channel ambient light sensor using a dummy input generator and a user-space application. The project also includes your original opt4048_reader.c (unchanged) so the structure remains realistic for future hardware integration.
project/ │ ├── opt4048_reader.c # Your original I2C sensor reader ├── input_generator.c # Generates dummy 4‑channel sensor_input.txt ├── sensor_app.c # Reads the 4 values and displays them ├── Makefile └── README.md # (this file)
The real OPT4048 uses I²C to read CH0–CH3:
- CH0 – IR Full Range
- CH1 – Visible Broadband
- CH2 – Blue/Green
- CH3 – Red/NIR
Because the real hardware requires permissions, this project simulates sensor data through a text file (sensor_input.txt).
The workflow:
input_generatorproduces 4 random sensor values.sensor_appreads those 4 values and displays them at 5 Hz.opt4048_readeris included unchanged for future integration.- A
Makefilecompiles everything and runs the app.
Run:
make
This compiles:
- input_generator
- opt4048_reader
- sensor_app
make run
This does:
./input_generator→ createssensor_input.txt./sensor_app→ prints the 4 channel values continuously
Example output:
CH0(IR): 53211 | CH1(Visible): 88344 | CH2(Blue/Green): 12922 | CH3(Red/NIR): 99320
- Creates sensor_input.txt
- Produces 4 pseudo‑random values in the OPT4048 20‑bit range (0–1048575)
- Output format:
CH0,CH1,CH2,CH3
- Reads
sensor_input.txt - Parses 4 integers
- Displays them repeatedly every 200 ms (5 Hz)
- Your original code, unchanged
- Opens
/dev/i2c-4 - Reads 3‑channel sensor data from a real OPT4048 device
- Sends values via Unix domain socket
This file is preserved for actual hardware usage later.
Targets:
make→ build all executablesmake run→ run input generator + sensor appmake clean→ remove binaries + text files
- No root access is required since simulation uses text files.
opt4048_reader.cwill fail without proper I²C permissions but is kept intentionally for hardware use.
If you want, I can add:
- A socket-based simulation between generator and app
- A Yocto recipe to deploy this on Qualcomm boards
- A JSON or binary protocol
- A GUI dashboard for live visualization
This README documents:
- Structure
- Steps
- Build and run instructions
- Detailed file explanations
If you want a PDF version, a Yocto integration, or a GitHub-ready project, tell me!