The Planted Tank Forum - View Single Post - DIY PAR meter, Yeah you heard me
View Single Post
Old 01-20-2013, 01:19 AM   #474
O2surplus
Planted Tank Enthusiast
 
O2surplus's Avatar
 
PTrader: (4/100%)
Join Date: Jan 2010
Location: yorba linda, ca.
Posts: 573
Default

Here's the actual sketch that we used for the "Close Enough" PAR Meter.


Code:
// CLOSE ENOUGH PAR Written in Arduino 23 By MISTERGREEN

#include <LiquidCrystal.h> // modified by O2surplus to include correct LCD pinout for "CLOSE ENOUGH PAR Meter" V1.0
                           //  Code also includes provision for seial output of PAR values to a PC.
float average = 0;
float output = 0;
float factor = 1.52;
unsigned long time; 
int counter = 0;
// create the LCD
LiquidCrystal lcd(8, 7, 5, 4, 16, 2);
// set up backlight
int bkl = 6; // backlight pin

void setup() {
  time = millis();
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("CLOSE ENOUGH PAR");
  pinMode(bkl, OUTPUT);
  digitalWrite(bkl, HIGH);
  // initialize the serial communication:
  Serial.begin(115200); // Max for Arduino Uno
}

void loop() {

  int sensorValue = analogRead(0);
  average += sensorValue;
  counter++;

  //every second or 1000 millis
  if(millis() > time+1000) {
    //corrections to fit par
    average = average/counter;

    if(average <= 560) {
      factor = 1.55;
    } 
    else {
      factor = 1.36;
    }
    //corrects for high PAR
    output = average * factor;

    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
    // print the number of seconds since reset:
    lcd.print(output);
    // send PAR data to the Serial output.
    Serial.println(output, BYTE);
    
  }
  //reset timer & counter to get ready for the next second.
 // time = millis();
  counter = 0;
  average = 0;
 delay(1000);
}
__________________
225 Gal, Glass "Reef Ready" w/ twin Iwaki Pumps & 2 Ocean Clear inline filters. Custom 320 watt LED Lighting system utilizing a 6' Maker's Heat Sink, 12 BridgeLux Vero 18's,3 purpose built 5 channel A6211 Led driver/Controllers, and a 20lb CO2 system w/ Milwaukee Ph Controller.
O2surplus is online now   Reply With Quote