vsergeev / lua-periphery

A Lua library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
MIT License
186 stars 39 forks source link

Opening PWM: opening 'export': No such file or directory [errno 2] #22

Closed PhilMo6 closed 4 years ago

PhilMo6 commented 4 years ago

Trying to use the pwm module and am getting this error. This is my code up to the error.

local PWM = require('periphery').PWM local pwm local success,err = pcall(function() pwm = PWM(0, 22) end) print(success,err) false Opening PWM: opening 'export': No such file or directory [errno 2]

Im using a Raspberry Pi Model B Plus Rev 1.2 running the latest Raspbian os

vsergeev commented 4 years ago

It sounds like the PWMs are not enabled in the kernel, in which case you'll need to enable them with a Device Tree overlay by adding a dtoverlay=pwm or dtoverlay=pwm-2chan kernel argument to your /boot/config.txt. Once enabled, the channel number will be numbered incrementally from 0 (not with the pin number).

You can find a few guides online to help with the configuration, as there are several different choices of pins you can enable for PWM -- I recommend searching for dtoverlay=pwm or dtoverlay=pwm-2chan and Raspberry Pi.