Using a TEMT6000 Phototransistor Ambient Light Sensor with Arduino
In this tutorial, we will explore how to use the TEMT6000 ambient light sensor with an Arduino. This sensor allows us to measure the intensity of ambient light and can be used in various applications, such as adjusting screen brightness based on lighting conditions. By the end of this guide, you will have a working example that reads light levels and displays them on the serial monitor.

The TEMT6000 sensor operates as a phototransistor, outputting a voltage that corresponds to the amount of light it detects. This voltage can be easily read by the Arduino's analog input pins, allowing us to convert it into meaningful readings in millivolts or volts. You can watch the video for a detailed walkthrough of the code and wiring (in video at 00:00).
Hardware Explained
The main components for this project include the TEMT6000 sensor and the Arduino board. The TEMT6000 is a small and efficient ambient light sensor that uses a phototransistor to detect light levels. It has three pins: V (voltage), G (ground), and S (signal). The signal pin outputs a voltage that varies with light intensity, which the Arduino reads through its analog input.
The Arduino serves as the microcontroller that reads the output from the TEMT6000 sensor. It processes this data and can be programmed to perform actions based on the light levels detected. This makes the sensor suitable for various applications, from simple light detection to more complex systems like automatic lighting adjustments in smart devices.
Datasheet Details
| Manufacturer | Vishay |
|---|---|
| Part number | TEMT6000 |
| Logic/IO voltage | 3.0 – 5.5 V |
| Supply voltage | 5 V |
| Output current | 20 mA max |
| Peak sensitivity | 570 nm |
| Power dissipation | 100 mW |
| Junction temperature | 100 °C |
| Package | 4 x 2 x 1.05 mm |
| Notes / variants | NPN phototransistor |
- Ensure the sensor is powered with a stable 5V supply.
- Use a 10kΩ resistor to connect the signal pin to ground for proper operation.
- Keep the sensor away from direct sunlight to avoid saturation.
- Consider heat-sinking if used in high-temperature environments.
- Check for proper wiring to avoid floating inputs.
- Calibrate readings for specific applications as necessary.
Wiring Instructions


To wire the TEMT6000 sensor to the Arduino, start by connecting the V pin of the sensor to the 5V pin on the Arduino. Next, connect the G pin of the sensor to one of the GND pins on the Arduino for the ground connection. Finally, connect the S pin, which is the signal pin, to the analog input pin A0 on the Arduino. This setup will allow the Arduino to read the voltage output from the sensor based on the ambient light levels.
It's important to ensure that all connections are secure to prevent any loose wiring, which can lead to inaccurate readings. If you are using a breadboard, double-check the connections to ensure that the sensor is correctly wired to the Arduino as described.
Code Examples & Walkthrough
In the code, we begin by defining the input pin for the light sensor using #define light A0. This sets up the Arduino to read the signal from the TEMT6000 sensor connected to pin A0.
#define light A0 // define input pin
void setup() {
Serial.begin(9600);
}
In the setup() function, we initialize the serial communication at a baud rate of 9600, which allows us to send data to the serial monitor.
In the loop() function, we read the light level using analogRead(light) and then map that value to millivolts:
void loop() {
int Lvalue = analogRead(light); // read the light
int mVolt = map(Lvalue, 0, 1023, 0, 5000); // map analogue reading to 5000mV
float volt = (double)mVolt / 1000; // convert millivolt to volt
This code takes the raw analog reading, maps it to a range of 0 to 5000 millivolts, and then converts it to volts for easier interpretation. This is crucial for understanding the light levels detected by the sensor.
Finally, we print the values to the serial monitor:
Serial.print(mVolt); // print millivolt
Serial.print("mV ");
Serial.print(volt, 3); // print volts with 3 decimal places
Serial.println("V ");
delay(1000); // wait for 1000 milliseconds
}
This section of the code displays the millivolt and volt readings on the serial monitor every second. This allows you to see how the light levels change in real-time as you cover or expose the sensor to light.
Demonstration / What to Expect
Once the wiring is complete and the code is uploaded to the Arduino, you should see readings of the light levels in millivolts and volts on the serial monitor. For example, in bright light, you may see values around 2500 mV, while in darkness, values could drop significantly (as low as 2000 mV). If you cover the sensor or turn off the lights, the readings should reflect these changes almost instantly, demonstrating the sensor's responsiveness (in video at 02:30).
الأشياء التي قد تحتاجها
-
أمازون
الموارد والمراجع
-
خارجيتحميل ورقة بيانات TEMT6000vishay.com
ملفات📁
لا توجد ملفات متاحة.