I recently got a Dust sensor from a company and it says that the voltage out corresponds to the concentration of dust in the air. How can I use the GPIO pins to get the voltage reading?
The voltage is lower than 4 volts as well.
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityI recently got a Dust sensor from a company and it says that the voltage out corresponds to the concentration of dust in the air. How can I use the GPIO pins to get the voltage reading?
The voltage is lower than 4 volts as well.
Use an ADC (analogue-digital converter) like the MCP3008. Easy to get readings with Python:
from gpiozero import MCP3008
dust = MCP3008()
while True:
print(dust.voltage)
You can use dust.voltage
if you need the voltage itself, or use dust.value
to get a normalised value (0-1). See the gpiozero docs and this guide to using ADCs (including wiring).
I found several tutorials online for connecting analog inputs to a Raspberry Pi. I'd recommend the Adafruit site. I noticed that one of the chips they used was about the same price as an small Arduino, which has 5 analog inputs. There are many online tutorials to show you how to communicate between and Arduino and Raspberry Pi.