How to control DMX lights with Raspberry Pi

I have an upcoming project where I will be controlling the exterior lights of a major building in my city, and in order to do that I need to master controlling DMX devices with a Raspberry Pi. I have an old DJ style lamp at home that uses DMX protocol which is perfect for testing. With a Raspberry Pi and a DMX adapter, you can use a little python to program the projector. Getting it to work was a tough process, so hopefully I can make it easier for the next person. If you’re looking to control DMX lights with a Raspberry Pi, here’s an easy way to do it.

What you will need for this project

  • Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero with power adapter and SD card
  • Enttec open DMX USB adapter
  • A DMX compatible luminaire
  • A 5-pin DMX cable (with 5 to 3-pin adapter if necessary for your luminaire)

How to control DMX lights with a Raspberry Pi (the easiest way)

For this project we will use the Open Lighting Architecture (OLA) to send DMX frames to lights. Before you start, set up your Raspberry Pi. If you haven’t already, check out our article on how to install a Raspberry Pi for the first time or how to make a Raspberry Pi headless installation (without keyboard and screen). For this project we recommend a Raspberry Pi headless installation.

1. Install basic requirements needed by the project, including OLA, python, and python-bindings for the project.

sudo apt-get update
sudo apt-get install -y 
   ola 
   git 
   ola-python 
   python3-pip

2. Add the user pi to the olad group.

sudo adduser pi olad

3. Go down to the OLA configuration directory and save some plugin configuration files. We won’t be using backups, but it’s useful in case you need to refer to something later.

cd /etc/ola/
sudo cp ola-ftdidmx.conf ola-ftdidmx.conf.bak
sudo cp ola-usbserial.conf ola-usbserial.conf.bak
sudo cp ola-opendmx.conf ola-opendmx.conf.bak

4. Edit the ola-ftdidmx.conf file to set `enabled = false` to` enabled = true`. You can use a text editor or the command below.

sudo tee ./ola-ftdidmx.conf > /dev/null <

5. Edit the ola-usbserial.conf file and ola-opendmx.conf to set `enabled = false`. You can use a text editor or the commands below.

sudo tee ./ola-usbserial.conf > /dev/null < /dev/null <

6. Reload plugins by restarting the OLA daemon.

sudo killall -s SIGHUP olad

seven. Connect your Enttec Open DMX USB adapter to your Raspberry Pi, any USB port will do.

(Image credit: Tom’s Hardware)

8. Using a DMX cable connect your Open DMX adapter to your device; make sure it is powered on and in DMX mode.

(Image credit: Tom’s Hardware)

9. Run the following command to discover your device, write down the number next to the device ID.

ola_dev_info | grep FT232R

Note: If your device is not discoverable, go to web interface in step 11, then click “Reload plugins” – then try again.

ten. Patch your device in a DMX universe (we will use universe 0) with the following command:

# Adjust device ID (-d 8), and port (-p 1) to match your device from the previous command
ola_patch -d 8 -p 1 -u 0

11. Visit the IP address of your Raspberry Pi in your internet browser, followed by port 9090 to confirm that the universe was created.

open http://10.0.0.1:9090

12. In the web interface, select your universe, go to the DMX Console tab, and increase the sliders for each channel until you see your light fixture start to turn on. For my device, channel 1 controls red, 2 controls blue, and 3 controls green. By adjusting the individual channels, we can control the color of the device.

Image 1 of 2

Control DMX lights with Raspberry Pi

(Image credit: Tom’s Hardware)
Image 2 of 2

Control DMX lights with Raspberry Pi

(Image credit: Tom’s Hardware)

13. Using git, clone the example python repository in your personal directory.

cd ~/
git clone https://github.com/rydercalmdown/dmx_lights.git

14. Scroll down in the directory and install the repository requirements.

cd dmx_lights
make install

15. Start the vial server with the following command. You can then visit the Pi’s IP address on port 8000 to see the server.

make run

16. Change the color of the lights by visiting the wash endpoints with curl or in your browser.

curl http://IP_ADDRESS_OF_YOUR_PI:8000/wash/red/
curl http://IP_ADDRESS_OF_YOUR_PI:8000/wash/random/
curl http://IP_ADDRESS_OF_YOUR_PI:8000/wash/blue/
curl http://IP_ADDRESS_OF_YOUR_PI:8000/blackout/

(Image credit: Tom’s Hardware)

Hope this gives you an example of how to get started with python and a Raspberry Pi to control DMX devices. Getting it to work fine for me took a weekend, but by following these instructions you should be able to do it in under an hour. Good luck!

(Image credit: Tom’s Hardware)


Source link

Comments are closed.