Saturday, 18 October 2014

sfpduino - Arduino SFP optical power meter

I thought it might be interesting to see what I could do with an SFP and an Arduino UNO. My first introduction to Atmel micro-controllers was with the Atmel AVR Butterfly. While the Butterfly is a fantastic piece of hardware it is much quicker to create and test things with the Arduino UNO. 















I have powered the SFP off the 3V power supply on the Arduino UNO and the 16x2 LCD with the 5V supply. I am using the Arduino Liquidcrystal display library hence all the wires! See here for the wiring diagram for the display. http://arduino.cc/en/Tutorial/LiquidCrystal
To connect the SFP to the Arduino UNO I used the Arduino Wire library. http://arduino.cc/en/reference/wire

My SFP is a third party cheap 1310nm transceiver. The SFP is plugged into a Samtec SFP header and is mounted on a piece of  perf board for convenience. The demo code below prints out the temperature and the optical power receive from the SFP using the Arduino UNO as the i2c Master. As most 1310nm SFPs can typically receive light from 1200-1600nm it could be interesting to make a very small plugable coin battery powered optical power meter with a display where all you had to do was add your own SFP with DOM. The sort of thing that you could put on a key ring and give away at trade shows.

While SFF-8472 states that the optical power receive accuracy must be better than +/-3dB. I did a quick test with 1310nm and 1550nm light sources (plus several different attenuators) and compared the measured results between a real calibrated optical power meter and my SFP. I was quite surprised that the SFP power values were typically within 0.2dB of the power meter. 

From SFF-8472
Measured TX output power in mW. Represented as a 16 bit unsigned integer with the power defined as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm).

Internally measured transceiver temperature. Represented as a 16 bit signed twos complement value in increments of 1/256 degrees Celsius, yielding a total range of -128C to +128C.

The entire sketch is below. 

#include <Wire.h>
#include <math.h>
#include <LiquidCrystal.h>

// LCD interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const byte EEPROM_ID = 0x51;
int A51[128];

void setup()
{
  Wire.begin();        
  Serial.begin(9600);  
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
}

byte I2CEEPROM_Read (unsigned int address)
{
  byte data;
  Wire.beginTransmission(EEPROM_ID);
  Wire.write(address);
  Wire.endTransmission();
  Wire.requestFrom(EEPROM_ID,(byte)1);
  while(Wire.available() == 0); data = Wire.read();
    return data;
}

void loop()
{
   for (int i = 96; i <106; i++)
  {
    A51[i] = I2CEEPROM_Read(i);
   }
  float temp = A51[96] + (float) A51[97]/256;
  float optical_rx = 10 * log10((float)(A51[104]<<8 | A51[105]) * 0.0001);
  lcd.setCursor(0, 0);
  lcd.print ("Temp = ");
  lcd.print (temp);
  lcd.print ((char)223); //degree symbol
  lcd.print ("C");
  lcd.setCursor (0, 1);
  lcd.print ("RX = ");
  lcd.print (optical_rx);
  lcd.print (" dBm");
    
delay(1000);
}

23 comments:

  1. code is also here:
    https://github.com/sonicepk/sfpduino

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I am interested in building this my self. Can you please specify me the components used in this project? Also if you have any schematics, can you please mail me anuradhabc@gmail.com
    Thanks!

    ReplyDelete
  4. Hi,

    I connect an sfp 850nm prolabs GLC-SX-MM-C. I connect 4 wire:

    - SFP Vcc tx and Vccrx to ARDUINO UNO 3.3V
    - SFP VeeT and VeeR to ARDUINO UNO GND
    - SFP PIN 4 to ARDUINO UNO A4
    - SFP PIN 5 to ARDUINO UNO A5

    Is it correct?
    Is it compatible my sfp for this project?
    On my display I can view Temp = 0.00 °C and RX = 1.91 dBm

    :-(

    Can you help me?

    maurogalluccio79@gmail.com

    Thanky you
    Mauro

    ReplyDelete
    Replies
    1. Puoi aiutarmi vorrei costruirlo

      Ciao
      Mario

      Delete
    2. Puoi aiutarmi vorrei costruirlo

      Ciao
      Mario

      Delete
  5. Hi Eoin
    Can you mail me the schematic please.
    naveen2k5@gmail.com.

    ReplyDelete
  6. I had problems with the new Wire library, but with Arduino IDE 1.0.1 it worked like a charm. Thank you.
    Márcio

    ReplyDelete
  7. Marcio or Eoin,
    I also would like to make one of these. Please share the schematic to rick.lewark@dowjones.com

    ReplyDelete
  8. I need all its details like schematics and components specifications so that we can built our own. Pl mail at ajay@gjust.org. Whosoever has assembled and tested pl help

    ReplyDelete
  9. I need all its details like schematics and components specifications so that we can built our own. Pl mail at ajay@gjust.org. Whosoever has assembled and tested pl help

    ReplyDelete
  10. Pl mail me all details so that we can assemble ourselves at ajay@gjust.org

    ReplyDelete
  11. Please share the schematic to ertan00@gmail.com

    ReplyDelete
  12. Please share the schematic to adnizio@gmail.com

    ReplyDelete
  13. can u share the schematic to muh.adnansuryaazis@gmail.com ?

    ReplyDelete
  14. Please share the schematic to elektro.seco@gmail.com

    ReplyDelete
  15. PLease share me circuit design to aungsatmon.mm@gmail.com

    ReplyDelete
  16. Please share the schematic to arioo2802798@gmail.com

    ReplyDelete
  17. Interesting poste and idea. I would like to try by myself. Could you send me schematic to jawad4abida@gmail.com

    ReplyDelete
  18. Hi Eoin
    would you please mail me the schematic and wireing thak you.
    hmd.message@gmail.com

    ReplyDelete
  19. Hello Eoin! I am working on a senior design project similar to this and was wondering if you can email me at edelucia@gwu.edu because I have a few questions that I think you can answer for me! Thanks so much.

    ReplyDelete
  20. Hola Eoin, te pediria por favor si podrias enviarme por correo el esquema del circuito y su cableado. muchas gracias albertzebas@gmail.com

    ReplyDelete
  21. Hi Eoin
    Can you mail me the schematic please.
    gilangpomade@gmail.com

    ReplyDelete