Arduino Astronomy Python Uncategorized

Building an inexpensive lux meter for the observatory…

As part of an environmental monitoring system for an observatory, I wanted to include a measure of ambient light. Ostensibly, this is for safety reasons. However, I must admit that I really just want to see if I can (coarsely) measure sky brightness.

There are a number of inexpensive light sensors available from AliExpress/Amazon. The two that I show here are based on the TEMT6000 sensor and the LM393 voltage comparator. Both cost less than $1.50.

Hooking up the sensors is really quite straightforward. Connect the GND pin to GND, the VCC pin to 3.3V, and the A0/S pin to analog pin 0. You’re done.

A simple Arduino test script would look like…

const int numReadings = 10;
int reading;
int total = 0;
int average = 0;

int lightPin = 0;
float lux;

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (int i = 0; i < numReadings; i++){
    reading = analogRead(lightPin);
    total = total + reading;
    Serial.println(total);
    delay(100);
  }
  average = total / numReadings;
  total = 0;
  lux = pow(10,6.6162) * pow(average,-1.9191);
  Serial.print("Reading: "); Serial.print(average);
  Serial.print(" ==> "); Serial.print(lux); Serial.println(" lux");
  delay(1000);        // delay in between reads for stability
}

 

Upload the sketch to your Arduino and open up a serial monitor. You should see values from 0 to 1023. If you’ve got a TEMT6000 hooked up the numbers will increase with light levels while an LM393-based device will show readings that decrease with light levels.

At first glance, it looks like the TEMT6000 does not have sufficient sensitivity/resolution at low light levels, so it looks like the LM393 will be used for observatory monitoring.

The values coming out of the sensor give a relative measure of ambient light. But, what we’d really like is an absolute measure of light levels measured in lux. The best way to do this is to measure sensor readings at a number of different known light levels. To get the ‘known’ light levels, you can use a light meter that measures in lux. These are available cheaply (although you get what you pay for) from AliExpress and are likely to be much better than just ‘winging’ it. To calibrate…

  1. Setup in a room that you can adjust the lighting from low/dark to bright.
  2. Take measurements measurements from both the lux meter and your Arduino light meter at, say, 10 intervals from dark to full brightness. You could tape the LM393 to the side of the light meter so that they’re both ‘looking’ in roughly the same direction.
  3. Move outside and take more measurements. Sample in shady spots, bright spots, and full-on sun if you can.
  4. Plot your measurements as known (lux meter) vs measured (Arduino) as a log-log plot.
  5. Find a best-fit line to your log-log plot in the form, y = m * x+ b, where y is the known level, x is the measured level, and m & b are the slope & intercept of the best-fit line
  6. Your transformation from measured to known is, lux = xm*10b

For my sensor, the transformation equation works out to be lux = reading-1.9191x106.6162

What’s next? Well, now that we have the basics of the lux meter, it can be incorporated into other projects.