DIY Li-Fi Using Arduino Uno

48,143

49

14

Introduction: DIY Li-Fi Using Arduino Uno

Very simple and useful project to understand the working of Li-Fi, you can also make your own Li-Fi device with a bit more modifications to the design and code provided. You actually need two arduino's, one to send and the other to receive to make it more fun.

Step 1: ​Getting Started

Components needed

100 ohm resistor,

1 K resistor,

LED,

LDR,

Arduino Uno

Step 2: Setting Up Connections

Connect one end of 100 ohm resistor to pin number 13 and the other end to the positive terminal of led, the other end of led goes to GND pin. Also connect the ldr as shown. You can also use male to female jumper wires directly for connecting the resistor and ldr.

Step 3: Setting Up Even Light

As the ldr values depend upon the surrounding light and also led cannot emit even light I have used a small paper pipe and placed the led through one end and ldr at the other end of it.

Now you are all set to start coding.

Step 4: Code

//copy this code and start modifying

int sensorPin = A0; // select the input pin for ldr

int sensorValue = 0; // variable to store the value coming from the sensor

int light=0;

int i=0;

int d[32];

int temp=1;

int k=0; int add=0;

int a=1001;//-------------- replace with any value of your choice

void setup()

{ pinMode(13, OUTPUT); //pin connected to the relay

Serial.begin(9600); //sets serial port for communication

Serial.println(sensorPin);

int b;

while(a!=0)

{

b=a%2; //converts binary to decimal

a=a/2;

if(b==1)

{

digitalWrite(13,HIGH);

delay(2);

sensorValue=analogRead(sensorPin);

d[i]=sensorValue; }

else

{

digitalWrite(13,LOW);

delay(2);

sensorValue=analogRead(sensorPin);

d[i]=sensorValue;

}

i++;

} i--;

// for converting binary to decimal

while(i>=0)

{

if(d[i]>=75&&d[i]<700)

{

k=i;

while(k!=0)

{

temp=temp*2;

k--;

}

add=add+temp;

temp=1;

}

i--;

}

Serial.println(add); // Final recieved value gets printed

digitalWrite(13,LOW); }

void loop()

{

}

Step 5: Further Applications

You can make few changes to the code and make it work for characters and also you can use a light bulb instead of led which can give more light evenly than the led which is the actual concept of Li-Fi.

Enjoy.

1 Person Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

14 Discussions

0
benjamincreem

I've expanded this to use 2 arduinos. Sends data incredibly slow but it works great. Release 0.5 is for 2 arduinos. Receiver just continuously receives data from transmitter. Be sure to start the receiver first and then the transmitter. Receiver prints whatever it receives to Serial Monitor. Set up the ldr on the receiver arduino the same way that it is setup in this instructable. Setup the led on the transmitter arduino the same way that it is setup in this instructable. Transmitter sends hard coded data.

Release 1.0 includes SD cards. Setup the SD cards readers. Will likely need to change the pin number for the led on the transmitter, as the sd card will use pin 13. I used pin 8 for the led instead. Transmitter reads info file from the sd card and sends. Receiver receives the file and writes all data to its own card. Again, start the receiver first. Transmitter sends the file size, size of the file name, the file name, and then the actual file. Receiver knows when to close the file when it has written filesize bytes to the file. May create my own instructable if anyone is interested.

Code can be found here:

https://github.com/BenjaminCreem/ArduinoLifi

0
shreyas1si15ec097
shreyas1si15ec097

Question 2 years ago

Hey Hi instead of using one character.I want to interface with serial monitor.And whatever text i type it must take in and convert to decimal and detected by LDR

0
ATR0011
ATR0011

3 years ago

hey UdayN I would like to do this as a project...can u explain how I could transmit audio signal using the above lifi project , and one more thing is there a specific model of arduino uno that is required.Please reply as soon as you can

0
noahdekker
noahdekker

3 years ago

does it work the whole process

0
abdulhye
abdulhye

3 years ago

how can it receive data???

0
MaxV39
MaxV39

4 years ago

how do I make it send different information? it just sends a 14 and a 0

0
FelixK14
FelixK14

4 years ago

there is something wrong in the script: if i unplug the ldr, the serial monitor still shows my value "a"

0
UjasP2
UjasP2

4 years ago

What is the value of capacitor used ?

0
KiloVision
KiloVision

4 years ago

FYI, visible light is not 100x faster than radio waves. Both travel at the speed of light.

0
UdayN
UdayN

Reply 4 years ago

Yeah, it's actually the spectrum of light which is 10,000 times larger than the radio waves we use for Wi-Fi, which makes Li-Fi 100 times faster