Personal Project · Embedded · 2026
Light Data Transfer
Sending data from an ESP32 to a Raspberry Pi 4 using a blinking LED and a photoresistor.
The main goal of this project was to understand how to send data by light. I used an ESP32 to control an LED. A Raspberry Pi 4 connected to a photoresistor that processes the blinks and converts it back into data.
I had a curiosity for how fiber optics worked and wanted to gain a better understanding of it. While this is not the same thing, it is the same idea for sending data by light.
How it works
Transmitter
An ESP32 blinks a red LED on and off. LED on is a 1, LED off is a 0.
Receiver
A Raspberry Pi 4 reads a photoresistor voltage divider on GPIO 17.
Protocol
Bytes are sent one bit at a time on a fixed clock, wrapped in a small packet so the Pi knows where a message starts, how long it is, and whether it arrived intact.

The protocol
Each byte is framed with a start bit, eight data bits sent least significant bit first, followed by a stop bit.
Bytes are grouped into packets. Two header bytes mark the start, a length byte says how much data follows, and a checksum at the end lets the Pi reject anything that got corrupted.
Current Version
- Working end to end: the Pi decodes the ESP32's message and the checksum verifies.
- Bit time tuned down to 100 ms, about 10 bits per second, or roughly one byte per second with framing.
Built with
- ESP32
- Raspberry Pi 4
- Photoresistor
- Red LED
- GPIO