ESP32S with S9706

Hello all,

recently i am using a S9706 colorsensor with my ESP32S3-DevkitC-1-N8R2.
When i only use one sensor, it's working perfectly. But when i try to read more than one sensor using the same CLK, GATE and RANGE lines for both sensors i get unreasonable data.

I searched on the net for sometime but i couldn't get any infos about this sensor.
So please, if someone has experince with such sensors can tell me if i have a change or should search for other sensors.

Thanks in forward.

There's a datasheet here:

It gives a link to the manufacturer's documentation page:

Show how you have them connected.

It doesn't look to me that these are intended for connecting in a "bus" configuration with multiple devices?

It looks like you will, at least, need a separate data line per sensor?

Thank you for the answer.

I have already a separate data line for each sensor but they still deliver unreasonable data.

Again, show your schematic.

Also post your code.

See: How to get the best out of this forum; in particular, Posting code and common code problems and Schematics or circuit diagrams


This is how i have them connected

And here is my code:


#include <S9706.h>

// Defining the pins needed for the color sensor
const int DataPin1  = 21;
const int DataPin2  = 36;              
const int RangePin = 38;
const int ClockPin = 39;
const int GatePin  = 40;

// Instance for RGB color sensor
S9706 colorsensor1(DataPin1, RangePin, ClockPin, GatePin);
S9706 colorsensor2(DataPin2, RangePin, ClockPin, GatePin);

// Some float variables to store the color infos
uint8_t f_r1, f_g1, f_b1;
uint8_t f_r2, f_g2, f_b2;

void setup() {
  Serial.begin(115200);
  
  colorsensor1.begin();
  colorsensor2.begin();
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

  // read the color sensors
  colorsensor1.update(S9706_MODE_HIGH, 100);
  f_r1 = colorsensor1.getRed(); 
  f_g1 = colorsensor1.getGreen();
  f_b1 = colorsensor1.getBlue();
  delay(100);
  
  colorsensor2.update(S9706_MODE_HIGH, 100);
  f_r2 = colorsensor2.getRed(); 
  f_g2 = colorsensor2.getGreen();
  f_b2 = colorsensor2.getBlue();
  delay(100);
  
  Serial.print("red1: ");                      
  Serial.print(f_r1);
  Serial.print(" green1: ");
  Serial.print(f_g1);
  Serial.print(" blue1: ");
  Serial.println(f_b1);

  Serial.print("red2: ");   
  Serial.print(f_r2);
  Serial.print(" green2: ");
  Serial.print(f_g2);
  Serial.print(" blue2: ");
  Serial.println(f_b2);
}

What's the purpose of the optoisolators?

Does it work without them?

Does each sensor individually work via its own isolator, with no other sensors present?

I think the problem is with the optoisolator.
Without the opto it looks like i am getting some good data.

What was the intention of opto-isolating just the data lines?

I thought i may isolate the sensors from the microcontroller