Home › Forums › Environmental Sensors › Solar Radiation
- This topic has 8 replies, 4 voices, and was last updated 2022-07-10 at 5:52 AM by Storm.
-
AuthorPosts
-
-
2017-07-03 at 5:35 PM #2265
I am looking to use a Mayfly with a solar radiation sensor. It’s a simple, 3-wire analog sensor and I think it’s standard in weather station equipment. Does anyone have experience doing this, or a sketch to share?
-
2017-07-06 at 4:07 PM #2267
I have used several solar radiation sensors with my Mayfly boards, so it’s possible, however it really depends on what the excitation voltage of the sensor is, and what the analog signal’s output voltage is. Can you tell me the make and model of the sensor, or at least what are the power requirements and output voltage?
-
2017-07-06 at 5:22 PM #2269
Thanks for the response. We’re using an Apogee SP-110, which is self-powered (doesn’t draw from the battery) and provides output in the range of 0-250 mV. The 3 wires go to a positive and negative signal from the sensor and a ground.
-
2017-07-06 at 5:51 PM #2271
The Apogee SP-110 will work fine with the Mayfly. Just connect the signal wires to AA0 and AA1 (the aux analog inputs) and do a differential measurement. You’ll need to use the Adafruit_ADS1x15 library and look at the example for differential measurements.
We always use the amplified output versions of Apogee’s solar sensors instead of the self-powered ones because they have much better sensitivity. There’s an order of magnitude improvement in the sensitivity by using the amplified ones, and it results in a much cleaner signal too. The SP-212 is the amplified (2.5v) equivalent of the SP-110, so I would recommend that instead if you haven’t already purchased the sensor.
-
2017-07-07 at 10:05 AM #2272
Thanks again. We’ll probably stick with the SP-110 since we have a few already in the lab. I found in a datalogger manual that they recommend using it as a single-ended analog sensor, where the positive wire is the signal and the negative wire is an additional ground. I saw in the ADS1x15 library that there is a folder for singleended. Would I just follow that example and keep the wiring the same? Or would I wire both “ground” wires to the ground pin (black wire on the starter kit)?
-
2017-07-07 at 11:00 PM #2273
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.
Arduino12345678910111213141516171819#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 bitsfloat voltage = adc0 * 0.1875; //converts bits to millivolts; default resolution of ADS1115 is 0.1875mv/bitfloat ShortwaveRadiation = voltage * 5.0; //Apogee SP-110 has calibrated output of 5.0 W/m2 per mVSerial.print("Voltage: "); Serial.print(voltage); Serial.print(" mV; ");Serial.print("Shortwave Radiation: "); Serial.print(ShortwaveRadiation); Serial.println(" W/m2");delay(1000);} -
2017-10-04 at 11:14 PM #2352
I own a SP-212 sensor. Could you please share the code for SP-212 to work with arduino mega 2560 and also arduino uno? I’m not using Mayfly.
-
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).
Arduino1234567891011121314void setup(void){Serial.begin(9600);}void loop(void){int sensorValue = analogRead(A0); //change this to the correct analog pin you're usingfloat voltage = sensorValue * (5.0 / 1023.0); //converts bits to voltsfloat 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);} -
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
Arduino1234567891011121314151617181920212223242526/* 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 usingvoltage = (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 bitsfloat ShortwaveRadiation = voltage * 5.0; //Apogee SP-110 has calibrated output of 5.0 W/m2 per mVSerial.print ("Voltage: "); Serial.println(voltage); Serial.print(" mV; \n");Serial.print ("Shortwave Radiation: "); Serial.println(ShortwaveRadiation); Serial.print(" W/m2\n");delay(1000);}
-
-
AuthorPosts
- You must be logged in to reply to this topic.