[SOLVED] Grove UV Sensor and GrovePi

Has anyone tried to use this sensor with the grovepi? I didn’t see any code on github for it.


I did just do a little reading on it and as far as I can tell it is an analog sensor and will run on voltages between 3v - 5v (RPI runs a 3.3v pins). RPi doesn’t come standard with any analog pins like arduino but the GrovePi does have an analog to digital converter that allows you to plug analog sensors into the RPi through the bGrovePi.

I haven’t used the GrovePi but I assume it has a built library for reading analog sensors

Hi @paul.reisinger,

Just as @Shane.gingell said, this is an analog sensor, so you can use it with the GrovePi. There’s just some math involved in order to bring the readings to something useable. I looked over Seeed's website for the math I need to use.

You’d have to connect the sensor to one of the analog ports of the GrovePi.
Let’s assume we’re using the A0 port.

The code is going to look like this:

import grovepi 
from time import sleep

uv_sensor_pin = 0 # A0 port on the GrovePi

while True:
    uv_sensor_value = grovepi.analogRead(uv_sensor_pin) # read value of the sensor pin
    uv_sensor_voltage = uv_sensor_value / 1023.0 # get voltage value
    illumination_intensity = uv_sensor_value * 307 # get mW/m^2

    print("mW / m^2 = %.2f", illumination_intensity)

I’m assuming you already have the following:

  1. Have Raspbian For Robots installed - i.e. from an image

  2. Have the GrovePi board flashed with the latest version of the firmware.

Thank you!

Thank you both so much for replying and providing answers and solutions to my question! I should be good to go now. Thanks again!

1 Like