Skip to content

Commit 2dc2027

Browse files
committed
archive
0 parents  commit 2dc2027

21 files changed

+1348
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Ramon Qu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
670 KB
Binary file not shown.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# LI-FI-Arduino
2+
3+
## Please check the paper vlc_paper.pdf
4+
<object data="vlc_paper.pdf" type="application/pdf" width="700px" height="700px">
5+
<embed src="vlc_paper.pdf">
6+
This browser does not support PDFs. Please download the PDF to view it: <a href="vlc_paper.pdf">Download PDF</a>.</p>
7+
</embed>
8+
</object>
9+
### If you have any question please send email to quramon@gmail.com, Thanks
10+
11+
Wireless communications, such as Wi-Fi and Bluetooth, are commonly used in the daily life. However, while more and more wireless devices occupy the available frequencies, the frequency spectrum is reaching a maximum capacity.
12+
13+
Thus, Li-Fi, communicating using light waves between two devices, becomes a future solution to transmit data. LED devices with a data wave generator may keep the lighting functionality of a LED while sending data in the background. With the full range of the visible and infrared light spectrum, we may transmit data day and night. With Li-Fi, data communication happens indoors with low latency and high speed and is hard to hijack from outside the room. On the receiver side, a small solar panel both receives the signal and recycles the power to charge the battery for future use. It thus saves energy lost in standard wireless data transmission. The system consists of two Arduino (microcontroller) devices as the emitter and receiver. The user interface, based on the Python programming language, is used to control sending and receiving data. Infrared LED signals the beginning and end of the data transmission During the transmission, LEDs switching on and off signal binary 0’s and 1’s.
14+
15+
This system can transmit text and images successfully. However, with the limitation of the consumer-grade solar panel’s response time, it is hard to reach high speeds in data transmission. With high-end and low-response-time components, it will be able to transmit live videos at high speeds. The Li-Fi system not only provides the basic lighting function but also sends the data and power to the receiver side.
16+
## ----------------------------
17+
## Usage
18+
- pypic -
19+
Python end for receiver side.
20+
Pypic.py is reeiver Side
21+
22+
- transmitter
23+
Python for transmitter(emitter side)
24+
25+
- re_calib
26+
Arduino Code for Light threathold calibration.
27+
28+
- re_data
29+
Arduino code for Light Receiver side
30+
31+
- tran
32+
Arduino code for Light Emitter side
33+
34+
- tr/transmitter1
35+
Arduino code for Light Emitter side testing
2.26 KB
Binary file not shown.

pypic/basefunction.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import serial
2+
import binascii
3+
import sys
4+
import base64
5+
import matplotlib.pyplot as plt
6+
import matplotlib.image as mpimg
7+
from tqdm import tqdm
8+
9+
from tkinter import *
10+
from tkinter import ttk
11+
def serial_begin():
12+
ser = serial.Serial('COM3', 115200, timeout=.1)
13+
return ser
14+
15+
16+
def image_receive(ser):
17+
flag = False
18+
while True:
19+
a = ser.readline()
20+
data = a
21+
if (len(a) > 0):
22+
pbar = tqdm(total=100)
23+
if (not flag):
24+
n = int(a, 2)
25+
print(n)
26+
pic = ""
27+
picdata = ""
28+
count = 0
29+
while len(pic) < n * 8:
30+
# print("1")
31+
a = ser.readline()
32+
if (len(str(a)) > 15):
33+
pic += str(a)[2:17]
34+
# print(str(a)[2:17])
35+
pbar.update(15 / n / 8 * 100)
36+
elif (len(str(a)) > 3):
37+
pic += str(a)[2:-5]
38+
# print(str(a)[2:-5])
39+
pbar.update((len(str(a)) - 7) / n / 8 * 100)
40+
41+
print(pic)
42+
# print(len(pic))
43+
44+
45+
i = 0
46+
print(pic)
47+
data = [pic[i:i + 8] for i in range(0, len(pic), 8)]
48+
print(len(data))
49+
for i in data:
50+
data_part = i
51+
x = int(data_part, 2)
52+
message = chr(x)
53+
picdata += message
54+
print(picdata)
55+
# picdata+="QBAEAQBAEAQBAEAQBAEAQBAEAQBAEAQBAEAQBAEAQBAf/2Q=="
56+
57+
picdata = base64.standard_b64decode(picdata)
58+
59+
fh = open("C:/Users/Ramon Qu/Desktop/vlc/untitled/img/imageToSave.jpg", "wb")
60+
fh.write(picdata)
61+
fh.close()
62+
img = mpimg.imread('C:/Users/Ramon Qu/Desktop/vlc/untitled/img/imageToSave.jpg')
63+
plt.imshow(img)
64+
plt.show()
65+
66+
def text_receive(ser,tl):
67+
while (1):
68+
a = ser.readline()
69+
70+
data = a
71+
if (str(data)[2:-5] == "00010"):
72+
# print(2)
73+
while (1):
74+
a = ser.readline()
75+
data = a
76+
# print(len(a))
77+
if (str(data)[2:-5] == "00011"):
78+
# print("END")
79+
print()
80+
tl.insert(INSERT,"\t")
81+
break
82+
if (len(data) > 3):
83+
print(chr(int(data, 2)), end="")
84+
tl.insert(INSERT,chr(int(data, 2)))
85+
sys.stdout.flush()

pypic/expimg/April_Fools_Day-128.png

7.7 KB
Loading

pypic/expimg/b96_15-128.png

3.43 KB
Loading

pypic/expimg/b96_16-256.png

9.87 KB
Loading

pypic/img/imageToSave.jpg

4.31 KB
Loading

pypic/pypic.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
'''
2+
Li-Fi VIsible Light Communication System. Yiren Ramon Qu, Lyndon Institute, VT
3+
MIT License
4+
Copyright (c) 2017 Yiren Qu
5+
6+
Li-Fi Receiver Side
7+
'''
8+
import serial
9+
import binascii
10+
import sys
11+
import base64
12+
import matplotlib.pyplot as plt
13+
import matplotlib.image as mpimg
14+
from tqdm import tqdm
15+
16+
ser = serial.Serial('COM3', 115200, timeout=.1) # Start the serial connectiion
17+
18+
19+
print("######################################################\n"
20+
"##--------------------START-------------------------##\n"
21+
"######################################################\n"
22+
"##-------------------Receiver-----------------------##\n"
23+
"##---------------------Side-------------------------##\n"
24+
"##----------------Start Receiving ------------------##\n"
25+
"##--------------------------------------------------##\n"
26+
"######################################################\n"
27+
)
28+
a = input()
29+
'''
30+
Input 's' or 't'
31+
's' - Receving the image
32+
't' - Receving the text
33+
'''
34+
if (a == "s"):
35+
print(
36+
"##-------------Receiving Image Mode--------------##\n"
37+
"##--------------------------------------------------##\n"
38+
"||||||||||||||||||||||||||||||||||||||||||||||||||||||\n"
39+
"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"
40+
" \n"
41+
)
42+
flag = False
43+
while True:
44+
a = ser.readline()
45+
data = a
46+
if (len(a) > 0):
47+
pbar = tqdm(total=100)
48+
if (not flag):
49+
n = int(a, 2)
50+
# n is the number of packets need to be received
51+
print(n)
52+
pic = ""
53+
picdata = ""
54+
count = 0
55+
while len(pic) < n * 8:
56+
# Receive the packet and save back to a complete binary string
57+
a = ser.readline()
58+
if (len(str(a)) > 15):
59+
pic += str(a)[2:17]
60+
pbar.update(15 / n / 8 * 100)
61+
elif (len(str(a)) > 3):
62+
pic += str(a)[2:-5]
63+
pbar.update((len(str(a)) - 7) / n / 8 * 100)
64+
print(pic)
65+
i = 0
66+
#Parse the image to 8 bits/group and convert back to character
67+
data = [pic[i:i + 8] for i in range(0, len(pic), 8)]
68+
print(len(data))
69+
for i in data:
70+
data_part = i
71+
x = int(data_part, 2)
72+
message = chr(x)
73+
picdata += message
74+
print(picdata)
75+
#The string is a base-64 string representing an image
76+
picdata = base64.standard_b64decode(picdata)
77+
#Save this image and open it with plot library
78+
fh = open("C:/Users/Ramon Qu/Desktop/vlc/pypic/img/imageToSave.jpg", "wb")
79+
fh.write(picdata)
80+
fh.close()
81+
img = mpimg.imread('C:/Users/Ramon Qu/Desktop/vlc/pypic/img/imageToSave.jpg')
82+
plt.imshow(img)
83+
plt.show()
84+
if a=="t" :
85+
print(
86+
"##-------------Receiving Text Mode---------------##\n"
87+
"##--------------------------------------------------##\n"
88+
"||||||||||||||||||||||||||||||||||||||||||||||||||||||\n"
89+
"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"
90+
" \n"
91+
)
92+
count = 0
93+
while(1):
94+
a = ser.readline()
95+
data = a
96+
if(str(data)[2:-5]=="00010"):
97+
#Detect whether received a start signal binary
98+
print("----------------> No."+(str(count)),end="")
99+
while(1):
100+
a = ser.readline()
101+
data = a
102+
if(str(data)[2:-5]=="00011"):
103+
#If detecting the end signal, exit and wait a new start.
104+
print()
105+
count+=1
106+
break
107+
if(len(data)>3):
108+
#If it is a character, print this character on the same line.
109+
print(chr(int(data,2)),end="")
110+
sys.stdout.flush()
111+

0 commit comments

Comments
 (0)