GUVA-S12SD giving huge voltage values

I used this tutorial here to setup the GUVA-S12SD (used my ESP32): Interfacing GUVA-S12SD UV Sensor Module with Arduino - Electropeak

When I shine light at the sensor from my phone I get readings as high as 20V. Here is an snippet of readings:

sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 48.00        sensor voltage = 0.23 V
sensor reading = 677.00        sensor voltage = 3.31 V
sensor reading = 1311.00        sensor voltage = 6.40 V
sensor reading = 3049.00        sensor voltage = 14.89 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 4095.00        sensor voltage = 20.00 V
sensor reading = 2569.00        sensor voltage = 12.54 V
sensor reading = 980.00        sensor voltage = 4.79 V
sensor reading = 265.00        sensor voltage = 1.29 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V
sensor reading = 0.00        sensor voltage = 0.00 V

I admit to get readings that high I have to bring the flash really close and it is fairly bright flash, but it still is a mobile phone flash and the sensor should not react to it since there is no UV light coming out of it.

Am I doing something wrong or is my sensor just faulty?

You assume? Also have you checked the sensor optical sensitivity bandwidth?

Your conversion from sensor readings (I believe these are counts from the ADC). to Sensor voltage is wrong.

Assuming you are supplying the sensor with 3.3v the max you can get out is 3.3V.

The readings of 4095 means the Analog input is equal to or more that the ADC input can convert.

How are you connecting and powering the sensor?

It sounds like the analog input is floating. Check continuity of connections.

Did you connect the grounds?

My multimeter does measure 5v max when supplied with 5v. So the calculations in the example code must be wrong. I still don't understand why mobile flash that should not be in the range of UV light produces a reading in the first place.

Hi, @shard91
Welcome to the forum.

Can you post a picture of your project so we can see your component layout?
Can you please post a circuit diagram of your project too?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

You should not be putting 5V into this sensor as in that diagram, because you only have a 3V3 system, try connecting the sensor to 3V3, although I don’t know if the sensor will work correctly at that voltage. The voltage conversion formula is designed for a 5V 10 bit system. You seem to have a 3V3 12 bit system, so you will need that to be reflected in the formula. So swap 1024 for 4096 and the 5.0 to 3.3.

Two points

  1. a white LED is made by a UV LED shining on a phosphor which then glows white, so some of that UV is getting through. Also the phosphor can be emitting in the UV region, below the frequency of the excitation LED.

  2. the detector can be reacting to out of band radiation.

@TomGeorge
Here is a photo of the setup:

I added the screen to not rely on the serial monitor and to be able to move this around.

Circuit diagram:

ESP32 GND > GUVA GND
ESP32 5V VCC > GUVA VCC
ESP32 GPIO 32 > GUVA SIG

ESP32 3V3 > OLED VCC
ESP32 GND > OLED GND
ESP32 SCL > OLED SCK
ESP32 SDA > OLED SDA

and the code I use to display the values:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE,BLACK);
}

void loop() {
  float sensorVoltage;
  float sensorValue;

  sensorValue = analogRead(32);
  sensorVoltage = sensorValue/1024*5.0;

  String buf;
  buf += F("value:");
  buf += String(sensorValue, 6);
  buf += F("\nvoltage:");
  buf += String(sensorVoltage, 6);

  display.setCursor(0, 10);
  display.println(buf);  
  display.display(); 
  delay(1000);
}

also a bonus video that shows this all in action: link

The GUVA sensor is designed to work with 5V. But changing the 1024 to 4096 and keeping the 5.0v resulted in an output voltage in range of 0-5V.

Almost all the white led lights I shined on the sensor from very close range result in the max 5V reading.

So you are not interested about keeping your processor safe from voltages outside its rails then. When it suddenly fries you should not be surprised.

I mean the reading from that formula no longer shows values between 0-20V but instead 0-5V. Which is still not the 0-1V shown in the tutorial. So nothing really changed, just the formula in the code.

Try

int analogValue;

void setup()
{
  float sensorVoltage; 
  float sensorValue; 
  
 analogValue = sensorValue;

Not true. It is an analog device and will work on any voltage between 2 and 5.5V.

Yes the sensor is but your Arduino board is operating at 3.3v so you are best powering the sensor from 3.3V.

I believe you mentioned you have a voltmeter. I suggest you power the sensor from any convenient voltage from 3 to 5V, DO NOT CONNECT IT TO THE ARDUINO BOARD.

Use the voltmeter and sensor to get a feel for how the sensor responds to darkness, inside, outside etc.

Then when you have an understanding of what is going on you connect it to the Arduino board.

You can expect roughly 1V output from the GUVA-S12SD sensor, pointing at full summer sun, in clear sky at noon.

Ok, so I connected 3.2v LiFePo4 battery directly to the GUVAs VCC + GND and measured voltage from SIG + GND with 2 of my multimeters. Both of them read 3.2v output when the flashlight was shined directly at sensor from close proximity.

Seems that the sensor is defective. Check with full sun, though.

From your description it sounds like if covered with a metal or ceramic cover the voltage did not go low.

Also as @jremington suggested you should go outside or by an OPEN window (i.e. no glass between sensor and outside sun)

Could be a bad sensor but they should be pretty tough, unless you had in the past connected it backwards.

The output amplifier is a variation of an LM358 whose output is limited to about 0.5 volts below Vcc.

Voltage drops to 0 pretty fast as I start moving my flashlight away from it. Maybe the sensor just doesn't like bright light few millimeters away from it. As @jremington suggested, I will try with the sun as soon as I see the sun here in north.

At my latitude of 44N, using the Adafruit version of that sensor (same circuit gain, MCP6001 rail to rail op amp), I measured 0.8V output (UVI about 8) in full sun at noon on Oct. 10. It will drop every day, with the sun lower in the sky.