This is a simple application for the Spark Core that receives DMX-Values over WiFi and transmits it over DMX.
The received DMX data is stored and transmitted over DMX with a refresh rate of 25Hz.
The color of the RGB LED is determined by the first 3 channels and the small blue LED toggles every time the DMX universe is sent. The Outputs D0-D7 are set to DMX Values 1-8 (D0 and D1 as PWM, rest as digital).
This code integrates great to home-automation-servers such as openHAB, Loxone or many others as you can use simple commands for one specific channel. If you use ArtNet you have to send all 512 channels at once, using this code you can set or fade any channel with a simple packet.
Send the command(s) to Spark Core IP, Port 3200 (TCP or UDP):
< Mode >< DMX-Channel >[,< DMX-Value >,[< Fading-Time >]][;< Next Command >]
Where mode is S for set or F for fade, DMX-Channel as a single Channel from 1-512 and Value from 0-255.
On unix for example:
# echo "S1,255;F2,255;F3,128" | nc -u sparkcore.lan 3200
This will set Channel 1 instantly to 255 (=100%) and softly fade Channel 2 to 255 (100%) and Channel 3 to 128 (50%).
This code will not work in Sparks online IDE! You have to compile it yourself or upload the firmware without changes.
Check out Sparks repository for information on compiling: https://github.com/spark/core-firmware
To transmit DMX you need an RS485-transceiver chip. Hooking up a MAX485 is simple:
Use the spark-cli tools to upload the firmware (typically stored in core-firmware.bin) to your spark core. Press and hold "MODE"-Button (also called USER-Button) while pressing "RESET". Release "MODE" button as soon as the core flashes yellow (takes approx 3 seconds).
# spark flash --usb core-firmware.bin
The Spark Core should boot automatically the new firmware.
To improve the stability of the firmware I disabled the Spark Cloud. To revert to any other firmware using Spark Cloud IDE you need to set SYSTEM_MODE to AUTOMATIC or flash any other Cloud-enabled firmware like Tinker:
# spark flash --usb tinker
- Spark Core port of DMX transmission is based on this project: https://github.com/KyotoFox/Spark-ArtNet-DMX
- DMX transmission is based on this repo: https://code.google.com/p/stm32-dmx512/