Home › Forums › Environmental Sensors › Solar Radiation › Reply To: Solar Radiation
2022-07-10 at 5:52 AM
#17145
Hi all, I own a SP-110 Apogee sensor. I am working the sensor with DOIT ESP32 Devkit Board V1. Could anyone please check the code and see if the code is done correctly? Do I need to include any library in the code? Thanks in advance. Rgds, Storm
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* code read Apogee SP-110 Solar Radiation Sensor output to the serial terminal. * RED wire: Data line, connect to ESP32 Devkit Board (30 Pin) ADC pin (pin 4) * WHITE and CLEAR/BARE wire: Connected to GND */ const int Analog_pin = 4; int sensorValue = 0; float voltage = 0; void setup() { Serial.begin(115200); } void loop() { sensorValue = analogRead(Analog_pin); // change this to the correct analog pin you're using voltage = (sensorValue * 3.3) / (4095.0); //convert bits to volts (12 bits) //ESP32 ADC bit can be (9 bits/10 bits/11 bits/12bits), //if the ESP32 ADC bit is not been configure then usually is in 12 bits float ShortwaveRadiation = voltage * 5.0; //Apogee SP-110 has calibrated output of 5.0 W/m2 per mV Serial.print ("Voltage: "); Serial.println(voltage); Serial.print(" mV; \n"); Serial.print ("Shortwave Radiation: "); Serial.println(ShortwaveRadiation); Serial.print(" W/m2\n"); delay(1000); } |