Light Sensors

 General audience classification icon  General audience classification icon

Photoresistor

A photoresistor is a sensor that perceives light waves from the environment. The resistance of the photoresistor is changing depending on the intensity of light. The higher the intensity of the light, the lower the sensor's resistance. A light level is determined by applying a constant voltage through the resistor to the sensor, forming a voltage divider, and measuring the resulting voltage. Photoresistors are cheap, but the resistance is influenced by temperature and changes slowly, so they are used in applications where speed and accuracy are not crucial.
Photoresistors are often utilised in energy-effective street lighting control.
A symbol, sample photoresistor, and connection circuit are present in figures 1, 2 and 3.

 Photoresistor symbol
Figure 1: A photoresistor symbol
 Photoresistor
Figure 2: A photoresistor
 Arduino and photoresistor sensor schematics
Figure 3: Arduino and photoresistor sensor schematics

As shown in the figure 3, the photoresistor connected gives a lower voltage level while the light is more intense. Results can be read with the following example code. The value will be just a number not expressed in any units, e.g. Lux. To express light intensity in Luxes, additional calculations must be encoded in the program.

//Define an analog A0 pin for photoresistor
int photoresistorPin = A0; 
//The analogue reading from the photoresistor 
int photoresistorReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialise the analogue pin of a photoresistor as an input
    pinMode(photoresistorPin, INPUT); 
}
 
void loop()
{
    //Read the value of the photoresistor
    photoresistorReading = analogRead(photoresistorPin); 
    //Print out the value of the photoresistor reading to the serial monitor
    Serial.println(photoresistorReading); 
    delay(10); //Short delay
}
Photodiode

A photodiode is a sensor that converts light energy into electrical current. A current in the sensor is generated by exposing a p-n junction of a semiconductor to the light. Information about the light intensity can be determined by measuring a voltage level. Photodiodes react to changes in light intensity very quickly, so they can be used as receivers of light-based data transmission systems (e.g. fibre data communication). Solar cells are just large photodiodes. A symbol, sample photodiode and connection circuit are present in figures 4, 5 and 6.
Photodiodes are used as precise light-level sensors, receivers for remote control, electrical isolators (optocouplers), and proximity detectors.

 Photodiode symbol
Figure 4: A photodiode symbol
 Photodiode
Figure 5: A photodiode
 Arduino and photodiode sensor schematics
Figure 6: Arduino and photodiode sensor schematics

Although the photodiode can generate current, the schematic in figure 6 shows its connection similar to the photoresistor in the previous example. In such a circuit, the photodiode changes its current according to a change in light intensity, resulting in the voltage change at the microcontroller's analogue input. As in the example for a photoresistor, the higher the light intensity, the lower the voltage. An example code:

//Define an analog A0 pin for photodiode
int photodiodePin = A0;  
//The analogue reading from the photodiode
int photodiodeReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialise the analogue pin of a photodiode as an input
    pinMode(photodiodePin, INPUT); 
}
 
void loop()
{
    //Read the value of the photodiode
    photodiodeReading = analogRead(photodiodePin); 
    //Print out the value of the photodiode reading to the serial monitor
    Serial.println(photodiodeReading); 
    delay(10); //Short delay
}
Phototransistor

The phototransistor is a typical bipolar transistor with a transparent enclosure that exposes the base-emitter junction to light. In a bipolar transistor, the current that passes through the collector and emitter depends on the base current. In the phototransistor, the collector-emitter current is controlled with light. A phototransistor is slower than a photodiode but can conduct more current; additionally, it amplifies the incoming signal. In specific conditions, if the light is completely off or intense enough to make the output current maximal, a phototransistor can be considered a light-controlled electronic switch (e.g. in optocouplers, which are usually connected to digital inputs of the microcontroller and provide physical separation between devices).
Phototransistors are used as optical switches, proximity sensors and electrical isolators.
A symbol, sample phototransistor device, and circuit are present in figures 7, 8 and 9.

 Phototransistor symbol
Figure 7: A phototransistor symbol
 Phototransistor
Figure 8: An phototransistor
 Arduino and phototransistor schematics
Figure 9: Arduino and phototransistor schematics

An example code:

//Define an analog A1 pin for phototransistor
int phototransistorPin = A1;  
//The analogue reading from the phototransistor
int phototransistorReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialise the analogue pin of a phototransistor as an input
    pinMode(phototransistorPin, INPUT); 
}
 
void loop()
{
    //Read the value of the phototransistor
    phototransistorReading = analogRead(phototransistorPin); 
    //Print out the value of the phototransistor reading to the serial monitor
    Serial.println(phototransistorReading); 
    delay(10); //short delay
}
en/iot-open/hardware2/sensors_light.txt · Last modified: 2023/11/23 10:37 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0