B4R Library rConceptinetics

This is a B4R Library to control LED lights using the DMX512 protocol.
The library rConceptinetics is partially wrapped and enhanced from this GitHub project.

Test Setup Example (DMXController)
An Arduino MEGA with Arduino DMX Shield runs a B4R program listening to serialized data holding the commands to set the light(s) value 0-255 for a selected channel.
The serialized data is set by a B4J application.
The Arduino MEGA is used because it has more then 1 serial port and 2 serial ports are required.

1717327103527.png


Hardware
  • 1x Arduino MEGA
  • 1x CQRobot DMX Shield MAX485 for MCU
  • 1x LED Mini Flat Par Light LSPA36RC (DMX512 with 3-7 channels)
  • 1x Adam Hall Cables 3 STAR DMF 0600 DMX Cable 3-Pol XLR Female auf 3-Pol XLR male 6 m
  • 1x Adam Hall Connectors 3 STAR DMX T 3 XLR Cable 3-Pol woth 120OHM resistor
Arduino MEGA Serial
In order to use the Serial on the MEGA For debug and leave the Serial1 for the DMX Shield change the Conceptinetics.h file inside the library rConceptinetics.
CPP:
// Define which serial port To use As DMX port, only one can be selected at the time by uncommenting one of the following lines
//#define USE_DMX_SERIAL_0
#define USE_DMX_SERIAL_1
//#define USE_DMX_SERIAL_2
//#define USE_DMX_SERIAL_3

Arduino MEGA and DMX Shield Pin Mapping
Import is to connect the Arduino MEGA Serial 1 pins to the DMX Shield.
MEGA = DMX Shield
RX1 GPIO19 = 3 (Orange)
TX1 GPIO18 = 4 (Blue)

DMX Shield Jumper Setting
Looking from the DMX shield bottom with X2 at the left side:
EN,DE Master,TX-io,RX-io

B4R Example Code
Show how to init and use the methods from the library rConceptinetics.
B4R Example Code:
Sub Process_Globals
    Public Serial1 As Serial
    'DMX object from the library rConceptinetics.
    Private dmx_master As DMXMaster
    'Channels - can also use instead the defaults from the library
    Private DIMMER As Byte = dmx_master.CHANNEL_DIMMER
    Private Const RED = 2, GREEN = 3, BLUE = 4 As Byte
End Sub

Private Sub AppStart
    'IMPORTANT - the dmx master has to be initialized prior Serial1
    dmx_master.Initialize(10, dmx_master.RXEN_PIN)

    'Init serial1 and asyncstream to handle channel commands
    Serial1.Initialize(115200)

    'Set Channel 1 DIMMER @ 50%
    dmx_master.SetChannelLevel(DIMMER, 50)
    'or use dmx_master.SetChannelValue(1, 127)
    Log("SetChannelLevel(DIMMER, 50)")

    'Set Channel 2 RED @ low 10% (=255 / 10)
    dmx_master.SetChannelValue(RED, 25)
    Log("SetChannelValue(RED, 25)")
    Delay(2500)

    'Turn channel RED off
    dmx_master.SetChannelValue(RED, 0)

    'Set Channel 3 GREEN @ mid 50%
    dmx_master.SetChannelLevel(GREEN, 50)
    Log("SetChannelLevel(GREEN, 50)")
    Delay(2500)

    'RGB on   
    dmx_master.SetRGB(RED,GREEN,BLUE,10,20,30)
    Log("SetRGB(RED,GREEN,BLUE,10,20,30)")
    Delay(2500)

    'RGB off
    dmx_master.SetRGBOff(RED,GREEN,BLUE)
    Log("SetRGBOff(RED,GREEN,BLUE)")

End Sub

ToDo
  • DMX Input Listener
 

Attachments

  • rConceptinetics.zip
    34.9 KB · Views: 86

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20240602 - Example DMX RESTful Server Ethernet

Purpose

To control DMX lights from client applications sending commands to the Arduino DMX Controller via HTTP and Ethernet connection.

Concept
An Arduino MEGA + Ethernet Shield + DMX Shield runs an B4R program acting as an HTTP RESTful server.
The RESTful server listens for commands send via HTTP GET requests from clients like B4A-App, B4J-App, Browser, Node-RED, Python.
The HTTP GET request arguments (must be lowercase!):
  • channel=1-512 (mandatory)
  • value=0-255 (mandatory)
  • disconnect=0 or 1 (optional, default 1 = disconnect after executing command)
The disconnect argument can be used to keep a connection until closed by the client,
else socket connection made, channel and value set and socket connection is closed.
HTTP GET Request:
http://dmx-controller-ip/channel=1-512&value=0-255&disconnect=0|1

Example Browser HTTP GET Request
Control an LED with address 1 and the 4 channels Dimmer-RED-GREEN-BLUE.
The address applies to the first channel as set on the LED:
The LED has on the back a digital display with 4 setting button which is set to DMX Mode d0001.
Note: The connection is disconnected (argument disconnect=1) after every command.

Hardware
  • 1x Arduino MEGA
  • 1x Arduino Ethernet Shield with W5100 chip
  • 1x CQRobot DMX Shield MAX485 for MCU
  • 1x LED Mini Flat Par Light LSPA36RC (DMX512 with 3-7 channels)
  • 1x Adam Hall Cables 3 STAR DMF 0600 DMX Cable 3-Pol XLR Female auf 3-Pol XLR male 6 m
  • 1x Adam Hall Connectors 3 STAR DMX T 3 XLR Cable 3-Pol woth 120OHM resistor
Software
  • B4R 4.0 - DMX Controller
  • B4R Additional Library rConceptinetics 0.5
  • B4J 10.0 - DMX Client Non-UI, UI
  • Node-RED 3.1.9 - Tested with a simple flow using HTTP Request Nodes (flow not included)
Notes
  • For more information, see README.md of the rConceptinetics library.
  • This RESTful server concept could also be used for other applications.
Arduino MEGA + Ethernet Shield + DMX Shield
1717576819419.png


B4J UI Application
1717576760276.png
 

Attachments

  • DMXRESTServer.zip
    12.2 KB · Views: 108
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20240607 - Example DMX RESTful Server WiFi

Purpose

To control DMX lights from a desktop application sending commands to an Arduino DMX RESTful Server via HTTP and WiFi connection.

Concept
An ESP8266 LOLIN(WeMos) D1 R1 [ESP8266] runs a B4R program acting as an HTTP RESTful server (DMXServer).
The ESP8266 is connected to the Arduino MEGA and communicates via SoftSerial.
The Arduino MEGA + Arduino DMX shield runs an B4R program listening to DMX commands from the ESP8266 (DMXController).
The data sent from the ESP8266 is serialized and contains the 2 objects channel and value to control the LED light.

The RESTful server listens for commands send via HTTP GET requests from clients like B4J-App, Browser, Node-RED, Python.
See previous post DMX RESTful Server Ethernet on how to set HTTP commands.

Hardware
  • 1x Arduino MEGA
  • 1x CQRobot DMX Shield MAX485 for MCU
  • 1x WeMOS D1 R1 (ESP8266)
  • 1x LED Mini Flat Par Light LSPA36RC (DMX512 with 3-7 channels)
  • 1x Adam Hall Cables 3 STAR DMF 0600 DMX Cable 3-Pol XLR Female auf 3-Pol XLR male 6 m
  • 1x Adam Hall Connectors 3 STAR DMX T 3 XLR Cable 3-Pol with 120OHM resistor
Software
  • B4R 4.0 - DMXServer ESP8266
  • B4R 4.0 - DMXController Arduino MEGA
  • B4R Additional Library rConceptinetics 0.5
  • B4J 10.0 - DMXClient UI with CustomView SliderLevel to control a DMX channel value
Wiring
Arduino MEGA = ESP8266
B4X:
Pin 5v = 5v
Pin GND = GND
Pin 52 RX = D2 TX (Blue)
Pin 53 TX = D1 RX (Green)
Note: ESP8266 B4R Program: When running, the Arduino MEGA provides the ESP8266 with power & ground.

Arduino MEGA = DMX Shield
B4X:
Pin 18 TX1 = 3 RX (Blue)
Pin 19 RX1 = 4 TX (Green)

Notes
  • For more information, see README.md of the rConceptinetics library.
  • This HTTP RESTful server concept could also be used for other applications.
Arduino MEGA + DMX Shield + ESP8266 WeMos D1 Mini
1717746804388.png


B4J UI DMX Client with CustomView SliderLevel
1717746879668.png

Note:
The customview SliderLevel uses JavaObjects to access slider properties.
The slider level 0-100 is mapped to channel value 0-255.

ToDo
  • Use this example as a base for the board "WeMOS Mega + WiFi R3 ATmega2560 + ESP8266 USB-TTL for Arduino Mega NodeMCU".
  • Create an ArtNet DMX Controller.
 

Attachments

  • DMXRESTServerWiFi.zip
    18.3 KB · Views: 107
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20240612 - Example DMX Controller BLE

Purpose

To control DMX LED lights from a desktop application sending commands via Bluetooth Low Energy (BLE).

Concept
An ESP32-WROOM-32 (ESP32) runs a B4R program as the DMX BLE Controller (with identifier DMXBLECONTROLLER).
The ESP32 waits for BLE client connections and listens to BLE payload received.
The ESP32 is connected via its Serial2 port to an Arduino MEGA Serial2 port.
The ESP32 parses the payload received into 2 objects channel,value and sends the objects serialized to the Arduino MEGA.
The Arduino MEGA + Arduino DMX shield, as the DMX Controller, sets the LED channel and value (brightness) via an B4R program.

Data Objects
  • channel=1-512 (mandatory)
  • value=0-255 (mandatory)
Hardware
  • 1x Arduino MEGA
  • 1x CQRobot DMX Shield MAX485 for MCU
  • 1x ESP-32S USB C Developmentboard (ESP32)
  • 1x LED Mini Flat Par Light LSPA36RC (DMX512 with 3-7 channels)
  • 1x Adam Hall Cables 3 STAR DMF 0600 DMX Cable 3-Pol XLR Female auf 3-Pol XLR male 6 m
  • 1x Adam Hall Connectors 3 STAR DMX T 3 XLR Cable 3-Pol woth 120OHM resistor
Software
  • B4R 4.0 - DMXBLEController ESP32
  • B4R 4.0 - DMXController Arduino MEGA
  • B4R Additional Library rConceptinetics 0.5
  • B4J 10.0 - DMXClient UI with CustomView SliderLevel to control a DMX channel value
  • Python 3.10.11, Thonny 4.1.4 - Used by the B4J DMXClient
Wiring
Serial Connection: ESP32 = Arduino MEGA

HTML:
Pin RX2 GPIO16 = TX2 GPIO16 (GREEN)
Pin TX2 GPIO17 = RX2 GPIO17 (BLUE)
For both controllers the onboard port Serial2 are used.
Power Supply: ESP32 = Arduino MEGA
On the ESP32S development board, the jumper 3.3V-5V is changed from 3.3V to 5V.
The power is supplied to the ESP32S development board either USB or external 9V.
HTML:
Pin 5V = VIN (RED)
Pin GND = GND (BLACK)
DMX: Arduino MEGA = DMX Shield
HTML:
Pin 18 TX1 = 3 RX (Blue)
Pin 19 RX1 = 4 TX (Green)
Arduino MEGA Serial0 port used for logging, Serial1 port used for the DMX shield.
Clients
The BLE connection has been tested initially with the Android App Serial Bluetooth Terminal 1.47.
After selecting the device with identifier DMXBLECONTROLLER, send string 1,100 (channel dimmer level 100) followed by 2,100 (channel red level 100) to check if LED lights RED.

A B4J UI test application, DMX Client, has been created based on the previous shared DMXRESTServerWiFi example.
This B4J UI DMX client uses an external Python script (dmxbleinterface.py) to handle BLE communication with the DMX BLE Controller (ESP32).
The Python script is located in the same folder as the dmxclient.jar.
The data flow:
B4J DMX Client > Python Script BLE Connection to DMXBLEController (ESP32)
B4J DMX Client > set channel,value > send channel,value > Python Script BLE data handling > DMXBLEController
DMXBLEController > parse string channel,value > serialize data > DMXController (Arduino MEGA)
DMXController > deserialize data > set DMX channel & value

Any BLE client can be used.

Notes
  • For more information, see README.md of the rConceptinetics library.
  • This BLE concept could also be used for other applications.
Hardware Arduino MEGA+Arduino DMX Shield, ESP32S + Developmentboard
1718213745591.png

The ESP32S provides the Arduino MEGA/Shield with power.
Communication between ESP32S and Arduino MEGA via both Serial2 Ports.

B4J UI DMX Client
1718213898564.png

BLE Communication between B4J UI and the ESP32 via external Python script.
The B4J CustomView SliderLevel has been enhanced by handling the onMouseRelease event, to
only set the channel value if the mouse is released from the slider (Property ValueChanging).

ToDo
  • Develop B4A DMX BLE client.
  • B4J UI DMX Client replace external Python script if suitable B4J BLE library available.
  • Node-RED client.
 

Attachments

  • DMXControllerBLE.zip
    26.1 KB · Views: 125
Last edited:
Top