TEMT6000X01 flex sensor with an Arduino Uno and an OLED showing a relative light reading of 50%.

Display Ambient Light on an OLED with the TEMT6000X01 and Arduino Uno

Build a small light meter with the PlantMate TEMT6000X01 flex PCB, an Arduino Uno R3 and a 0.91-inch OLED. Cover the sensor with your hand and the bar shrinks. Uncover it or point a lamp at it and the bar grows. The display shows a relative light level from 0% to 100%.

What you’ll need

  • One sensor and matching 4-pin, 1.0 mm FFC/FPC adapter from the TEMT6000X01 Flex Light Sensor Kit (5-Pack).
  • Arduino Uno R3 and a USB data cable.
  • A four-pin, 128×32 SSD1306 I²C OLED that supports a 5 V supply and 5 V I²C logic. The PlantMate 0.91-inch OLED works for this wiring.
  • One 10 kΩ resistor, a breadboard, jumper wires and a soldered pin header or leads for the adapter.

1. Identify the flex pins

Disconnect USB power. Look at the flex with the exposed gold contacts facing you, the sensor at the left and the tail at the right. Pin 1 is the top contact and pin 4 is the bottom contact. Fully seat the reinforced tail in the adapter and close the latch. The dual-contact socket can accept the tail face up or down, so locate the two breakout connections by following the traces or checking continuity with the power disconnected.

Flex PCB with exposed contacts up. Pin 1 is OUT to A0, pins 2 and 3 are unconnected, and pin 4 goes to 3.3 V.
With the contacts facing up and the sensor on the left, count the tail contacts from top to bottom.

2. Wire the sensor and OLED

Connect flex pin 4 (3V3, collector) to the Uno’s 3.3 V pin. Connect flex pin 1 (OUT, emitter) to A0 and add an external 10 kΩ pull-down from that A0 junction to GND. Leave flex pins 2 and 3 unconnected. Power the compatible OLED from the Uno’s separate 5V pin and connect both circuits to the same ground.

ConnectionArduino Uno R3
Flex pin 1 (OUT, emitter)A0 at the 10 kΩ resistor junction
Flex pins 2 and 3 (NC)Leave unconnected
Flex pin 4 (3V3, collector)3.3 V
10 kΩ pull-down resistorBetween A0 and GND
OLED VCC5V
OLED GNDGND
OLED SDAA4 / SDA
OLED SCLA5 / SCL
Flex pin 1 connects to A0 and a 10 kΩ pull-down to ground. Flex pin 4 connects to 3.3 V. The 5 V OLED uses A4 for SDA and A5 for SCL.
Pin 1 and A0 share the 10 kΩ pull-down to ground. Pin 4 goes to the Uno’s 3.3 V pin. Use a common ground for the sensor circuit and OLED.

Match the OLED’s printed pin labels. The flex uses two contacts for the analog circuit, while the OLED uses the Uno’s I²C pins. The Arduino Uno R3 pinout shows both sets of pins.

3. Install the libraries and upload the sketch

  1. In Arduino IDE, select Arduino Uno under Tools → Board → Arduino AVR Boards and select the port for the board.
  2. In Library Manager, install Adafruit SSD1306 and Adafruit GFX Library. Install Adafruit BusIO if prompted.
  3. Copy the sketch below into a new sketch, then click Upload. Open Serial Monitor at 115200 baud to see the averaged A0 reading and the same light percentage shown on the OLED.
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// Flex pin 1 (OUT) to A0, with a 10 kOhm pull-down from A0 to GND.
// Flex pin 4 (3V3) to 3.3V. Leave flex pins 2 and 3 open.
// 5V-compatible OLED: SDA to A4, SCL to A5, VCC to 5V, GND to GND.
constexpr uint8_t kSensorPin = A0;
constexpr uint8_t kOledAddress = 0x3C;
constexpr uint8_t kSampleCount = 16;
constexpr uint16_t kLightFullScaleAdc = 675;  // Approx. 1023 * 3.3 / 5.0.
constexpr uint8_t kBarWidth = 122;

Adafruit_SSD1306 oled(128, 32, &Wire, -1);
bool oledReady = false;

void setup() {
  Serial.begin(115200);
  Wire.begin();

  Wire.beginTransmission(kOledAddress);
  oledReady = Wire.endTransmission() == 0 &&
              oled.begin(SSD1306_SWITCHCAPVCC, kOledAddress);
  if (oledReady) {
    oled.setTextSize(1);
    oled.setTextColor(SSD1306_WHITE);
  } else {
    Serial.println(F("OLED unavailable. Check the wiring and I2C address."));
  }
}

void loop() {
  uint16_t sum = 0;
  for (uint8_t i = 0; i < kSampleCount; ++i) {
    sum += analogRead(kSensorPin);
    delay(2);
  }

  const uint16_t lightAdc = (sum + kSampleCount / 2) / kSampleCount;
  const uint16_t boundedAdc = min(lightAdc, kLightFullScaleAdc);
  const uint8_t lightPercent = (100UL * boundedAdc + kLightFullScaleAdc / 2) / kLightFullScaleAdc;
  Serial.print(F("A0 average: "));
  Serial.print(lightAdc);
  Serial.print(F("  Light: "));
  Serial.print(lightPercent);
  Serial.println('%');

  if (oledReady) {
    const uint8_t fillWidth = uint16_t(lightPercent) * (kBarWidth - 2) / 100;
    oled.clearDisplay();
    oled.setCursor(3, 4);
    oled.print(F("Light "));
    oled.print(lightPercent);
    oled.print('%');
    oled.drawRect(3, 17, kBarWidth, 12, SSD1306_WHITE);
    oled.fillRect(4, 18, fillWidth, 10, SSD1306_WHITE);
    oled.display();
  }

  delay(200);
}

4. Try the light meter

Compare the reading in room light, with the sensor shaded, and with a lamp pointed toward it. More light increases the current through the 10 kΩ resistor and raises the voltage at A0. With the Uno’s default 5 V ADC reference, the 3.3 V sensor supply corresponds to about 675 of the 1023 ADC counts. The sketch maps an averaged reading of 0 to 675 to a relative 0% to 100% and caps higher readings at 100%. The percentage reflects the circuit’s output. Measuring lux requires calibration.

The OLED shows a relative light reading of 50% with a half-filled bar.
An example relative light reading of 50%. The number and bar change as the light changes.

If the reading or display looks wrong

  • OLED stays blank. Check VCC, GND, SDA on A4 and SCL on A5. Confirm the module’s I²C address. Use 0x3D in the sketch if a scan finds the OLED at that address.
  • Light stays near zero in every condition. Verify the adapter orientation, 3.3 V at pin 4, and continuity from pin 1 to A0. Measure the 10 kΩ path from A0 to GND with power disconnected. An open sensor connection or a direct short from A0 to ground can leave the reading near zero.
  • Light stays high when shaded. Check that A0 is connected to pin 1 and through the 10 kΩ resistor to ground. Also check for a short from A0 to 3.3 V or 5 V.

For the sensor’s electrical characteristics, see the Vishay TEMT6000X01 datasheet. If you want to fit the flex into a case, the sensor PCB STEP model is available separately.

All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *