使用方法

GP2Y1014AY粉尘传感器返回的是模拟量,树莓派没有模拟量输入引脚则需要使用的ads1115数模转换模块

安装Python模块

  1. sudo pip install adafruit-circuitpython-ads1x15

使用模块

  1. import time
  2. import board
  3. import busio
  4. import adafruit_ads1x15.ads1015 as ADS
  5. from adafruit_ads1x15.analog_in import AnalogIn
  6. # Create the I2C bus
  7. i2c = busio.I2C(board.SCL, board.SDA)
  8. # Create the ADC object using the I2C bus
  9. ads = ADS.ADS1015(i2c)
  10. # Create single-ended input on channel 0 相当于读取ads1115 A0 的信息
  11. chan = AnalogIn(ads, ADS.P0)
  12. # Create differential input between channel 0 and 1
  13. #chan = AnalogIn(ads, ADS.P0, ADS.P1)
  14. print("{:>5}\t{:>5}".format('raw', 'v'))
  15. while True:
  16. print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
  17. time.sleep(0.5)

GP2Y1014AY粉尘传感器

  • 引脚分布

image.png

  • 接线图

image.png