Post Top Ad

Thursday, February 22, 2024

How To Make Amazing and Useful LI-fi Project | Using for Secret Data Transfer


 How To Make Amazing and Useful LI-fi Project | Using for Secret Data Transfer

Li-Fi is an emerging wireless communication technology that uses visible light to transmit data.


In this instructable we make a simple Li-Fi system that can send messages from one laptop to another.


This can be used to secretly communicate with your friends in a wifi free environment.


The instructable is made for the Tu Delft course: TfCD assignment 2

Use the hardware components to build the two circuits.


Circuit one:


Circuit one is made to send data. 2 cables an Arduino, a breadboard and an LED are needed. The first picture illustrates the circuit with a resistor.


1. Connect a wire to digital port 10 and to the plus side of the LED (the longest wire is the plus side of the LED).


2. Use a wire to connect the minus side of the LED to the ground port on the Arduino.


Optional step: Add a 220 Ohm resistor to prevent the LED from overheating. Connect as illustrated in the picture.


Circuit two:


Circuit two is made to receive data. 3 cables, an LDR and a 10K ohm resistor are needed to make this circuit. The second picture illustrates the circuit.


1. Use a wire to connect the 5 volts to one side of the LDR.

2. Use a wire to connect the other side of the LDR to analog port A0.


3. Connect the 10k Ohm resistor to the side of the LDR that is connected to port A0, as illustrated in the picture.


4. Connect the other side of the 10k Ohm resistor to the breadboard.


5. Connect the non-connected side of the Ohm resistor to the ground on the Arduino.

Use the Arduino software to build the code.


Code one:


This code tells the Arduino to blink the led for a specific amount of time. With this code, it is possible to send two messages, because this is a simple setup you can only choose from a list of predetermined messages, but you can also make different durations correspond with the letters of the alphabet and send full messages that way, It would be wise to reduce the time to send a message in that case by editing the delay times. Since you might be in a situation with more or less light than us you might need to edit the threshold sensor value in the code. To determine what this value is, uncomment the print sensor value command and check the values of the sensor when the led is on and off and take a value in between.


Copy the following code to Laptop 1.

// code for receiving using the LDR


unsigned long StartTime = millis();


unsigned long Value; unsigned long EndTime;


int Message;


boolean StartedCounting = false; //this is used to determine if the counting has started


void setup() { Serial.begin(9600); }


void loop() {


int sensorValue = analogRead(A0); //read the sensor value


delay(1); // to stabilize


// Serial. println(sensorValue); // this can be used to determine the threshold in your lighting conditions

if (StartedCounting==false && sensorValue>850){ //if the counting has not yet started and the light is on


StartTime = millis(); // This saves the current time in milliseconds


StartedCounting=true; }


if (StartedCounting== true && sensorValue<850){ // if the counting has started and the light is off


Value = millis() - StartTime; // subtract the starting time from the current time to get message time Message= Value/1000;


StartedCounting=false;


Serial.print("Message: ");


if (Message == 1){ // change these to your own messages. The sender should also have this list so they know what they are sending.

Code two:


This code tells the Arduino to count the number of seconds that the LDR is lit. It couples the number of seconds to a message and prints it in the serial monitor, so make sure it is open.


Copy the following code to Laptop 1.


// code for sending the message with the LED



int Message1 = 6; // set the number of the first message you want to convey


int Message2 = 2; // set the number of the second message you want to convey boolean Message1done = false; // this will be used to determine if the first message has been sent

int i=0;


int j=0;


void setup()


{ pinMode(10, OUTPUT); //pin connected to the led Serial.begin(9600); //sets serial port for communication }


void loop(){


if (i < Message1) { // Sending the first message. This will loop until i has reached the value of message1


digitalWrite(10,HIGH); // turn on the LED


i++; //increase i with 1


delay(1010); // wait for a second (1010 miliseconds, a little more than a second to correct inaccuracies) }else if (Message1done == false){ // once the led has been lit long enough it will be turned off a


digitalWrite(10,LOW);


delay(1000); // wait a second before sending the next message


Message1done=true; // note that one message has been sent }


if ((j < Message2) && (Message1done == true)) { // sending the second message only if message one is done


digitalWrite(10,HIGH); //this code is in principle the same as for message 1


j++;


delay(1010); }


else if (Message1done == true) { digitalWrite(10,LOW);exit(0); // stop the execution of the code when both messagesare sent } }

In this step, everything gets connected.


The sender:


1. Connect hardware one to laptop one.


2. Upload the software to blink the LED to the Arduino.


The receiver:


1. Connect hardware two to laptop two.


2. Upload the software to blink the LED to the Arduino.


Place the LDR and the LED next to each other.


Send a message.


It works best if you reset both Arduinos before sending a new message.


 How To Make Amazing and Useful LI-fi Project | Using for Secret Data Transfer

Li-Fi is an emerging wireless communication technology that uses visible light to transmit data.


In this instructable we make a simple Li-Fi system that can send messages from one laptop to another.


This can be used to secretly communicate with your friends in a wifi free environment.


The instructable is made for the Tu Delft course: TfCD assignment 2

Use the hardware components to build the two circuits.


Circuit one:


Circuit one is made to send data. 2 cables an Arduino, a breadboard and an LED are needed. The first picture illustrates the circuit with a resistor.


1. Connect a wire to digital port 10 and to the plus side of the LED (the longest wire is the plus side of the LED).


2. Use a wire to connect the minus side of the LED to the ground port on the Arduino.


Optional step: Add a 220 Ohm resistor to prevent the LED from overheating. Connect as illustrated in the picture.


Circuit two:


Circuit two is made to receive data. 3 cables, an LDR and a 10K ohm resistor are needed to make this circuit. The second picture illustrates the circuit.


1. Use a wire to connect the 5 volts to one side of the LDR.

2. Use a wire to connect the other side of the LDR to analog port A0.


3. Connect the 10k Ohm resistor to the side of the LDR that is connected to port A0, as illustrated in the picture.


4. Connect the other side of the 10k Ohm resistor to the breadboard.


5. Connect the non-connected side of the Ohm resistor to the ground on the Arduino.

Use the Arduino software to build the code.


Code one:


This code tells the Arduino to blink the led for a specific amount of time. With this code, it is possible to send two messages, because this is a simple setup you can only choose from a list of predetermined messages, but you can also make different durations correspond with the letters of the alphabet and send full messages that way, It would be wise to reduce the time to send a message in that case by editing the delay times. Since you might be in a situation with more or less light than us you might need to edit the threshold sensor value in the code. To determine what this value is, uncomment the print sensor value command and check the values of the sensor when the led is on and off and take a value in between.


Copy the following code to Laptop 1.

// code for receiving using the LDR


unsigned long StartTime = millis();


unsigned long Value; unsigned long EndTime;


int Message;


boolean StartedCounting = false; //this is used to determine if the counting has started


void setup() { Serial.begin(9600); }


void loop() {


int sensorValue = analogRead(A0); //read the sensor value


delay(1); // to stabilize


// Serial. println(sensorValue); // this can be used to determine the threshold in your lighting conditions

if (StartedCounting==false && sensorValue>850){ //if the counting has not yet started and the light is on


StartTime = millis(); // This saves the current time in milliseconds


StartedCounting=true; }


if (StartedCounting== true && sensorValue<850){ // if the counting has started and the light is off


Value = millis() - StartTime; // subtract the starting time from the current time to get message time Message= Value/1000;


StartedCounting=false;


Serial.print("Message: ");


if (Message == 1){ // change these to your own messages. The sender should also have this list so they know what they are sending.

Code two:


This code tells the Arduino to count the number of seconds that the LDR is lit. It couples the number of seconds to a message and prints it in the serial monitor, so make sure it is open.


Copy the following code to Laptop 1.


// code for sending the message with the LED



int Message1 = 6; // set the number of the first message you want to convey


int Message2 = 2; // set the number of the second message you want to convey boolean Message1done = false; // this will be used to determine if the first message has been sent

int i=0;


int j=0;


void setup()


{ pinMode(10, OUTPUT); //pin connected to the led Serial.begin(9600); //sets serial port for communication }


void loop(){


if (i < Message1) { // Sending the first message. This will loop until i has reached the value of message1


digitalWrite(10,HIGH); // turn on the LED


i++; //increase i with 1


delay(1010); // wait for a second (1010 miliseconds, a little more than a second to correct inaccuracies) }else if (Message1done == false){ // once the led has been lit long enough it will be turned off a


digitalWrite(10,LOW);


delay(1000); // wait a second before sending the next message


Message1done=true; // note that one message has been sent }


if ((j < Message2) && (Message1done == true)) { // sending the second message only if message one is done


digitalWrite(10,HIGH); //this code is in principle the same as for message 1


j++;


delay(1010); }


else if (Message1done == true) { digitalWrite(10,LOW);exit(0); // stop the execution of the code when both messagesare sent } }

In this step, everything gets connected.


The sender:


1. Connect hardware one to laptop one.


2. Upload the software to blink the LED to the Arduino.


The receiver:


1. Connect hardware two to laptop two.


2. Upload the software to blink the LED to the Arduino.


Place the LDR and the LED next to each other.


Send a message.


It works best if you reset both Arduinos before sending a new message.

No comments:

Post a Comment

Post Top Ad

Pages