Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
MQTT control of PWM capable pins on the Raspberry Pi - not strictly limited to lighting either...
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
LICENSE Added licence
README mosquitto repo and dependencies
mqtt-pwm-lights.cfg.example Reduced the specificity of the subscription
mqtt-pwm-lights.init The gpio needs initialised twice, for some reason Fix indentation for logging



This script subscribes to a topic defined in /etc/mqtt-pwm-lights/mqtt-pwm-lights.cfg, and adjust the PWM value on the configured pin (18 by defualt) on a Raspberry Pi. It requires the WiringPi library from as the gpio command is used to control the PWM values on the GPIO interface. Neither WiringPi SYSFS exporting or RPi.GPIO (Python library) support PWM at this point in time.

When any change to the lighting level is required, it will ramp up or down to the desired level, creating a smooth lighting level change effect.


# This needs automated and/or packaged up

sudo echo "deb wheezy main" > /etc/apt/sources.list.d/mosquitto-wheezy.list
wget -O /tmp/mosquitto-repo.gpg.key
sudo apt-key add /tmp/mosquitto-repo.gpg.key
sudo apt-get update

sudo apt-get install python-mosquitto git
mkdir /etc/mqtt-pwm-lights/
git clone git:// /usr/local/mqtt-pwm-lights/
cp /usr/local/mqtt-pwm-lights/mqtt-pwm-lights.cfg.example /etc/mqtt-pwm-lights/mqtt-pwm-lights.cfg
cp /usr/local/mqtt-pwm-lights/mqtt-pwm-lights.init /etc/init.d/mqtt-pwm-lights
update-rc.d mqtt-pwm-lights defaults
cp /usr/local/mqtt-pwm-lights/mqtt-pwm-lights.default /etc/default/mqtt-pwm-lights
## Edit /etc/default/mqtt-pwm-lights and /etc/mqtt-pwm-lights/mqtt-pwm-lights.cfg to suit
/etc/init.d/mqtt-pwm-lights start

See LICENSE file
Something went wrong with that request. Please try again.