Code to transfer image using Lifi....How?

Hello people,
I am a student stuck in final year project of making Lifi.
I have made hardware folllowing this circuit:

and can transfer text through it.
BUT I can't transfer images and I need the code to transfer the images.So if anyone has that code plz give it to me.
I would really appreciate ur help....

What have you tried?

I have tried to learn how to decode and encode and send the image from this site:

but all that coding is so confusing to merge with my own arduino circuit.

Since sending text works, convert the image file to text and transmit it. No need to decode the JPG image.

#jremington
OH MY GOD man u r a genius…is this as simple as u said?
Just rename image to text?

Also plz provide any line of code that calls a text file to be sent to the reciever.
Currently I am using this code to transmit:

void setup()
{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);

// Clear Timer on Compare Match (CTC) Mode
bitWrite(TCCR1A, WGM10, 0);
bitWrite(TCCR1A, WGM11, 0);
bitWrite(TCCR1B, WGM12, 1);
bitWrite(TCCR1B, WGM13, 0);

// Toggle OC1A and OC1B on Compare Match.
bitWrite(TCCR1A, COM1A0, 1);
bitWrite(TCCR1A, COM1A1, 0);
bitWrite(TCCR1A, COM1B0, 1);
bitWrite(TCCR1A, COM1B1, 0);

// No prescaling
bitWrite(TCCR1B, CS10, 1);
bitWrite(TCCR1B, CS11, 0);
bitWrite(TCCR1B, CS12, 0);

OCR1A = 210;
OCR1B = 210;

Serial.begin(2400);
}

void loop()
{
Serial.println(“testing testing testing”);
delay(500);
}

trans.txt (669 Bytes)

Where is your image stored?

@AWOL & @jremington
Respected Sir what do u mean by where is my image stored?
the above code only transfers text it doesn't transfer image.
I am asking u that what exact line I should write to call the text file to transmit it to reciever?

I am considering to transfer image but in reply#3 said I should rename image to text and transfer...

Where is the image file stored?

@AWOL
it is stored in D:/ drive with name of imagetx

None of my Arduino's has a D:/ drive, so I'm assuming that yours is attached to a PC.
Is the Arduino attached to the same PC?

Currently I am using this code to transmit

I strongly doubt that.

All that code does is set up Timer1 to do something, then prints a single line on the serial monitor.

How could it possibly "send" anything to Lifi?

I'm sure Google can help you. High level these are the steps that you'll want to do:

  1. load your chosen image
  2. convert the image to bits
  3. send these bits instead of the alphabet
  4. reconstruct the image from the received bits
  5. plot the reconstructed image

I think the second step will be the hardest. Try to google for "arduino image to bits" or something like that. Good luck!

  1. convert the image to bits

You don't need to convert the image to anything. You read it as a stream of bytes and transmit them.

Pete

In the video clip, the circuit shows a photodiode but the close up picture is of a light dependent resistor (LDR). With an LDR you have no hope of transmitting data at a reasonable speed.

Here are two methods of transmitting data using an arduino serial connection over IR. One uses a simple photo diode and the other uses a TSOP IR receiver:

I guess that you'll be using an SD card to hold the image file. Look up the code to read an SD card file example: https://www.arduino.cc/en/Tutorial/ReadWrite, read it and write it to a serial port. Presumably on the other side, you'll want to write the transmitted data to another SD card file or what do you intend to do with it ?

You do not have to know how the file you are transmitting is encoded because you are simply streaming bytes. It could be a JPG image or an excel spread sheet or anything. It does not matter.

AWOL:
None of my Arduino's has a D:/ drive, so I'm assuming that yours is attached to a PC.
Is the Arduino attached to the same PC?

@AWOL no sir,thing is I am doing simulations on proteus right now,I have now converted the image into binary through matlab.The matlab gives me the txt file containing binary of that image.

Only problem now remaining is how to call that specific txt file (in my laptop) to arduino in code.

jremington:
I strongly doubt that.

All that code does is set up Timer1 to do something, then prints a single line on the serial monitor.

How could it possibly "send" anything to Lifi?

:confused: @jremington The code actually makes the led to blink(bit 1 means on and 0 means off).Then by this blinking of led it sends the binary information of the string "testing testing testing" to the reciever.....

I guess I answered what u were saying? :slight_smile:

Almost like magic. Absolutely fascinating!