
A bi-directional Li-Fi (light fidelity) optical communication system has been developed for high-speed, two-way digital data transfer over free-space optical links. Using laser diodes, photodiodes, and on-off keying (OOK) modulation, each module can operate dynamically as both a transmitter and a receiver, unlike the earlier unidirectional design published in June issue of EFY. This enables reliable bi-directional communication over the same optical link at data rates of up to 520kbps.
The system uses dedicated transmitter and receiver circuits with switching logic, together with handshake, packet-based communication, and checksum-based error detection to ensure reliable transfer of files of any type. It demonstrates the practical implementation of full-duplex optical wireless communication using low-cost discrete components and USB-to-TTL converters, making it suitable for academic study, system development, and rapid prototyping as an alternative to conventional RF communication. Fig. 1 shows the author’s breadboard prototype. Two identical system units were built and tested.

Circuit and working
Fig. 2 shows the circuit diagram of the Li-Fi transceiver module for bi-directional optical communication. It consists of two identical transceiver units, each capable of functioning as both a transmitter and a receiver. Each unit is built around a CH9102 USB-to-TTL converter (U1), an LM393 dual comparator (IC1), a BC547 transistor (T1), a laser diode (LD1), and a BPW34 photodiode (D1). Of the two comparators in the LM393, only IC1B is used, while IC1A remains unused.

On the transmitter side, the TXD (pin 6) output of the CH9102 drives transistor T1, which switches the laser diode on and off according to the serial data, thereby implementing on-off keying (OOK) modulation. The optical pulses are transmitted through free space to the receiving unit.
In the receiver section, the BPW34 photodiode is reverse-biased through R1 (2kΩ) and generates a voltage proportional to the received light intensity. This signal is applied to the non-inverting input (pin 5) of comparator IC1B. The inverting input (pin 6) receives an adjustable reference voltage from potentiometer VR1, allowing the detection threshold to be optimised for ambient light conditions and improved noise rejection. Resistor R2 acts as the pull-up resistor for the LM393’s open-collector output, while capacitor C1 (0.1µF) provides supply decoupling to improve stability at high switching speeds. The comparator converts the weak analogue signal into clean TTL-level pulses, which are fed to the RXD (pin 7) of the CH9102 for USB serial communication.
During operation, the software alternately switches each unit between transmit and receive modes. Since both transceiver units use identical hardware, either unit can transmit or receive data at any time. This arrangement enables reliable bi-directional optical communication with handshake and error-checking support at data rates of up to 520kbps.
| Parts List (For one set) |
| Semiconductors: LD1 – Laser diode T1 – BC547 npn transistor D1 – BPW34 pin photodiode IC1 (IC1A-IC1C) – LM393 comparator Resistors (all 1/4-watt, ±5% carbon): R1 – 2kΩ R2 – 1kΩ VR1 – 2kΩ potmeter Capacitors: C1 – 0.1µF ceramic disc Miscellaneous: U1 – CH9102 USB to TTL converter module – PCB (designed or custom-made) or Breadboard – Connecting/jumper wires – Enclosure (optional) |
The software
The control software is written in Python and upgrades the earlier design by introducing reliable bi-directional communication at a baud rate of up to 520kbps. It continues to use OOK modulation, where the laser diode transmits binary data as light pulses. A handshake and acknowledgement (ACK) mechanism enables synchronisation, error detection, and automatic packet retransmission.
At the transmitter, the Python script (see Fig. 3) opens the selected file in binary mode, determines its size, and establishes communication through a short handshake. It then sends a <START> marker followed by metadata containing the file size and a fixed packet size of 128 bytes. The file is divided into 128-byte packets, each consisting of a header (0xAA, 0x55), a packet number, a data length, a payload, and an 8-bit checksum (sum of the data bytes modulo 256). The packets are transmitted through the TX pin, which drives a BC547 transistor to switch the laser diode at high speed for optical data transmission. Fig. 3 shows a snippet of the transmitter Python code.

After each packet, the transmitter waits for receiver feedback. A valid acknowledgement (V) triggers transmission of the next packet, while a negative acknowledgement (N) or a timeout causes the packet to be retransmitted. This ensures reliable data transfer despite noise, optical misalignment, or temporary link interruptions. After all packets have been received successfully, the transmitter sends an <END> marker to complete the file transfer.
On the receiver side (Fig. 4), a reverse-biased BPW34 photodiode detects the incoming optical signal and converts it into a voltage proportional to the light intensity. An LM393 comparator converts this analogue signal into a clean digital UART signal. The Python receiver continuously monitors the serial port, waits for the <START> marker, reads the file metadata, and opens the output file in binary write mode. Fig. 4 shows a snippet of the receiver Python code.

Each received packet is verified by checking the header (0xAA, 0x55), packet number, payload length, and checksum. The checksum is recalculated and compared with the received value to ensure data integrity. If the packet is valid and in sequence, its payload is written to the file and a valid acknowledgement (V) is sent to the transmitter. If the checksum fails, a negative acknowledgement (N) is returned, requesting retransmission. Duplicate packets are ignored but still acknowledged to maintain synchronisation.
EFY note. Before running the Python script, verify the correct COM port in device manager under ports (COM and LPT), and ensure that the source and destination file paths are correctly configured.
Construction and testing
The actual-size PCB of the Li-Fi transceiver module (see Fig. 2) is shown in Fig. 5, and its component layout is shown in Fig. 6. After assembling the circuit on the PCB, mount it inside a suitable enclosure with an opening for the laser beam so that the light falls directly on the photodiode. Connect the PCB to a laptop or desktop computer through the USB interface.


Alternatively, the bi-directional Li-Fi system may also be assembled using standard breadboards, as shown in the author’s prototype (Fig. 1).
To test the system, assemble two identical Li-Fi transceiver PCBs. Place the two modules at separate locations with a clear line of sight so that the laser beam from each module reaches the photodiode of the other. This arrangement simulates a practical bi-directional communication link. Ensure that the laser transmitter of each module is aligned with the receiver of the opposite module.
First, connect the VCC, GND, TX, and RX pins of the CH9102 USB-to-UART module to the corresponding pins on the assembled PCB. Then, connect the CH9102 USB-to-UART module to the laptop via USB to power the PCB and establish serial communication. After optimising the hardware and software, the communication speed was set to 520kbps, which proved to be the highest stable data rate.
At this speed, the bit period is approximately 1.9µs, very close to the practical operating limit of the LM393 comparator (typical response time of about 1.3µs under suitable conditions). During laboratory testing, baud rates of up to 750kbps were achieved without errors under ideal conditions. However, this performance may not remain reliable under different ambient conditions or with slight optical misalignment. Therefore, 520kbps is recommended for dependable operation.
Reliable high-speed communication requires proper adjustment of the VR1 threshold on both modules, accurate optical alignment, adequate filtering, and minimal electrical noise and crosstalk. Data integrity is ensured through packet framing, checksum-based error detection, and automatic packet retransmission. Any lost or corrupted packets are resent until the complete file is received correctly, enabling reliable bi-directional wireless file transfer over the optical Li-Fi link.
Finally, the system demonstrates how digital data can be transmitted using light through on-off keying and received by a photodiode. It also demonstrates high-speed UART communication, data packetisation with checksum-based error checking and automatic retransmission, as well as the importance of comparators, filtering, and component selection for reliable signal reception. It also shows how discrete electronic circuits and software protocols work together to create a complete bi-directional Li-Fi communication system.
Abhay Verma is an electronics engineer at EFY and a passionate electronics hobbyist with a keen interest in practical circuit design and DIY projects.




