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
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
Let’s assume we’re using the
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) sleep(0.5)
I’m assuming you already have the following:
Raspbian For Robotsinstalled - i.e. from an image
GrovePiboard flashed with the latest version of the firmware.
Thank you both so much for replying and providing answers and solutions to my question! I should be good to go now. Thanks again!