The GUVA-S12SD UV Sensor chip is suitable for detecting the UV radiation in sunlight. It can be used in any application where you want monitor for the amount of UV light and is simple to connect to any microcontroller. I recently noticed that some sellers had little modules for this sensor at a reasonable price so decided to purchase one
The module, with a typical UV detection wavelength of 200 – 370nm, outputs a calibrated analog voltage which varies with the UV light intensity so basically all you need to do is connect this to an ADC input and read in the value.
This value ties in with the UV index, this looks something like this
Connection
The connections are straightforward and described below, I used 3.3v from my Raspberry Pi.
1. GND: 0V (Ground)
2. VCC: 3.3V
3. OUT: 0V to 1V ( 0 to 10 UV Index)
Layout
As said its a simple layout but here you go, again I use an Analog Zero which has an MCP3008
Code
[codesyntax lang=”python”]
import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
def readadc(adcnum):
# read SPI data from MCP3008 chip, 8 possible adc’s (0 thru 7)
if adcnum > 7 or adcnum < 0:
return -1
r = spi.xfer2([1, 8 + adcnum << 4, 0])
adcout = ((r[1] & 3) << 8) + r[2]
return adcout
while True:
value = readadc(0)
volts = (value * 3.3) / 1024
print (“%4d/1023 => %5.3f V” % (value, volts))
time.sleep(0.5)
[/codesyntax]
Testing
Open the serial monitor and look at the readings
If you look at the image earlier that corresponds to UV index of 0 which is a relief because I tested this indoors
Links