Contents
Overview
Data transmission through LiFi using Arduino involves leveraging the capabilities of Arduino microcontrollers and Light Emitting Diodes (LEDs) to establish wireless communication through light waves. In this setup, an Arduino board is configured to modulate the intensity of an LED, encoding data into light pulses. On the receiving end, another Arduino board equipped with a light sensor detects these light variations and decodes the transmitted data. This approach offers advantages such as high-speed data transmission, immunity to electromagnetic interference, and enhanced security. By combining the simplicity of Arduino with the innovative potential of Li-Fi technology, enthusiasts can embark on projects to explore and develop their own Li-Fi communication systems for various applications, from educational experiments to real-world solutions
Introduction
In the digital age, where data transmission is at the heart of connectivity, innovative technologies constantly emerge to enhance efficiency and reliability. One such groundbreaking innovation is Li-Fi, poised to revolutionize data transmission through light. This introduction delves into the realm of Li-Fi, shedding light on its principles, applications, and potential impact on the future of connectivity.
In the ever-evolving landscape of digital communication, the Arduino platform continues to empower enthusiasts and professionals alike to explore innovative solutions. One such groundbreaking endeavor involves leveraging Arduino to delve into the realm of Li-Fi, a cutting-edge technology revolutionizing data transmission through light. This introduction serves as a beacon for Arduino enthusiasts, shedding light on the fascinating intersection of Li-Fi and Arduino and paving the way for exciting experiments and projects.
Bill Of Materials
SN | COMPONENTS NAME | QUANTITY | ALIEXPRESS LINK | AMAZON LINK |
---|---|---|---|---|
1 | Arduino Nano | 1 | ALI-EXPRESS BUY | AMAZON BUY |
2 | Arduino Uno | 1 | ALI-EXPRESS BUY | AMAZON BUY |
3 | LED'S | Some | ALI-EXPRESS BUY | AMAZON BUY |
4 | LCD Display 16*2 | 1 | ALI-EXPRESS BUY | AMAZON BUY |
5 | Mini Solar Panel | 1 | ALI-EXPRESS BUY | AMAZON BUY |
6 | Connecting Wires | Some | ALI-EXPRESS BUY | AMAZON BUY |
7 | Bread Board | 1 | ALI-EXPRESS BUY | AMAZON BUY |
Block Diagram of data transmission through li-fi using Arduino
Below is a block diagram explanation of the data transmission through Li-Fi using Arduino and LED in the transmitter, and a 16*2 LCD and Arduino in the receiver.
Transmitter Side:
- Arduino Microcontroller: At the heart of the transmitter is an Arduino board, serving as the central processing unit. The Arduino is programmed to control the modulation of an LED based on the data to be transmitted.
- LED Module: An LED light is connected to the Arduino board. The Arduino modulates the intensity of the LED to encode the data into light pulses. Rapid variations in the LED’s brightness represent binary data (1s and 0s).
- Data Source: The data source could be a sensor, a computer, or any device capable of generating data. This data is processed by the Arduino and encoded into light pulses for transmission. In our case we are providing data from the serial monitor of Arduino IDE.
Receiver Side:
- Arduino Microcontroller: On the receiver side, another Arduino board is utilized. This Arduino board is responsible for receiving the transmitted light signals and decoding them back into usable data.
- 16*2 LCD Display: A 16*2 LCD display module is connected to the receiver Arduino. This display serves as the output medium for the received data. The decoded data is displayed on the LCD screen in a human-readable format.
- Light Sensor: A light sensor, such as a photodiode or phototransistor, is connected to the receiver Arduino. The sensor detects variations in light intensity caused by the transmitted light pulses. In our case we are using solar pan
Data Transmission:
- The transmitter Arduino encodes data into light pulses by modulating the LED’s intensity.
- The receiver Arduino captures the light pulses using the light sensor.
- The received light signals are decoded by the receiver Arduino, converting them back into binary data.
Display and Output:
- The decoded data is displayed on the 16*2 LCD connected to the receiver Arduino.
- Users can observe the transmitted data in real-time on the LCD display, providing a tangible output of the Li-Fi communication process.
Circuit Diagram
Circuit Diagram Transmitter Side
Below is a simple circuit diagram for the transmitter side of data transmission through Li-Fi using Arduino, with the LED connected to pin number 12.
In this circuit:
- The Arduino is powered by connecting its +5V (VCC) pin to a power source and its GND pin to the ground (GND).
- The LED is connected to digital pin 12 (Pin 12) of the Arduino. The anode (+) of the LED is connected to Pin 12, and the cathode (-) is connected to the ground (GND) of the Arduino.
Note: You can use resistor between pin 12 and led in this circuit as per the selection of the LED.
Circuit Diagram Receiver Side
Below is the circuit diagram for the receiver side of data transmission through Li-Fi using Arduino, including a solar panel for power and a 16*2 LCD display connected via I2C.
In this circuit:
- The Arduino is powered by connecting its +5V (VCC) pin to a power source and its GND pin to the ground (GND).
- The solar panel is connected to analog pin A3 of the Arduino. The positive (+) terminal of the solar panel is connected to A3, and the negative (-) terminal is connected to the ground (GND) of the Arduino.
- The 16*2 LCD display is connected to the Arduino using the I2C protocol. The VCC pin of the LCD is connected to +5V (VCC) of the Arduino, the GND pin is connected to GND, the SDA pin is connected to analog pin A4 (SDA), and the SCL pin is connected to analog pin A5 (SCL).
Flow chart
Flow Chart Transmitter side
Flow Chart Receiver side
Fig: Flow chart of the transmitter side of data transmission through LiFi using Arduino.
Working Principle
- In our LiFi system, we have implemented the RS232 standard for data transmission, ensuring reliable communication between the transmitter and receiver.
- Let us assume we are transmitting the data “hello world,” each character is converted into its respective ASCII code and then into binary representation .
- The binary data is stored in a register and left rotation is performed.
- The first bit of the rotated data is checked, and based on its value, the LED connected the Arduino is either turned on or off.
- This process is repeated after certain delay until the transmission is completed.
- When the data transmission is completed, the LED is set to a high state, indicating the end of the communication process.
- At the receiver end of our LiFi system, a photovoltaic cell is connected to the analog pin of the Arduino.
- When the light falls on the solar panel, the voltage will induced on it. The induced voltage is detected by the microcontroller and compared with the threshold voltage set by the potentiometer.
- If the induced voltage exceeds the threshold voltage, the microcontroller sets the corresponding value as ‘1‘ otherwise, it is set as ‘0’.
- The detected value is stored on the buffer and when the microcontroller acknowledge about the completion of transmission, it decodes the data in the buffer into a ASCII decimal value and hence character.
- Finally this character is display into serial monitor and the I2C LCD display.
Example
Let us assume the data to be transmit is ‘A’
Its ASCII value in decimal is ‘65’ or binary is ‘01000001’
Program or Source code
Transmitter side Program
//ARDUINO LIFI TRANSMITTER
#define TRANSMIT_LED 12
#define SAMPLING_TIME 5
String text;
bool led_state = false;
bool transmit_data = true;
int bytes_counter = 20;
int total_bytes;
void setup() {
Serial.begin(9600);
pinMode(TRANSMIT_LED, OUTPUT);
text="HelloThisIs LiFi #";
}
void loop() {
if(Serial.available())
{
text=Serial.readString();
text.trim();
Serial.println(text);
text.concat(" #");
}
total_bytes = text.length();
while (transmit_data)
{
transmit_byte(text[total_bytes - bytes_counter]);
bytes_counter--;
if (bytes_counter == 0)
{
transmit_data = false;
}
//delay(100);
}
transmit_data = true;
bytes_counter = total_bytes;
delay(1000);
}
void transmit_byte(char data_byte)
{
digitalWrite(TRANSMIT_LED, LOW);
delay(SAMPLING_TIME);
for (int i = 0; i < 8; i++)
{
digitalWrite(TRANSMIT_LED, (data_byte >> i) & 0x01);
delay(SAMPLING_TIME);
}
digitalWrite(TRANSMIT_LED, HIGH);
delay(SAMPLING_TIME);
}
Receiver side Program
// ARDUINO LIFI RECEIVER
#include<LiquidCrystal_I2C.h>
#define LDR_PIN A3
#define SAMPLING_TIME 5
LiquidCrystal_I2C lcd(0x27, 16, 2);
//Declaration
bool led_state = false;
bool previous_state = true;
bool current_state = true;
char buff[64];
int threshold;
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.setCursor(0, 0);
lcd.backlight();
lcd.print("hello lifi");
delay(2000);
lcd.clear();
}
void loop()
{
//threshold = analogRead(A6);
//Serial.println(threshold);
current_state = get_ldr();
if (!current_state && previous_state)
{
sprintf(buff, "%c", get_byte());
Serial.print(buff);
lcd.print(buff);
if (strcmp(buff, "#") == 0)
{
lcd.clear();
}
}
// digitalWrite(LED, current_state);
previous_state = current_state;
//Serial.println(finaldata);
}
bool get_ldr()
{
//bool val = analogRead(LDR_PIN) > threshold ? true : false;
bool val = analogRead(LDR_PIN) > 390? true : false;
return val;
}
char get_byte()
{
char data_byte = 0;
delay(SAMPLING_TIME * 1.5);
for (int i = 0; i < 8; i++)
{
data_byte = data_byte | (char)get_ldr() << i;
delay(SAMPLING_TIME);
}
return data_byte;
}