Home › Forums › Environmental Sensors › Solar Radiation › Reply To: Solar Radiation
2017-10-05 at 8:06 PM
#2354
The code I posted above is for when you use a ADS1115 16-bit ADC. If you’re using a standard Uno or Mega board, you’ll have to use the regular 10-bit ADC, unless you’re planning to use a separate ADS1115 breakout. But assuming you’re okay with the lower resolution of the 10-bit ADC, just use the standard analogRead command and then convert the result to voltage. And because the output of the SP-212 is 1mv = 1 PAR, the measured voltage (in millivolts) is the PAR. The 10-bit resolution of the ADC means you’ll get steps of around 5 PAR (4.89 actually).
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
void setup(void) { Serial.begin(9600); } void loop(void) { int sensorValue = analogRead(A0); //change this to the correct analog pin you're using float voltage = sensorValue * (5.0 / 1023.0); //converts bits to volts float PAR = voltage * 1000.0; //converts volts to PAR (for SP-212, 1 mV = 1 PAR) Serial.print("Bits: "); Serial.print(sensorValue); Serial.print(" PAR: "); Serial.println(PAR); delay(1000); } |