python - ADCPi- how to run without being root? -


i have pi model a, running latest version of raspbian. plugged adc-pi (https://www.abelectronics.co.uk/products/3/raspberry-pi/17/adc-pi-v2---raspberry-pi-analogue-to-digital-converter) various analog sensors.

running demo code (which below) if use './adc_demo.py' works fine if use 'sudo python3 adc_demo.py' error 'import error: no module named quick2wire.i2c'. can can run using latter statement? have script runs motor through gpio pins on pi, , needs ran root- , i'm trying merge 2 scripts together.

adc_demo.py

#!/usr/bin/env python3 # read abelectronics adc pi board inputs # uses quick2wire http://quick2wire.com/ # see http://elinux.org/rpi_adc_i2c_python full setup instructions  import quick2wire.i2c i2c  import re import time  adc_address1 = 0x68 adc_address2 = 0x69  adc_channel1 = 0x98 adc_channel2 = 0xb8 adc_channel3 = 0xd8 adc_channel4 = 0xf8   line in open('/proc/cpuinfo').readlines():     m = re.match('(.*?)\s*:\s*(.*)', line)     if m:         (name, value) = (m.group(1), m.group(2))         if name == "revision":            if value [-4:] in ('0002', '0003'):                 i2c_bus = 0             else:                 i2c_bus = 1             break  i2c.i2cmaster(i2c_bus) bus:      def getadcreading(address, channel):         bus.transaction(i2c.writing_bytes(address, channel))         time.sleep(0.05)         h, l, r = bus.transaction(i2c.reading(address,3))[0]         time.sleep(0.05)         h, l, r = bus.transaction(i2c.reading(address,3))[0]          t = (h << 8) | l         v = t * 0.000154         if v < 5.5:             return v         else: # must floating input             return 0.00  while true:      print("1: %f" % getadcreading(adc_address1, adc_channel1))     print("2: %f" % getadcreading(adc_address1, adc_channel2))     print("3: %f" % getadcreading(adc_address1, adc_channel3))     print("4: %f" % getadcreading(adc_address1, adc_channel4))      print("5: %f" % getadcreading(adc_address2, adc_channel1))     print("6: %f" % getadcreading(adc_address2, adc_channel2))     print("7: %f" % getadcreading(adc_address2, adc_channel3))     print("8: %f" % getadcreading(adc_address2, adc_channel4))      time.sleep(1) 


Comments