Data Transmission with Optical Fiber - [ PART 6 ] - Optical Fiber Communication with Arduino

In this post, we will use Arduino to implement optical fiber data transmission. In the previous post, we covered all the topics, so let's start building the circuit.

Introduction to Optical Fiber Communications and How does Optical Fiber Communications Works  
Light and its Fundamentals   
What a Optical Fiber Cable is and its Construction  
Optical Fiber Transmission Setup   
Interfacing Optical Fiber Transmission with Arduino 
Optical Fiber Communication with Arduino to Arduino 



Data Transmission with Optical Fiber - Arduino t0 Arduino


I am using the Amplitude Shift Keying (ASK) scheme for communication between two Arduinos through this optical link. To implement ASK, I will utilize the Radiohead Amplitude Shift Keying Library. The transmitter Arduino will read the potentiometer values and use ASK modulation to send them through the optical link. The receiver Arduino will then receive this data from the optical link and convert it back to its original form.

Build the transmitter and receiver circuits according to their diagrams and connect them to their respective devices. The transmitter circuit includes the following components:

- Microcontroller (Arduino)
- HFBR-1414 Optical Fiber Cable Transmitter
- SN75452B Switching Driver
- Resistors with values of 10K (1) and 56 ohms (1)
- Capacitors with values of 0.1uF (3) and 10uF (1)

Here are the circuit connections on the breadboard.


Here is the full setup with Arduino Transmitter and Receiver Circuits:


Connect the fiber cable and power up the boards. Here is the code for the Arduino transmitter and receiver using ASK modulation.

Arduino Transmitter with ASK:

#include <RH_ASK.h>

RH_ASK driver;

int potPin = A0;
int potValue;

void setup() {
  Serial.begin(9600);
  if (!driver.init())
    Serial.println("Initialization failed");
}

void loop() {
  potValue = analogRead(potPin);

  char dataToSend[5];
  itoa(potValue, dataToSend, 10);

  driver.send((uint8_t *)dataToSend, strlen(dataToSend));
  driver.waitPacketSent();

  Serial.println(potValue);

  delay(100);
}


Arduino Receiver with ASK:

#include <RH_ASK.h>

RH_ASK driver;
int potValue;
char receivedData[5];

void setup() {
Serial.begin(9600);
if (!driver.init())
    Serial.println("RadioHead initialization failed");
    driver.available();
}

void loop() {
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);

  if (driver.recv(buf, &buflen)) {
    if (buflen < 5) {
      for (int i = 0; i < buflen; i++) {
        receivedData[i] = (char)buf[i];
      }
      receivedData[buflen] = '\0';

      potValue = atoi(receivedData);

      Serial.println("Received Potentiometer Value: " + String(potValue));
    }
  }
}



Final Result:


For bidirectional communication, you can combine the transmitter and receiver into a single circuit to create a transceiver circuit. This can be easily used for serial communication over optical fiber. You can implement various schemes such as Manchester, 4B5B, or 8B10B, and interface with other protocols like I2C, UART, RS232, and RS485 using this circuit. 
Here is an Arduino bidirectional communication example:


This is a simple demonstration of optical fiber data transmission. Both Arduinos communicate with each other using UART to control the servo motor and LED brightness with potentiometers. I have tested this circuit's range at a distance of 342 meters with an Arduino. I reduced the transmitter current to 15mA, and the circuit works fine. You can download the resources, including the code, transmitter, and receiver models, from this Post.
You can check this video for better understanding:



 I hope you have know understand of optical fiber data transmission fundamentals with Arduino, if you have any suggestion and improvements feel free to write the comments.
stay with us for next unique project with Arduino.