TEMT6000 light sensor voltage divider readout Vs. photoresistor voltage divider

hi, I'm not sure why my temt6000 light sensor is getting a readout from my multimeter over 3.3 volts when I expose it to more lighting (in this case my cell phone led).

My photoresistor setup with two photoresistors in series has an analog out in between them.
At the end of the circuits, I have 10kohm resistors.

The temt6000 circuit has a 10kohm resistor attached to it.
I've also hooked these up in series.

The photos below show where I measure my voltage.
Did I mess up somewhere or is this just the due to the specifications of the phototransistor?
temt6000 spec sheet

both photos are attached below:

voltage divider photoresistors post #6, half input voltage

I reached the attachment limit here is the photoresistor setup:

You are aware that the voltage derived from Vin on an ESP32, powered via the USB interface, is 5 volts.
If that does not explain your problem, then maybe draw a full schematic. You seem to have a partial one on the right hand margin of the picture in your opening post.

I wasn't sure. I found some links online saying Vin can be supplied with 6-20 volts, recommended 7-12 volts.

What's unclear is that I couldn't find anything online regarding if I can use one of the pins as an outlet, other than this post.:

I measured the voltage at the Vin pin and gnd pin when plugged into a USB outlet and it read 4.65 volts.

See post #16 and #17.
https://forum.arduino.cc/index.php?topic=606908.msg4121171#msg4121171

What doesn't make sense to me is that with my photoresistor setup I was getting voltage values that were within the 0-3.3 V range.
As for my readings after making a schematic below I realized I need to reverse a couple of the sensors in terms of wiring. I think that's why I was getting weird readings.
This may be giving me weird voltage values too.

Your schematic shows phototransistors but the picture in post #1 shows light dependent resistors.
How are you powering the circuit? Through the USB?
If you are powering it through the usb, then you could easily see more than 3.3v at, say, the point on your schematic marked “pin 34 signal” when the top device is saturated with light and the bottom device is dark. In this case you would effectively have a potential divider across 5 volts with the top side of 10k ohm and the bottom side of, say, 10M ohm.

I am getting a .4 volt readout now with full light applied via a flash light.
Almost 0 volts with no light.

Here is the revised circuit to match the photoresistors.

I'm wondering if it has to do with my voltage attentuation, I read something about the adc pins running at 1.1v aref but i don't think I changed any of the settings in the program to do that.

Here is the corrected schematic and I believe I did wire things correctly to match it:

I am powering it currently via my usb port from laptop.
There is definitely a difference in readouts with same light conditions for photoresistors vs phototransistors.

If you don't want to exceed 3.3 volts at either the point marked Pin34 Azimuth or the point marked pin 35 elevation, then simply power that circuit at 3.3volts. The label "Vin or Vcc" is a bit vague.

Ok. I'm using the Vin pin of the esp32 to power the circuit but I can use a 3.3volt power supply easily. In this case is it possible to power that supply with the esp32 and if so through which pins?

I will eventually use a solar panel to power the esp32 but will use a 3.3volt converter.

Is there any advantages for using 0 dB attenuation or 1.1 v aref?

Hi All,
I suggest that you simplify your experiment and
use only one light sensor module. You do not need
two in series: that only makes it difficult to interpret
the voltage you are reading because of unequal lighting
between the sensors. That module has what
you need: a light to current converter (photo transistor)
and a current to voltage converter (resistor) in one
package. It is always best to start with the bare minimum
of hardware and learn from that what you need to know
before moving of to more complex circuits.
Herb

So I've powered the remainder of the circuit with a separate 3.3 volt regulator.
Anyone interested in the cad model can download it here:

I've used it in my other projects before and it has worked out well.
I was able to power the reguator with the Vin pin of the ESP32.
I've measured the Vout and it's ~3.27 volts.

Thanks to 6v6gt for helping complete the original code.
I've modified the program in the post here to print only one variable (the azimuth variable):
TEMT6000 smoothing values on ESP32 ADC for ESP-Now

I figured I would get correct readings but something is off.
When I light up the right half of the circuit I get a serial readout with values.
When I light up the left half of the circuit the serial readout is zero.

Here is the code. Free and open source. CC BY 4.0:

//Free and open source. CC BY 4.0

#include <driver/adc.h>

// Define the number of samples to keep track of. The higher the number, the
// more the readings will be smoothed, but the slower the output will respond to
// the input. Using a constant rather than a normal variable lets us use this
// value to determine the size of the readings array.
const int numReadings = 64;
const int numSensors = 1;

uint32_t readings[numSensors][numReadings];   //multi-dimensional readings from analog input
uint32_t total[numSensors] = {0};    // the running total
uint32_t readIndex = 0;              // the index of the current reading
uint32_t average = 0;                // the average
uint16_t EspNowAverage = 0;          // 0-255 value average

// delay to process smoothing readings
uint16_t numReadingsInterval = 1;
uint32_t lastEventAtMs = 0 ;

void setup() {
  Serial.begin(115200);
  // initialize all the readings to 0:
  for (uint16_t thisReading = 0; thisReading < numReadings; thisReading++) {
    for ( int j = 0; j < numSensors; j++)  readings[j][thisReading] = 0;
  }
}

void loop() {

  //Voltage divider analog in pins
  // https://dl.espressif.com/doc/esp-idf/latest/api-reference/peripherals/adc.html
  // set up A:D channels

  adc1_config_width(ADC_WIDTH_12Bit);
  adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_11); //Pin34

  adc1_config_width(ADC_WIDTH_12Bit);
  adc1_config_channel_atten(ADC1_CHANNEL_7, ADC_ATTEN_DB_11); //Pin35

  // millis() -->Returns the number of milliseconds passed since the Arduino board began running the current program.
  // This number will overflow (go back to zero), after approximately 50 days.
  // timing resets to 0 when millis() - lastEventAtMS becomes greater than or equal to numReadingsInterval
  // then loop proceeds with remaining functions
  if ( millis() - lastEventAtMs >= numReadingsInterval ) {

    lastEventAtMs = millis();

    // Read the sensor
    uint16_t Azimuth = adc1_get_raw(ADC1_CHANNEL_6);
    uint16_t Elevation = adc1_get_raw(ADC1_CHANNEL_7);

    uint16_t  inputPin[ numSensors ] = {Azimuth};

    uint16_t ai;

    for (ai = 0; ai < numSensors ; ai++) {
      // subtract the last reading:
      total[ ai ] = total[ ai ] - readings[ai][readIndex];
      // read from the sensor:
      readings[ai][readIndex] = inputPin[ai];
      // add the reading to the total:
      total[ai] = total[ai] + readings[ai][readIndex];

      // calculate the average:
      average = total[ai] / numReadings;

      // reduce results to 0-255
      EspNowAverage = average/16;
      Serial.print( "EspNowAverage sensor: ");
      Serial.print( ai );
      Serial.print( "   " );
      Serial.println(EspNowAverage);  //
    }

    // advance to the next position in the array:
    readIndex = readIndex + 1;
    // if we're at the end of the array...
    if (readIndex >= numReadings) {
      // ...wrap around to the beginning:
      readIndex = 0;
    }
  }
}

Here is the serial readout (right side with light, voltage readout of 2.2 volts,
half of 3.3 volts is 1.65 volts --> a difference of .55 volts from the midpoint --> .55volts/3.3 volts equals .167 --> .167 * 255 (0-255 adc range) = ~42.5
the left half was covered up with a finger.):

EspNowAverage sensor: 
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42
EspNowAverage sensor: 0   42

Now when I cover the right half and light up the left half, the serial read out is 0 and the voltage readout is ~.01 volts.

EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0
EspNowAverage sensor: 0   0

I don't get it. My circuit setup seems correct and matches the photoresistor setup I had, except now I'm using phototransistors. I take multimeter readings at the ground of the ESP32, and at V location (right sensor) and for the left sensor (S location, or signal out).

Here are the specs of the phototransistor:

Maybe it's a silly question, but is a phototransistor not capable of working as a voltage divider? Since with a voltage divider there are two resistors and the readout is between them?

I was wondering what you were doing. You seem to have configured your 4 photo transistors as a pair of 2 input logical AND gates. It will not work in the same way as the network of LDRs that you had previously.

I guess what you want is this:
If the light falling on both devices is exactly the same, the voltage at the mid point is exactly half of Vcc.
Otherwise the voltage at the mid point is half of Vcc plus some function of the difference between the light levels falling on each transistor.

You can do this easily in code if each photo transistor can have its own analog input. It is essentially then a subtraction of the analog values (signed integer)

Hi,
It looks like you are trying to measure differential values in azimuth and elevation.
Can I suggest you place a divider up between the sensors so you have some sort of shadow to make your readings different.

Tom.. :slight_smile:

Hi,
Those purple modules, can you post link to where you got them and data please?

Tom.. :slight_smile:

I will definetely make a divider as I have in the past for my other setups.
I have previously used 4 analog inputs for other setups. Someone’s suggestion said to use a voltage divider setup and reorient the sensors. This setup allowed for 2 analog inputs versus 4 and liked the idea. It also means less data for me to send between two esp32s via esp now protocol.

Thanks for the feedback now I know more about phototransistors.

I found these and they seem to be ldrs. They are rohs compliant so they are environmentally friendly.

https://www.electrodragon.com/product/2pcs-5mm-5800b-environment-friendly-photosensitive-led-photocell/

I will use these for next setup, unless anyone thinks they are not what they claim to be.

Hi please checkout post number 4 in url below for links to goodies:
https://forum.arduino.cc/index.php?topic=606908.msg4121171#msg4121171
Spec sheet in post 12 below.

I will upload cad models of them when I get a chance unless they are already online on grabcad.com. I have a bunch of great electrical components cad models I like to use for Arduino, etc at:
Grabcad.com/has-2

For inspiration the guy with the original idea:

If you are in the mood to experiment, you could try something like this with your phototransistors to save analog pins. The results may not be very linear, though.

Hi,
I think this is the connections you need to get any sense out of the array.
Because you have it in a differential configuration, you do not use the S (signal) terminals.
The connection of the upper sensor G to the lower V is now the new signal point.

Tom.. :slight_smile:

I'll try both the methods below.

I had that setup mentioned in the last post initially, although I don't think I measured my voltages from the points you mentioned.