read analog data from sensor tsl 2591

Dear researchers
I made a program to measure the pulses of light and used it for the ldr piece and I connected it to the A0 port but its frequency is very weak 10 Hz and this is why I bought the tsl 2590 but I did not know how to connect it because it has i2c and sda sca pin,I want to read data to me from one of the analog ports even Control their frequency
Here is a copy of a previous program that used ldr at a frequency of 10 Hz

long arr[8];
int i = 0;
int ldr = A0; //pin for ldr
int z = 0;
int y = 0;
long g = 0;
int seuil;
char ascii_values[100] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T','U', 'V', 'W', 'X', 'Y', 'Z', 
                          'a', 'b', 'c', 'd','e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n','o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x','y', 'z',
                          /*62*/ '0', '1', '2', '3', '4', '5', '6', '7','8', '9',
                          ' ', '!', '"', '#', '

, '%' , '&', '(' ,')' , '', '+', ',', '-', '.', '/',
                          ':', ';', '<', '=', '>', '?', '@'};
void setup() {
  Serial.begin(9600);
  int ldrobscu=analogRead(ldr);
  seuil = ldrobscu;
  Serial.print(" ldr en obscurité est:  ");
  Serial.println(seuil);
  Serial.println(" ready for reception ");
  Serial.println("  ");
}
void loop()
{
  if(z>=8){
    z=0; 
  }
    for (int i = 0; i < 8; i++)    {     
    if    ( analogRead(ldr) >= 700)  //
**************************************
    {
      arr[i] = 1;  // Whenever I get a '1' bit,
      z++;
      /*Serial.println("if1");
      Serial.print("1 if arr[] = ");
      Serial.println(arr[i]);
      Serial.print("1 if i = ");
      Serial.println(i);
      Serial.print("z = ");
      Serial.println(z);
      Serial.println("");
    */}
    else {
      arr[i] = 0;  //Whenever I get a bit at '0',
      z = 0;
      /*Serial.println("else1");
      Serial.print("1 else arr[] = ");
      Serial.println(arr[i]);
      Serial.print("1 else i = ");
      Serial.println(i);
      Serial.print("z = ");
      Serial.println(z);
      Serial.println("");
    */}
   
    delay(200);    // the time to capt the bit
    if (z == 8) {

capt();
      //i = 0;
     
    }
  }
}
void capt() {
 
  do {

if(y>=8){
    y=0; 
  }
    for (int j = 0; j < 8; j++)    {
      if      (analogRead(ldr) >= 700)//*******************************************
      {
        arr[j] = 1;
        y = 0;
      /Serial.println("if2");
      Serial.print("2 if arr[] = ");
      Serial.println(arr[j]);
      Serial.print("2 if j = ");
      Serial.println(j);
      Serial.print("y = ");
      Serial.println(y);
      Serial.println("");
      /}
      else {
        arr[j] = 0;  // if the 8 bit not (11111111) and have one or + 0
        y++;        //repeat the loop
        /if(y ==8){
          loop();
        }
/
    /
Serial.println("2 else");
      Serial.print("2 else arr[] = ");
      Serial.println(arr[j]);
      Serial.print("2 else j = ");
      Serial.println(j);
      Serial.print("y = ");
      Serial.println(y);
      Serial.println("");
      /}
      delay(200);
    }
    //Serial.println("
**************** Debut Deco **************");
    deco();
 
 
  }while (y != 8);
loop();
}
void deco(){

//  Serial.println(arr[1]);
  word ascii_value = arr[0] * 128 + arr[1] * 64 + arr[2] * 32 + arr[3] * 16 + arr[4] * 8 + arr[5] * 4 + arr[6] * 2 + arr[7] * 1;
 
  if (ascii_value == 32)
  {
    Serial.print(" ");
  }
  else
  {
    if (ascii_value >= 65 && ascii_value <= 90)      //for capital letters
    { int x = ascii_value - 65;                      // to take his position
      Serial.print(ascii_values[x]);                  //Its location  in ASCII  array values
    }
    else if (ascii_value >= 97 && ascii_value <= 122) //for lowercase letters
    {
      int x = ascii_value - 97;
      Serial.print(ascii_values[26 + x]);
    }
    else if (ascii_value >= 48 && ascii_value <= 57)  //for numbers
    {
      int x = ascii_value - 48;
      Serial.print(ascii_values[52 + x]);
    }
    else if (ascii_value >= 32 && ascii_value <= 38)  //for  !"#$%&
    {
      int x = ascii_value - 32;
      Serial.print(ascii_values[62 + x]);
    }
    else if (ascii_value >= 40 && ascii_value <= 47)  //for ()*+,-./
    {
      int x = ascii_value - 40;
      Serial.print(ascii_values[69 + x]);

} else if (ascii_value >= 58 && ascii_value <= 64) //for  :;<=>?@
    {
      int x = ascii_value - 58;
      Serial.print(ascii_values[77 + x]);
    }
    //Serial.println(ascii_value);//for test
    //Serial.print('\n');
  }
   
  }

"LDR" and "pulses" are not normally words I'd use in the same sentence (as I suspect you're now finding)

Here is a link to the device you mentioned, but again, depending on the length of pulses you're trying to measure, I imagine that I2C could well be a limiting factor for you.

Edit: Scrub the comment about I2C - the device appears to have an integration time of 100ms.

Thank you, sir
Sorry for my weak description of the problem
If you will, I want to shed a large number of light blinking on the optical receiver
The ldr " Light Dependent Resistor " can receive 10 times the amount of light and interruption, and after that I give it more than 10 it will not give me a valid reading of this.
I want to try the tsl 2591 devise but I don't know how to read from sdc sac

Tell us what sort of rate of data you're expecting.

The ldr " Light Dependent Resistor " can receive 10 times the amount of light and interruption, and after that I give it more than 10 it will not give me a valid reading of this.

I don't understand any of that.

I want to try the tsl 2591 devise but I don't know how to read from sdc sac

I suspect this device is a dead-end for the reasons above, but in case it isn't, it's an I2C device, and you'd read it using the Wire library.

To detect pulses of light, use a photodiode.

The circuit details will depend on what you are trying to do, so please describe your project clearly, with pulse timing information.

dear #jremington and #TheMemberFormerlyKnownAsAWOL
i need send stream of blink led like code below tx
and recieve data like rx
code tx

int LED = 13;
void setup() {
  
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1);                       // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1);                       // wait for a second
}

code rx

int light = 0; // store the current light value
boolean etat = false;   //Variable stockant l'état de la led
#define PAUSE 100  ;     //Pause entre chaque changement d'état de la led

void setup() {
    Serial.begin(9600); 
    
 }
void loop() {
  readSerial();
   
        
  
 void readSerial() {
  char val = Serial.read();
  Serial.print(val);}}
  
   if ( etat == false ) //Si l'état de la led est "faux" (led éteinte)
  { 
    Serial.print(0);    //On allume la led
                 //On attribue à etat la valeur true (allumée)
    delay(PAUSE);               //On attend PAUSE ms
  }
  else if ( etat == true ) //Sinon si l'état de la led est "vrai" (led allumée)
  {
    Serial.print(1);      //On éteint la led
           //On attribue la valeur false à etat
    delay(PAUSE);               //On attend PAUSE ms
  }

ldr can not capt more than 10 pulse of light i need use tsl 2591 i think is usefull

delay(1);                       // wait for a second

Nope.

Maybe this is part of your misunderstanding.

i need use tsl 2591 i think is usefull

With an integration time of around 100ms, I think I disagree.

TheMemberFormerlyKnownAsAWOL:
delay(1);                      // wait for a second Nope.

This means that I want to turn on the lamp and turn it off 1000 times per second. In contrast, my problem is that the sensor about me can only sense 10 times the light flashes.

TheMemberFormerlyKnownAsAWOL:

delay(1);                       // wait for a second

Nope.

Maybe this is part of your misunderstanding.
With an integration time of around 100ms, I think I disagree.

They wrote in datasheet "Clock frequency (I²C only)=400khz " Does this mean that its frequency is 1/400000 s?

The TX program flashes the light 500 times per second.

The RX program can't possibly work. Why and what are you reading from the serial monitor?

Post the RX code you are actually trying to use.

Yes, the maximum speed of the interface is 400 kHz.

But the integration time doesn't depend upon the interface speed, and appears the remain at around 100ms.

TheMemberFormerlyKnownAsAWOL:
Yes, the maximum speed of the interface is 400 kHz.

But the integration time doesn't depend upon the interface speed, and appears the remain at around 100ms.

i don't undrestand ,please can you tell me why interface speed around 100 ms?

jremington:
The TX program flashes the light 500 times per second.

The RX program can't possibly work. Why and what are you reading from the serial monitor?

Post the RX code you are actually trying to use.

jremington:
The TX program flashes the light 500 times per second.

The RX program can't possibly work. Why and what are you reading from the serial monitor?

Post the RX code you are actually trying to use.

At the moment i'm Txing data, just turning the LED ON for HIGH and OFF for LOW,
and reciever capt the data recieveng !

The RX program, as posted, does not even compile. So, IT DOES NOT WORK.

Post code that compiles.

jremington:
The RX program, as posted, does not even compile. So, IT DOES NOT WORK.

Post code that compiles.

sorry its for give an idea that what i would to explain to you ,
the code of reciever is on top haut

light__fidelity:
Dear researchers
I made a program to measure the pulses of light and used it for the ldr piece and I connected it to the A0 port but its frequency is very weak 10 Hz and this is why I bought the tsl 2590 but I did not know how to connect it because it has i2c and sda sca pin,I want to read data to me from one of the analog ports even Control their frequency
Here is a copy of a previous program that used ldr at a frequency of 10 Hz

what you need is a transceiver is a wider switching bandwidth.... as you discovered using and LED/LDR setup the maximum switching frequency(bandwidth) is quite small.

transceivers like these albeit for designed for fibre optics are what you are looking for...
https://uk.farnell.com/broadcom-limited/hfbr-1505cz/transmitter-fibre-optic-10mbd/dp/1247635?ost=HFBR-1505CZ
https://uk.farnell.com/broadcom-limited/hfbr-2505cz/receiver-fibre-optic-5mbd-sma/dp/1247661?ost=HFBR-2505CZ

hope that helps...

ps: it seem to me that you native language is french... maybe it would be easier for you to get the help you are looking for on the french board

light__fidelity:
i don't undrestand ,please can you tell me why interface speed around 100 ms?

Because the device has an integration time (effectively the time it takes to make a single measurement) of around 100ms.

sherzaad:
what you need is a transceiver is a wider switching bandwidth.... as you discovered using and LED/LDR setup the maximum switching frequency(bandwidth) is quite small.

transceivers like these albeit for designed for fibre optics are what you are looking for...
https://uk.farnell.com/broadcom-limited/hfbr-1505cz/transmitter-fibre-optic-10mbd/dp/1247635?ost=HFBR-1505CZ
https://uk.farnell.com/broadcom-limited/hfbr-2505cz/receiver-fibre-optic-5mbd-sma/dp/1247661?ost=HFBR-2505CZ

hope that helps...

ps: it seem to me that you native language is french... maybe it would be easier for you to get the help you are looking for on the french board

i think is usefull thank you , and what about sfp module ?

TheMemberFormerlyKnownAsAWOL:
Because the device has an integration time (effectively the time it takes to make a single measurement) of around 100ms.

oh yes thank you sure.

light__fidelity:
.... what about sfp module ?

not idea it they'll do the job for your project... up to you whether you want to try them or not.

good luck! :slight_smile: