The Planted Tank Forum - View Single Post - DIY PAR meter, Yeah you heard me

View Single Post
post #547 of (permalink) Old 05-09-2013, 04:23 PM Thread Starter
mistergreen
Children Boogie
 
mistergreen's Avatar
 
Join Date: Dec 2006
Location: Cincinnati
Posts: 16,304
New firmware with new outdoor function. The new total resistance is ~15.9K ohm instead of the previous 21K-27K.

Code:
// CLOSE ENOUGH PAR Written in Arduino 23 By MISTERGREEN
// for sunlight and indoor light
#include <math.h>
#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_indoor = 0;
float output_outdoor = 0;
float factor = 0;
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("Indoor   Outdoor");
  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 = 2.077;
    } 
    else {
      factor = 1.934;
    }
    float tempout = average * factor;
    //indoor fluorensence
    output_indoor = tempout;
    
    //add 10% to output for sunlight
    output_outdoor = tempout + (tempout * .10);

    // 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(round(output_indoor));
    lcd.print("   ");
    
    lcd.setCursor(9, 1);
    lcd.print(round(output_outdoor));
    lcd.print("   ");
    
    // send PAR data to the Serial output.
    
    Serial.print(output_indoor);
    Serial.print(",");
    Serial.println(output_outdoor);
    
    //reset timer & counter to get ready for the next second.
   time = millis();
   counter = 0;
   average = 0;
    
  }
  
  delay(5);

}


Last edited by mistergreen; 05-09-2013 at 05:58 PM. Reason: +
mistergreen is online now  
 
 
For the best viewing experience please update your browser to Google Chrome