Implementation of dimming controlled visible light communication using Raspberry Pi

Visible light communication (VLC) is a technology of wireless optical communication, which combines lighting and communication simultaneously. In indoor VLC system, both data communication and lighting quality plays an important role and must be considered. Thus, to achieve the desired levels of illumination, dimming control in VLC is an efficient technology. In this paper, the authors have designed and implemented a dimming control VLC system employing multi header-hybrid pulse position modulation (MH-HPPM) to achieve dimming functionality. MH-HPPM supports various dimming levels and also doesn’t have flicker problems. In this paper, the authors present the implementation of MH-HPPM based VLC system using Raspberry Pi. The prototype is designed using low-cost commodity hardware. Comprehensive experiments are carried out to evaluate the performance of MH-HPPM based VLC under dimming levels 0.25, 0.5 and 0.75. The results demonstrate that designed prototype supports a communication distance up to 3 m for dimming level 0.25 and 3.5 m for dimming level 0.5 and 0.75. It is also observed that MH-HPPM based VLC system also achieves and maintains better throughput for different incidence angle.


Introduction
Visible light communication (VLC) is the subset of optical wireless communication technology which uses visible light as the source to transmit high speed data. This data is transmitted by modulating the intensity of visible light source and is received by the photodiode in the receiver side. The data received is then readily transformed into the forms readable by the end users. VLC technology becomes a viable option with its vast visible light spectrum, which carries 300 THz of license free bandwidth compared to the dwindling RF

System overview
The system architecture overview of the VLC system using Raspberry pi is shown in Fig. 1. A typical VLC system comprises of transmitter and receiver. The transmitter of the VLC system works as: 1. Upon receiving the text data, the user is prompted to set the dimming target value from the available set of dimming values. 2. In the MH-HPPM encoder, the ASCII value of each letter, spaces, alphanumeric values or special characters are converted into binary vector which forms the message.
2.1 Depending on the target dimming value the binary message vector is divided into blocks, where the block size varies according to dimming value and then each block is encoded into MH-HPPM frame. 2.2 The MH-HPPM frame generated using software (from PC) consists of array of 1's and 0's and are sent to Raspberry pi.
3. The array of bits is sent through the GPIO pins of Raspberry pi to the LED driver circuit which drives (modulates) the LED. If bit is '1' LED turns ON, if bit is '0' the LED is turned off at a very fast switching rate.
At the receiver, the photodiode detects the light signal. The MH-HPPM decoder in the receiver section decodes each frame of MH-HPPM into array of binary vector which is then converted into corresponding text data.

MH-HPPM system design
MH-HPPM is capable of providing dimming functionality and the range of dimming values depends on the block size (Das and Mandal 2021). Before the MH-HPPM frame generation and dimming functionality is discussed, the key definitions that are used throughout the work is given as follows: • Block size-denoted as K . Any random data sequence is split into block of K bits depending on the dimming value. • Time slot-denoted as t slot . For any specific hardware, t slot is fixed. Hence, system can turn LED on or off at a maximum rate of 1∕t slot . • Symbol-a group of N time slots consisting of either on or off states which together represents one or several data bits. • Symbol duration-denoted as T , where T = N.t slot . The value of N depends on the dimming target value and block size. • Dimming value-denoted as . It indicates the intensity/brightness level of the LED.
Mathematically, it can be represented as: The range of varies from [0,1]. For example, = 0.5 means brightness level is 50%. As proposed in Das and Mandal (2021), MH-HPPM frame can be generated as follows: 1. Depending on the dimming target value , any random data sequence is split into a block of K bits of information data given as The dimming target value , and the equivalent block length, K , of information data are listed in Table 1. 2. MH-HPPM frame consists of two parts-the header part, d h and the message part, m .
Depending on the dimming target value , the message part, m , is generated from [b 2 , b 1 ] and its decimal equivalent is mapped either into PPM or inverse PPM. Thus, the length of the message part of the MH-HPPM frame is always m l = 4. 3. Similarly, depending on the dimming target value , the header part, d h , is generated from [ b K , b K−1 , … ., b 3 ] and its decimal equivalent is mapped either as PPM or inverse PPM. Thus, the length of the dimming header of the MH-HPPM frame is d l = 2 K−2 .
Hence, the total time slots of MH-HPPM frame are N = d l + m l = 2 K−2 + 4 . Therefore, the dimming value can now be represented as: In Fig. 2, the MH-HPPM frame for achieving dimming level of = 0.25, 0.5 and 0.75 is illustrated for a data of block size K = 4 and data as '1000'.

Data transmission and frame format
To enable communication between the transmitter and receiver a frame format must be properly designed. As shown in Das and Mandal (2021), slots can be extracted/recovered from the received MH-HPPM frame and since multiple headers are used so preamble or synchronization bits isn't needed between consecutive MH-HPPM frames for distinguishing. Hence, the frame format design is optimized as shown in Fig. 3 for transmitting data and establishing communication.
Start bits of appropriate size is sent depending on the dimming value to initiate the process of data transmission using MH-HPPM frame. The start bits also contain information about the dimming value. Following the start bit is the MH-HPPM data sequence frames. After all the MH-HPPM data sequence, the frame format is terminated by an appropriate size of stop bits to indicate the end of data transmission. After receiving the complete frame, the receiver first extracts the information of dimming value from the start bits which is used to decode the received MH-HPPM frame using appropriate decoding algorithm for the corresponding dimming value.

Implementation
This section presents the implementation of the dimming-controlled MH-HPPM VLC using raspberry pi which includes both software and hardware. Many a times, it is not convenient to work directly on the Raspberry Pi. Hence, Virtual Network Computing (VNC), a graphical desktop sharing system that allows to remotely control the desktop interface of one computer (running VNC Server) from another computer or mobile device (running VNC Viewer) is used. In this implementation, one PC has been used as a central console to transmit and receive data using VLC and VNC viewer for transmitter is used to control dimming and transmit data at the transmitter and VNC viewer for receiver is used

Transmitter
The schematic diagram of the transmitter circuit which contains a Raspberry Pi, a LED driver circuit (using, NPN transistor), a power supply of 12 v, 2.2 k resistor, COB LED (12 V, 2.4 W) and wires for connection is shown in Fig. 4b. In Fig. 4a block diagram of the  4c) and (4d) shows the top and front view of the designed transmitter module. The user PC (central console) takes the input data from the user. The prototype is designed to transmit only alphanumeric data using dimming controlled MH-HPPM. The MH-HPPM encoding is performed using python programming. The user in the transmitter side can opt for any dimming value (0.25, 0.5 or 0.75) and the python code will generate corresponding MH-HPPM dimming frame as shown in algorithm 1. Figure 5 demonstrates the MH-HPPM frame generated for an input character "A" when dimming value = 0.25 using python code.
The MH-HPPM encoded frame generated as shown in Fig. 6 is sent to LED driver circuit through the RPi GPIO pin and is used drive the LED.

Receiver
The receiver module required more considered selection of components than the transmission module. This is primarily due to the photodiode configuration, the signal amplification and the RPi GPIO requiring protection against over-voltage. The selection of the photodiode drove all of these requirements. Another influence on the choice of the receiver circuit ) for input data "hello" running in transmitter VNC viewer components was to make sure that each stage would not present a limiting factor to the ability of the prototype to receive high speed signals. The Raspberry Pi for the receiver module is of the same configuration as the transmission module, right down to the cases used to protect the RPi board against damage and contamination. GPIO pin 7 is used to receive the signal from the photodiode circuit. Due to the low power requirements of the amplifier circuit, the on-board + 5 V GPIO pin 2 is used to power the receiver circuit. The Transimpedance amplifier (TIA) OPA380 is selected partly due to its low drain to reduce the need for an additional power source. The RPi GND pin 6 is used for the circuit to ensure common ground connections.
In this prototype, a Hamamatsu S1223 PIN photodiode with a cut-off frequency of 30 MHz and having a high sensitivity in visible to near infrared range is chosen. Also, in order to stop the maximum output (+ 4.4 V) from the photodiode and the amplifier reaching the RPi's GPIO's and doing damage, a Zener protection circuit is used to restrict the output of the amplifier to + 3.3 V. The block diagram, schematic and the prototype of the receiver module is shown in Fig. 7.
The photodiode detects the LED's fast ON/OFF switching and sends the corresponding digital bit to the RPi via GPIO pin 7. The received pattern is decoded and converted to text/ alphanumeric values. The decoding is carried out using algorithm 2 as shown in In this algorithm it is considered that a MH-HPPM frame (of size 24 bits) for a block of K = 4 is received.
Algorithm 2 Figure 9 shows the experimental set up of the VLC system prototype. As it is seen from the figure, the central console (PC) is in the middle of the set up running the transmitter VNC viewer and the receiver VNC viewer. As shown in Fig. 6, the transmitter VNC viewer executes the transmitter code, allowing the user to select any dimming value between 0.25, 0.5, and 0.75. Following the selection of the dimming value, the code prompts the user for the data to be transmitted. The data is converted into an MH-HPPM frame and sent to the transmitter LED via RPi. The MH-HPPM frame dims the intensity of the LED to the desired dimming level based on the dimming value selected by the user. During the experiment, it was discovered that the intensity of light with dimming value 0.25 has the lowest intensity and dimming value 0.75 has the highest intensity (as expected). Because the intensity level could not be distinguished from the captured images for different dimming values, the authors measured the light intensity using an Android app called "Lux Light Meter Free," which is available in the Google Play store. The app detects the intensity of light using the smartphone's ambient light sensor. Figure 10 depicts the measurement of light intensity with a smartphone and the "Lux Light Meter Free" app.

Experiment and observations
As shown in Fig. 6, the transmitter VNC viewer executes the transmitter code, allowing the user to select any dimming value between 0.25, 0.5, and 0.75. Following the selection of the dimming value, the code prompts the user for the data to be transmitted. The data is converted into an MH-HPPM frame and sent to the transmitter LED via RPi. The MH-HPPM frame dims the intensity of the LED to the desired dimming level based on the dimming value selected by the user. During the experiment, it was discovered that the intensity of light with dimming value 0.25 has the lowest intensity and dimming value 0.75 has the highest intensity (as expected). Because the intensity level could not be distinguished from the captured images for different dimming values, the authors measured the light intensity using an Android app called "Lux Light Meter Free," which is available in the Google Play store. The app detects the intensity of light using the smartphone's ambient light sensor.

Fig. 8
Showing receiver code, MH-HPPM received frame ( = 0.25 ) and decoded text "hello" running in receiver VNC viewer Figure 10 depicts the measurement of light intensity with a smartphone and the "Lux Light Meter Free" app.
Thus, in this way the ambient light condition of the room and light intensity for different dimming levels have been measured and is shown in Fig. 11. Table 2 lists the measured light intensity for various dimming values. The transmitted and received data for dimming value 0.5 and 0.75 is shown Figs. 12 and 13 respectively.

Throughput versus distance
The VLC prototype's throughput is also evaluated by varying the distance between the transmitter and receiver. In the experiments, three dimming levels (0.25, 0.5, and 0.75) were tested. Each marker in the result plot shown in Fig. 14 represents a 30-s experiment and is listed in Table 3. It is observed that the VLC prototype maintains its peak throughput    at dimming levels 0.5 and 0.75 at distances of up to 3.5 m, and at dimming level 0.25 at distances of up to 3 m. After this distance, the throughput for the respective dimming levels drops dramatically because the received signal strengths are insufficient for the receiver to decode the signal. Given that the height of the ceiling in a typical office/home is usually around 2.5 to 3 m, the communication distance of 3.5 m supported by VLC prototype for dimming values 0.5, 0.75, and 3 m for dimming value 0.25 is sufficient in practice. Furthermore, it is also observed that the LED dimming level has no effect on the VLC system's communication distance.

Throughput versus incident angle
The performance of the presented VLC system is further evaluated under different incident angles. During the experiments, the distance between the transmitter and receiver is kept constant while the incident angles for the various dimming levels are varied. Experiments are carried out at various distances (1 m, 2 m, and 3 m) between the transmitter and receiver. Figure 15 depicts the performance of various dimming levels under different incident angles and the results are listed in Table 4. The VLC system nearly maintains its performance for different dimming values with LED Field of View (FOV). It is also observed that irrespective of the dimming level longer distance has shorter cut off incident angle. This is due to the fact that the system has already reached the upper bound of the communication distance before the incidence angle begins to affect it.

Conclusions
Dimming and visible light communication co-design is an important topic. Dimming controlled MH-HPPM is implemented in this paper to achieve different dimming levels without flickering while also achieving and maintaining peak throughput of 130 KBps (Kilo Bytes per second) and 125 KBps up to a distance of 3.5 m for dimming level of 0.5 and 0.75 respectively, whereas it maintains peak throughput of 110 KBps up to a distance of 3 m for dimming level of 0.25. With LED Field of View (FOV), the VLC system practically retains its performance for varying dimming values. It is also discovered that, regardless of the dimming level, a greater distance has a smaller cut off incident angle. The VLC prototype was built with low-cost off-the-shelf components, and extensive testing shows that MH-HPPM technique is adequate for use as an alternative dimming method. As a result, the dimming-controlled MH-HPPM VLC prototype has the potential to pique the interest of additional system-level research efforts to improve the throughput of the system, codesigning smart lighting and communication.
Funding This research is not funded.

Data availability No external data is used.
Code availability Code is not available elsewhere except the authors.

Declarations
Conflict of interest To our best knowledge this work doesn't have any conflicts of interest.