光害測量 Sky Quality Meter

使用TSL237S-LF感測器

[材料]

1. Arduino UNO主板 x 1

2. TSL237S-LF 高敏感度光-頻率轉換器(high-sensitivity light-to-frequency converter) x 1

3. 電容0.1uF x 1

[TSL237S-LF 光-頻率轉換器 腳位]

由左至右

pin1 to arduino GND

pin2 to arduino 5V

pin3 to arduino pin2


/* Example: TSL237-LF

TSL237 Arduino pins

GND GND

Vcc +5V

Out Digital pin 2

Wire a 0.1uF capacitator between Vcc and GND close to the sensor

*/


// Pin definitions

# define TSL237 2 // Out of TSL237 connected to Digital pin 2


// Constants

int period = 1000; // Miliseconds of each light frecuency measurement

int ScalingFactor = 0.1; // Scaling factor of this sensor

float area = 0.0092; // Sensing area of TSL237 device (cm2)

float millsec01,millsec02;

// Variables

unsigned long counter = 0; // Counter of measurements during the test

unsigned long currentTime = millis();

unsigned long startTime = currentTime;

volatile long pulses = 0; // Counter of measurements of the TSL237

unsigned long frequency; // Read the frequency from the digital pin (pulses/second)

float irradiance; // Calculated irradiance (uW/cm2)



void setup() {

Serial.begin(9600); // Start and configure the serial port

attachInterrupt(0, PulseCount, RISING);

pinMode(TSL237, INPUT); // Declare the pin such as an input of data

Serial.println("Testing a TSL237 sensor:"); // Splash screen

Serial.println("-------------------------");

Serial.println();

}


void loop(){

millsec01=millis();

getfrequency(); // Request to measure the frequency

getirradiance(); // Request to calculate the irradiance (uW/cm2)

Serial.print(" ");

Serial.print(irradiance); // print the frequency (pulses/second)

Serial.println(" uW/cm2");

pulses = 0; // reset the pulses counter

millsec02=millis();

delay (2000);

}



void PulseCount()

{

pulses++;

}


unsigned long getfrequency () {

noInterrupts();

frequency = pulses /((millsec01- millsec02)/1000); // Calculate the frequency (pulses/second)

interrupts();

return (frequency);

}


float getirradiance () {

irradiance = frequency / area; // Calculate Irradiance (uW/cm2)

return (irradiance);

}


[實驗步驟]

1. 數值最大可達到多少?