Home › Forums › Environmental Sensors › Solar Radiation › Reply To: Solar Radiation
Sure, if the manual says it’s okay to ground the sensor’s negative signal wire, then you can just connect the sensor’s ground and negative signal wires to a “GROUND” pin on the Mayfly, and then connect the sensor’s positive signal wire to one of the Mayfly’s auxiliary analog pins. The easiest way to do this is with one of these Grove-to-screw-terminal boards:
https://www.robotmesh.com/grove-screw-terminal
If you’re using aux analog pin 0, then the following code will work for reading your SP-110 sensor. I put the correct conversion factor in the sketch for your particular sensor. If anyone tries to use this sketch with other sensors with different conversion factors, they will need to change that part of the sketch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include <Wire.h> #include <Adafruit_ADS1015.h> Adafruit_ADS1115 ads; /* Use this for the Mayfly because of the onboard 16-bit ADS1115 */ void setup(void) { Serial.begin(9600); ads.begin(); } void loop(void) { int16_t adc0 = ads.readADC_SingleEnded(0); //reads Mayfly aux analog channel 0 (AA0), returns number of bits float voltage = adc0 * 0.1875; //converts bits to millivolts; default resolution of ADS1115 is 0.1875mv/bit float ShortwaveRadiation = voltage * 5.0; //Apogee SP-110 has calibrated output of 5.0 W/m2 per mV Serial.print("Voltage: "); Serial.print(voltage); Serial.print(" mV; "); Serial.print("Shortwave Radiation: "); Serial.print(ShortwaveRadiation); Serial.println(" W/m2"); delay(1000); } |