I'm using Pi Zero/ Pi ZeroW with StrechLite to display an output on a 16X2 LCD display.

drivers was installed as instructed on PiGuy official site.

while running a sample code after installing - an error occurs:

guy@rpi2:~/Documents/github/Rpi/GPIO_Projects/lcd $ python3 demo_clock.py 
Traceback (most recent call last):
  File "demo_clock.py", line 12, in <module>
    display = lcddriver.lcd()
  File "/home/guy/Documents/github/Rpi/GPIO_Projects/lcd/lcddriver.py", line 67, in __init__
    self.lcd_device = i2c_lib.i2c_device(ADDRESS)
  File "/home/guy/Documents/github/Rpi/GPIO_Projects/lcd/i2c_lib.py", line 7, in __init__
    self.bus = smbus.SMBus(port)
PermissionError: [Errno 13] Permission denied

But when using sudo it runs OK (taken from here):

guy@rpi2:~/Documents/github/Rpi/GPIO_Projects/lcd $ sudo python3 demo_clock.py 
[sudo] password for guy: 
Writing to display

  [1]: https://www.theraspberrypiguy.com/raspberry-pi-mini-lcd-display-tutorial/

Any ideas how to solve it ?



With the recent Raspbian releases from raspberryi.org the pi user may be added as a member of the gpio, i2c, and spi groups, to grant access to those peripherals.

You don't mention the operating system you are using.

Try the following then logout and log back in for it to take effect.

sudo adduser pi i2c

  • I did mention : StrechLite
    – Guy . D
    Mar 9 '18 at 13:26
  • So you did. I looked at the tags.
    – joan
    Mar 9 '18 at 13:29
  • You are correct!
    – Guy . D
    Mar 9 '18 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.