I am trying to help my son make a UV meter to test sunscreens for his school project.
We have already gone through a few coding issues, but keep having trouble with he sensors giving us weird random results. I am running them separately on an Arduino Uno R3.
I looked for basic code to run trials with both of them and I was from the get go getting random changes on the readings, going up and down into negative numbers with no apparent reason. I tried taking them outside without much improvement, but I chalked all this to testing them on a cloudy day or with my cell phone light. I purchased a lizard lamp with a bulb that emits both UVA and UVB, When i tested them again they continued giving me random readings that changed every reading without reason, also no noticeable change with distance of the UV source. I have been testing this indoors, in a normal house, in a room with a computer or 2, wifi and no weird electromagnetic interference or chemical weirdness. I have tried changing the delay from .3 seconds to 10 seconds and most everything in between without any noticeable improvement. I tried them with both 3.3 and 5 v without change, I also verified with a multimeter that they were receiving just below the voltage that they were hooked to ( 4.78 to 4.91 when hooked to 5V).
I will copy below the code I used to test them (i got them from the internet One is from Electropeak and the other I am not sure where i got it from) and a picture of the bulb info.
If someone can point me to what i am doing wrong I will appreciate it, since i am at a loss. I have ordered a few more sensors to test, but I feel its weird I have similar bad luck with both sensors.
UVM -30A
/*
UVM30A-UV-Module
Made on 02 Feb 2020
by Amir Mohammad Shojaee @ Electropeak
Home
*/
void setup(){
Serial.begin(9600);
}
void loop()
{
int sensorValue;
sensorValue=analogRead(A0);
Serial.print("The voltage value:");
Serial.print(sensorValue*5000/1023.0);
Serial.println("mV");
delay(1000);
Serial.print("\n");
}
GUVA-S12SD
void setup()
{
Serial.begin(9600);
}
void loop()
{
float sensorVoltage;
float sensorValue;
sensorValue = analogRead(A0);
sensorVoltage = sensorValue;
Serial.print("sensor reading = ");
Serial.print(sensorValue/1024*3.3);
Serial.println("");
Serial.print("sensor voltage = ");
Serial.print(sensorVoltage);
Serial.println(" V");
delay(3000);
}