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
The ESP32S provides the Arduino MEGA/Shield with power.
Communication between ESP32S and Arduino MEGA via both Serial2 Ports.
B4J UI DMX Client
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.