Diese Variante des LightwallController nutzt/ stellt folgende Schnittstellen bereit:
- USB-UART
- DMX
Es muss außerdem der Microkontroller mit 5V über USB versorgt werden. Der Fullcircle-DMX RJ45 Stecker benötigt dessweiteren 12V.
Schnittstellen
- 2xUSB
- USB-UART (Steuerung des Mikrocontrollers)
- Spannungsversorgung des Mikrocontrollers
- 12V
- RJ45 DMX-Fullcircle Ausgang
Komponenten
Dieses Projekt greift auf folgende Komponenten zurück:
- STM32F4 Discovery Board
- LightwallController#DMX-Shield
- Splitpeater
- Splipeater GIT-Version cec779f28e (als Variante 1)
- Lightwallcontroller Firmware
Firmware
Hardware-Dokumentation
-
Orginal geäztes DMX-Shield
-
Fliegender Nachbau
-
Splipeater mit 12V-Anschluss
-
Gehäuseseite mit RJ45-DMX und 12V-Eingang
-
Gehäuseseite USB-UART und USB für Spannungsversorgung
Mqtt
import mosquitto, os, socket, time, re
from threading import Thread
- File: /usr/local/sbin/lighttile2mqtt.py
TCP_IP = '127.0.0.1'
TCP_PORT = 2002
BUFFER_SIZE = 1024
reLightColor = re.compile("[0-9A-F]{6}")
- Prometheus
- mqttBroker="10.23.42.31"
- BigBrother
mqttBroker="10.23.43.191"
mypid = os.getpid()
client = mosquitto.Mosquitto("RoomLights"+str(mypid))
pollerState = True
oldStates = None
t = None
def processState(ls):
lightnr=1
global oldStates
for light in ls:
if oldStates is None or light != oldStates[lightnr - 1]:
if light == "000000":
light = "off"
client.publish("/room/lighttiles/%s/state" % lightnr, light, 0, True)
lightnr+=1
oldStates = ls
- Light ist das licht 1-6
- State ist h oder l
def switchLight(light, state):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
if state == "off":
state = "000000"
s.send("rgb write %s %s %s %s\r\n" % (light-1, int(state[:2],16), int(state[2:4],16), int(state[4:],16)))
time.sleep(0.1)
data = s.recv(BUFFER_SIZE)
s.close()
processState(getStates())
def getStates():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send("\r\n")
time.sleep(0.1)
data = s.recv(BUFFER_SIZE)
s.send("dmx show\r\n")
time.sleep(0.1)
data = s.recv(BUFFER_SIZE).replace("\r", "").split("\n")[2]
if len(data) < 36:
s.send("rgb write 5 0 0 0\r\n")
time.sleep(0.1)
data = s.recv(BUFFER_SIZE)
s.send("dmx show\r\n")
time.sleep(0.1)
data = s.recv(BUFFER_SIZE).replace("\r", "").split("\n")[2]
s.close()
return (data[:6], data[6:12], data[12:18], data[18:24], data[24:30], data[30:])
def on_connect(rc):
print("Connected with result code "+str(rc))
client.subscribe("/room/lighttiles/+/command")
processState(getStates())
def on_message(userdata, msg):
topic = msg.topic.strip("/").split("/")
lightNr = int(topic[2])
message = str(msg.payload)
if lightNr >= 1 and lightNr <= 6 and (message == "off" or reLightColor.match(message)):
switchLight(lightNr, message)
def on_disconnect(userdata):
#print "Disconnect"
pass
client.on_connect = on_connect
client.on_message = on_message
- client.on_disconnect = on_disconnect
client.will_set('/room/lighttiles/daemon/state', 'offline', 0, True)
while True:
print "Connect..."
client.connect(mqttBroker, 1883, 60, True)
client.publish('/room/lighttiles/daemon/state', 'online', 0, True)
while client.loop() == 0:
pass
print "Reconnecting..."
time.sleep(60)