Adafruit GUVA-S12SD not working

I have a simple program that I've found that is supposed to allow me to use an Adafruit UV sensor. However, It's not working. Here's the code:

#include "arduino.h"
#include "GUVA-S12SD.h"

void setup() 
{
  Serial.begin(9600);
}
void loop() 
{
  // I'm tracking all of the voltages to check for any irregularities
  float sensorVoltage; 
  float sensorValue;
  float sensorVoltage2; 
  float sensorValue2;
  float sensorVoltage3; 
  float sensorValue3;
  float sensorVoltage4; 
  float sensorValue4;
  float sensorVoltage5; 
  float sensorValue5;
  float sensorVoltage6; 
  float sensorValue6;
  float sensorVoltage7; 
  float sensorValue7;
  float sensorVoltage8; 
  float sensorValue8;

  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
  Serial.print(" reading A0 = ");
  Serial.print(sensorValue);
  
  sensorValue2 = analogRead(A1);
  Serial.print(" // reading A1 = ");
  Serial.print(sensorValue2);

  sensorValue3 = analogRead(A2);
  Serial.print(" // reading A2 = ");
  Serial.print(sensorValue3);

  sensorValue4 = analogRead(A3);
  Serial.print(" // reading A3 = ");
  Serial.print(sensorValue4);

  sensorValue5 = analogRead(A4);
  Serial.print(" // reading A4 = ");
  Serial.print(sensorValue5);

  sensorValue6 = analogRead(A5);
  Serial.print(" // reading A5 = ");
  Serial.print(sensorValue6);

  sensorValue7 = analogRead(A6);
  Serial.print(" // reading A6 = ");
  Serial.print(sensorValue7);

  sensorValue8 = analogRead(A7);
  Serial.print(" // reading A7 = ");
  Serial.println(sensorValue8);

  delay(500);
}

I have a wire connecting the "+" pin on the sensor to the "5V" pin on the Arduino, a wire connecting the "-" pin on the sensor to the "GND" pin on the Arduino, and a third wire connected to the "Out" pin on the sensor. I don't have this wire attached to the Arduino, instead I've been touching it manually to the board to test the different analog outputs, from 0-7.

When I hook it up to my PC and run the program, the code functions, but what it does is confusing. All 8 values fluctuate at around 60-90, but if I touch the wire connected to "Out" to any of the analog pins on my Arduino board, the value for that pin almost immediately drops to 0.

Additionally, the serial plotter is a bit odd.
This is a screenshot of what it looks like when I run the program.


For some reason, there isn't a "value 0" or "value 1" for some reason, and only one of the values is actually plotted. In this case, it's value 5. I've checked, too, and none of the other values are being shown on the plotter. Also, when I went to take a screenshot of the plotter, the values were all mixed up. This hasn't happened for me before, and I don't know if that's an issue or not.

Can anybody help?

You should not make any changes to a circuit while it is powered up, as that tends to damage the Arduino.

If there is no strong source of UV present, you should expect an analog reading of about "0".

Check out the Adafruit product page for the UV sensor.

I have an Adafruit GUVA-S12SD ultraviolet sensor that I've connected to my Arduino nano board. The "GND" pin on the board is connected to the "-" pin on the sensor, the "5V" pin on the board is connected to the "+" pin on the sensor, and the "A0" pin on the board is connected to the "Out" pin on the sensor. I'm also using the basic "ReadAnalogVoltage" program. Here it is, in case you'd like a reference:

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}

The problem is, the code seems to do the opposite of what it's supposed to! I've run some tests with and without the UV sensor connected to the A0 pin. When I'm inside (with no UV light) and it's not connected, I get numbers around 0.45. When I'm outside (with UV light), and it's not connected, I get about 2.5. However, in both cases (inside and outside), when I attach the wire to A0, the number immediately drops to 0. Why is that?

Probably a wiring error. Please post a link to the sensor, and a diagram or photo showing your own wiring.

Here you go!

Analog UV Light Sensor Breakout - GUVA-S12SD : ID 1918 : $6.50 : Adafruit Industries, Unique & fun DIY electronics and kits

image

Please do not cross post. Adafruit GUVA-S12SD not working

Looks okay. Please post a photo of your actual wiring. Which Nano, the Classic or Every?

It's a nano 33 ble. Here's some pictures:


The solder joins are extremely bad. Look there first.

If the BLE is a 3.3V processor based Ard, you better not connect a 5V device to an input... if that is so, connect (+) to 3.3V.

Many people will be confused with your use of red as ground and black as power, usually it's the reverse.

I see solder on A3 and the alternate ground pin. Is there something you did there and didn't mention?

The solder on the ground pin was from older tests. A bit ago, I had the suspicion that the different ground pins might correspond to the analog and digital sides of the board (I'm pretty new to Arduino so I have no idea). The blue wire was originally soldered to A3, but I removed it so that I could easily move the wire to different analog pins between tests.

I have merged your topics due to them having too much overlap on the same subject matter @l_t.

In the future, please only create one topic for each distinct subject matter and be careful not to cause them to converge into parallel discussions.

The reason is that generating multiple threads on the same subject matter can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Thanks in advance for your cooperation.

Is it possible that I may need some sort of library to be installed for this to work?

The first thing to do is fix the wiring. The connection on A0 needs to be soldered.

Then, read the Adafruit product page and revise your expectations.

I've already tried it soldered, as that was why there is leftover solder on A3. I also tried using a breadboard, and even connecting to 3.3V instead of 5V. After all that, nothing. Could there maybe be some sort of file that I need to install to the IDE?

I've also checked the Adafruit page, but couldn't find much help there.

Use your multimeter to measure the output voltage of the UV sensor module, in the dark and when illuminating the sensor with full sunlight, outdoors. The sensor needs to be powered, of course, and solder joints to the module must be clean and not touching each other.

Post the results you get.

Ok, when I tried directly measuring the output voltage of the 5V pin with the multimeter, I wasn't getting any power. However, when I tried the VIN pin, I was getting some power. So, I tried hooking it up to the UV sensor with the VIN pin instead of the 5V pin, and it worked. But, I'm skeptical that it may not work when I try to hook it up when it's not connected to my computer.

What does the VIN pin actually do, and will it work if I use it?

There is no VIN pin.

From the product page:

To use, power the sensor and op-amp by connecting V+ to 2.7-5.5VDC and GND to power ground. Then read the analog signal from the OUT pin. The output voltage is: Vo = 4.3 * Diode-Current-in-uA. So if the photocurrent is 1uA (9 mW/cm^2), the output voltage is 4.3V. You can also convert the voltage to UV Index by dividing the output voltage by 0.1V. So if the output voltage is 0.5V, the UV Index is about 5.

Capture.PNG

When I was talking about the 5V and VIN pins, I meant on the Arduino. Sorry for that confusion.


(Bottom left of the board in this pic)

You can read about how to power the Nano 33 through the VIN pin in the Nano 33 documentation.

Thanks! I'll check that out now.