Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

DIY Sky Quality Meter


Corpze

Recommended Posts

Hi!

I have made a new verison of the Sky Quality Meter i made several years ago. It is the same components but som new, simpler code.

It consists of a;

- Arduino UNO
- LCD Shield or a singel LCD Display (16x2 char.)
- Momentary push button
- TSL237 light-to-frequency-sensor
- 20 degree lens (cheap plastic ebay LED lens)
- Project box
- Some jumper cables.

The connections is as follows:

Pushbutton is connected to GND and input A2
The TSL 237 Needs 3V+, GND and is connected to input 8
The LCD is connected to 5V+ and GND and is connected to input 13, 12, 5, 4, 3, 2 (This will be obvious when you see the LCD display) OR - you can use a LCD Shield which just stacks on top of the arduino.

The code is posted below the video



The code:

#include <FreqMeasure.h>
#include <Math.h>
#include <LiquidCrystal.h>

float Msqm;
const float A = 19.0;
int buttonSQM = A2; 
int val = 0;
int reading = 0;
int percentage = 0;
LiquidCrystal lcd (13, 12, 5, 4, 3, 2);

void setup() {
   
   pinMode(buttonSQM, INPUT_PULLUP);
   digitalWrite(buttonSQM, HIGH);
   lcd.begin(16,2);
   Serial.begin(9600);
}

double sum=0;
int count=0;

void loop() {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("EXO PHOTOGRAPHY");
            lcd.setCursor(0,1);
            lcd.print("   SQM-METER");
            //delay (3000);
           // lcd.clear();
           // lcd.setCursor(0,0);
           // lcd.print("PRESS BUTTON TO");
           // lcd.setCursor(0,1);
           // lcd.print("  TAKE READING  ");
           // delay (3000);
  
    if ((Serial.readString() == "MySQM") or (digitalRead(buttonSQM) == LOW)) {
   
      reading = 1;
      FreqMeasure.begin();      
      while(reading) {
                 
         if (FreqMeasure.available()) {
            // average several reading together
            sum = sum + FreqMeasure.read();
            count +=1;
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Reading");
            lcd.setCursor(8,0);
            lcd.print(percentage);
            lcd.setCursor(11,0);
            lcd.print("%");
            
            percentage = count/31.0*100.0;

    //        Serial.print("Counts: ");
    //        Serial.print(count); 
    //        Serial.print(" Progress: ");           
    //        Serial.print(percentage);
    //        Serial.println("%");
              
            
            
            if (count > 30) {
               double frequency = F_CPU / (sum / count);
               sum = 0;
               count = 0;
               
               Msqm = A - 2.5*log10(frequency); //Frequency to magnitudes/arcSecond2 formula
                
               lcd.clear();
               lcd.setCursor(0,0);
               lcd.println("Mag/As2: ");
               lcd.setCursor(9,0);
               lcd.print(Msqm);
               
               Serial.print("Mag/As2: ");
               Serial.println(Msqm);
               delay(10000);
               lcd.clear();
               reading = 0; 
               FreqMeasure.end();
            }
         }
      }
   }
}






Best regards / Daniel

Edited by Corpze
Added connections.
  • Like 9
Link to comment
Share on other sites

17 hours ago, sloz1664 said:

Hi Daniel,

Great project, as always. I have the components and now the code. But, I'm missing the pin layout and wiring diagrams. Any chance of up loading?

Steve

My fault, forgot that...

I Have updated the first post with all correct inputs and connections, I have how ever not any wiring diagram, but there is no problem wiring this up, especially if you use a LCD shield instead of a single LCD.

/Daniel

Link to comment
Share on other sites

2 hours ago, Corpze said:

My fault, forgot that...

I Have updated the first post with all correct inputs and connections, I have how ever not any wiring diagram, but there is no problem wiring this up, especially if you use a LCD shield instead of a single LCD.

/Daniel

Thanks Daniel, much appreciated :)

Steve

Link to comment
Share on other sites

Hello Daniel,

Thank you very much for sharing your work. Do you think that I could use a 15º or 25º instead od the 20º that you recommend? The reason for this is because I live in Portugal and can't source the 20º version.

Thanks in advance for your advice.

Regards,
Carlos

Link to comment
Share on other sites

11 hours ago, uforias said:

Hello Daniel,

Thank you very much for sharing your work. Do you think that I could use a 15º or 25º instead od the 20º that you recommend? The reason for this is because I live in Portugal and can't source the 20º version.

Thanks in advance for your advice.

Regards,
Carlos

Yes, I am quite sure that you can use those as well - how ever, it might require a bit more calibration of the "const float A = 19.0; "
You  can try changing the number 19 to 18 or 20, or anything else really.

To calibrate i used the iOS app "Dark Sky Meter" and took 5 measurements and averaged them out.

Then you take a reading with your Arduino SQM and calibrate it so the readings corresponds to the App readings

/Daniel

  • Like 1
Link to comment
Share on other sites

20 minutes ago, sloz1664 said:

Hi Daniel,

Would I be able to amend the code to change the TSL 237 from input 8, to input 7. The LCD Shield is covering input 8.

 

Steve

No unfortunately, the Freqmeasure.h library uses the pin 8 for a arduino hardware timer and frequenze measurments.
But - i am fairly sure that the LCD sheild uses pin 8 as a reset function, you can assign that function (reset function) to another pin, not 100% sure but 95%.

/Daniel

Link to comment
Share on other sites

  • 2 months later...

Well I have all the pieces together, uploaded the code that was posted to the arduino Uno and the LCD screen lights up, but I must have missed a step. I can't get it to do anything with the momentary push button. 

Anyone have troubleshooting suggestions?

Thanks,

B

Link to comment
Share on other sites

On 03/02/2021 at 20:40, bmurphy495 said:

Well I have all the pieces together, uploaded the code that was posted to the arduino Uno and the LCD screen lights up, but I must have missed a step. I can't get it to do anything with the momentary push button. 

Anyone have troubleshooting suggestions?

Thanks,

B

If you have compiled the exact code, and connected everything according to the code, try to hold the button pushed down for a couple of seconds... it is a timer function in the code that might need to run first.

/Daniel

Link to comment
Share on other sites

6 hours ago, Corpze said:

If you have compiled the exact code, and connected everything according to the code, try to hold the button pushed down for a couple of seconds... it is a timer function in the code that might need to run first.

/Daniel

Thanks Daniel, I'll keep working on it. I'm sure it's somthing simple that I have not done. 

B

Link to comment
Share on other sites

Just wondered where you guys are buying the TSL237 from? They seem to be rarer than telescopes and there doesn't seem to be a direct equivalent for this code. Any help would be appreciated, thanks.

Link to comment
Share on other sites

  • 7 months later...
11 hours ago, Astra Obscura said:

The sensors are sold out globally. Would you be able to spare 1 of your 500? :D

Hello Astra and welcome to the site 👍 I ended up with just the two I ordered, looks like I could have made a few pennies if I had got the 500 🤣

Link to comment
Share on other sites

  • 10 months later...
  • 3 weeks later...
On 19/07/2022 at 20:41, servitecnic3999 said:

Hello, I have everything installed, but pressing does nothing, I have kept it pressed for more than 1 minute, but only Exo Photography sqm-meter appears.  any solution, thanks

Hve you altered anything in the code?
If not - check your hardware connections, it "should work"

/Daniel

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.