I am currently working on a project where I need to receive DMX512 data from a standard DMX lighting controller using an STM32G030K8T6TR microcontroller. I am using the Arduino IDE with the STM32 board support package.
Hardware Configuration
- Microcontroller: STM32G030K8T6TR
- UART Pins: PA10 (RX) for receiving DMX data
- Direction Control: PA8 used to control the DE/RE pin of the RS485 transceiver (set LOW for receiving)
- RS485 Transceiver: THVD1400DR
- DMX Source: Standard DMX512 lighting controller
What I Have Tried
I have tested several DMX libraries, including:
- DMXSerial,
- DMXSerial2,
- DMXSimple.
Unfortunately, most of these libraries are designed for AVR architecture and include AVR-specific headers such as <avr/interrupt.h>
, which are not compatible with STM32.
Additionally, the libraries I found either support only transmission or fail to function properly for receiving on STM32 targets. I am simply looking for a method or library that will allow me to receive DMX512 channel data on the STM32G030K8T6TR using the Arduino IDE environment. Any guidance, working examples, or recommendations for compatible libraries would be highly appreciated.
-
2\$\begingroup\$ Why do you need to use some mystical 3rd party libraries to receive DMX? If you use STM32, are you using C or assembly or some other language, and are you using STM32 HAL for UART, no libraries, or Zephyr or what? This isn't really an electrical engineerinh issue, but more like under what software framework you want to work with to use UART to receive DMX. Edit: Just saw, you want to use Arduino framework. Maybe Arduino.SE is more suitable place to ask then. Personally, I would use something else. \$\endgroup\$Justme– Justme2025年05月26日 11:22:30 +00:00Commented May 26 at 11:22
-
\$\begingroup\$ Starting point: github.com/mathertel/DmxSerial2/issues/31 \$\endgroup\$winny– winny2025年05月26日 13:08:57 +00:00Commented May 26 at 13:08
1 Answer 1
DMX512 is really not a hard-to-implement protocol, especially if you only need to receive. Just configure your UART for around 250 kbd, and the right framing. You might need to wait in software for the "break" condition, and then enable the UART. Plenty of time for that.
There's really several existing STM32 implementations, most of which should work directly on STM32G0. I'm not going to assess them for you, but here's three from my first page of search results (your search results will look different):
- https://github.com/aleksandrgilfanov/stm32-dmx-receiver
- https://github.com/carl3721/stm32-dmx512/blob/master/dmx-p103/src/main.c
- https://www.st.com/en/evaluation-tools/steval-ill030v1.html (official eval kit – where did you look if you didn't find this?)
-
\$\begingroup\$ Yes, but are they compatible with the Arduino framework? The OP didn't clearly say if he is open to bear metal or if he wants to use the Arduino framework, no matter what... But my personal feeling is that it is required to be Arduino compatible. \$\endgroup\$Blup1980– Blup19802025年05月26日 12:55:45 +00:00Commented May 26 at 12:55
-
\$\begingroup\$ the Arduino framework doesn't take much ownership of anything unless you tell it to, so, yes, this should not be a problem (and if it becomes a problem, comment out the offending code in Arduino; there's really no much sensible other way than to use an UART to receive UART, so if Arduino can't work with the UART peripheral...) (also, arduino is not the right software platform for this, but that's a more overarching issue) \$\endgroup\$Marcus Müller– Marcus Müller2025年05月26日 13:34:42 +00:00Commented May 26 at 13:34
-
1\$\begingroup\$ @Blup1980 Does Arduino framework allow triggering on the Break UART frame? If not, the libraries are MCU-specific and need to be written for specific Arduino platform by essentially replacing the UART library with a better one, and at that point, why bother with Arduino any more, if the stuff you want to do are so complex Arduino can't handle it out-of-the-box. After getting STM32 HAL up and running with UART, writing an interrupt based reception handler that triggers on Break frames is a no-brainer. \$\endgroup\$Justme– Justme2025年05月26日 15:35:39 +00:00Commented May 26 at 15:35
-
\$\begingroup\$ @Justme I agree 100%. I personally almost always work with the HAL with help of CubeMX. But the OP seems to be interested in Arduinos, and if we provide answers that are incompatible with that framework, it might miss the point of the OP. \$\endgroup\$Blup1980– Blup19802025年05月27日 11:41:03 +00:00Commented May 27 at 11:41
-
\$\begingroup\$ @Blup1980 also agreed, but if Arduino can't let a user use the UART, then Arduino simply won't help the user – any other Arduino solution would then just go ahead and disable Arduino's control of the UART just as much \$\endgroup\$Marcus Müller– Marcus Müller2025年05月27日 11:54:59 +00:00Commented May 27 at 11:54