You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
error: 'U2TXD_OUT_IDX' was not declared in this scope #10
I'm trying to use this library with an esp32 Feather S2 from Unexpected Maker and I'm getting this issue when compiling the project.
SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp: In member function 'void SparkFunDMX::update()':
/SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp:127:31: error: 'U2TXD_OUT_IDX' was not declared in this scope
pinMatrixOutAttach(txPin, U2TXD_OUT_IDX, false, false);
^~~~~~~~~~~~~
SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp:127:31: note: suggested alternative: 'U1TXD_OUT_IDX'
pinMatrixOutAttach(txPin, U2TXD_OUT_IDX, false, false);
^~~~~~~~~~~~~
U1TXD_OUT_IDX
I'm having the same issue trying to use a SparkFun Thing Plus - ESP32-S2 WROOM with a SparkFun ESP32 Thing Plus DMX to LED Shield. In my case, I'm only trying to use the device to send and receive DMX commands. I am not controlling an LED fixture.
Have you found any workaround for this or does this issue mean that this library isn't compatible with the S2?
The library as it's written is not going to build for the S2. Either Sparkfun needs to update it or you need to make a copy and edit it to use U1TXD_OUT_IDX. I'm not sure if that's the only change needed to make it build and run correctly with an S2.
Thanks John. I did quickly try updating the U2TXD_OUT_IDX value in the SparkFunDMX.cpp to both U0TXD_OUT_IDX and U1TXD_OUT_IDX but unfortunately the solution wasn't that simple for my situation. It does compile but I suspect that changing the pin would cause it to no longer work on the DMX shield.
I tested this on both the S2 and also tried loading the alternate UARTs onto a tested & working SparkFun Thing Plus original but that broke the DMX. It's not worth me testing different pinning right now because just using another S1 board is easier.
If anyone at SparkFun reads this and this is truly a compatibility issue, it would be helpful to put a notice on the DMX Shield and S2's product pages that they will not be compatible. The product page currently shows this text, which would be inaccurate if this bug is hardware based:
The DMX to LED shield is designed to work with the SparkFun Thing Plus - ESP32 WROOM or any board with a Feather footprint, so Feathers and Feather-Wings will fit it.
Hi @raypp2,
We're looking into this, might be a longer to have a solution than we like,
but working on squeezing this into the work queue.
If you come up with a solution before we do, please put in a PR.
On Thu, Sep 21, 2023 at 6:55 PM raypp2 ***@***.***> wrote:
Thanks John. I did quickly try updating the U2TXD_OUT_IDX value in the
SparkFunDMX.cpp to both U0TXD_OUT_IDX and U1TXD_OUT_IDX but unfortunately
the solution wasn't that simple for my situation. It does compile but I
suspect that changing the pin would cause it to no longer work on the DMX
shield.
I tested this on both the S2 and also tried loading the alternate UARTs
onto a tested & working SparkFun Thing Plus original but that broke the
DMX. It's not worth me testing different pinning right now because just
using another S1 board is easier.
If anyone at SparkFun reads this and this is truly a compatibility issue,
it would be helpful to put a notice on the DMX Shield and S2's product
pages that they will not be compatible. The product page currently shows
this text, which would be inaccurate if this bug is hardware based:
The DMX to LED shield is designed to work with the SparkFun Thing Plus -
ESP32 WROOM or any board with a Feather footprint, so Feathers and
Feather-Wings will fit it.
—
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKLJJKFWZROCDH2VI35GDPLX3TAXLANCNFSM6AAAAAA4Z565PU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
I've created #11 that I think fixes compatibility with the ESP32-S2, as well as our USB-C version of the ESP32 Thing Plus (the pinout is slightly different).
I've not had a chance to test it. @raypp2 or @EdwardDeaver any chance you're able to try it out and let me know how it goes? If all is well, I can merge the pull request and publish a new release. Thanks!
I've tried this patch with the ESP32 Thing Plus, USB-C version, and unfortunately it's not working for me.
It may be another issue (since the only thing I have is the DMX shield and the board), but I suspect there's still a compatibility issue involved.
Thank you for testing! Sorry that it didn't fix it, I'll dig a bit deeper and try to resolve the problem once I have some hardware to play with, and time to play with it 🕐
Fyi -- Using the correct pins which are in the patch (Pin 4 - Enable, Pin 16 - RX, Pin 17 - TX), I got the board to work using the ESP32 Thing Plus, USB-C version, but not using the provided library. I've implemented the correct timings for detecting the start of data and the UART#2 to read the data packets. Thus, without going into "debugging mode" on the Sparkfun library, it seems to me that the problem is in the timings/timers/interrupts being used.
Snippet of my code (ugly, I know, but I was just trying to debug this):
// ...
uart.begin(DMX_BAUD, SERIAL_8N2, rx_pin, tx_pin);
bool good_start = false;
while (!good_start) {
// Wait while RX is HIGH (idle)while (digitalRead(rx_pin) == HIGH)
;
// We've detected RX became low, start counting timeunsignedlong t1 = micros();
// Now the signal needs to be low for at least 88 usecwhile (true) {
// If the signal becomes high before 88usec, it was a false start, if it continues low after that, it's a good startif (digitalRead(rx_pin) == HIGH) {
break;
}
unsignedlong t2 = micros();
if (t2-t1 >= 88) {
good_start = true;
break;
}
}
}
// Ok, we have a good start with RX still low. Let's continue to monitor until it becomes HIGHwhile (digitalRead(rx_pin) == LOW)
;
// Ok, RX is now HIGH, we can activate the UART for the rest of the decoding
uart.flush(false);
// Read the 512 channels// ....
E (31) timer_group: timer_init(275): HW TIMER divider outside of [2, 65536] range error
E (31) timer_group: timer_set_counter_value(86): HW TIMER NEVER INIT ERROR
E (35) timer_group: timer_start(97): HW TIMER NEVER INIT ERROR
E (40) timer_group: timer_isr_callback_add(227): HW TIMER NEVER INIT ERROR
E (47) timer_group: timer_set_alarm_value(155): HW TIMER NEVER INIT ERROR
E (53) timer_group: timer_set_auto_reload(132): HW TIMER NEVER INIT ERROR
E (60) timer_group: timer_set_alarm(179): HW TIMER NEVER INIT ERROR
Makes me wonder, did this ever work? Far as I can tell, the divider always needed to be at least 2 in the ESP-IDF, right? Idk. This library needs a serious overhaul, though I don't have time for that unfortunately.
I've pushed some commits to #11 that fix this, and some synchronization issues, and another spot where the UART number needed to be changed for the S2. I've got it working on my end with the ESP32 Thing Plus, ESP32 Thing Plus (USB-C), and ESP32-S2 Thing Plus.
@pjpmarques You mind testing it again quickly for me? Just want to make sure I've not broken anything 😉 If all is well, I'll merge it in.
I've tried the new code and it's not working for me. Not sure why, since it seems to be because of the time as you said. I've using the library as this (connected to a proper DMX512 show controller with 192 channels). The test code is as follows:
Hmm, that's odd. Could you please double check that you've correctly grabbed the code from #11? Do you happen to have 2 copies of this library downloaded? Also please try restarting Arduino. The fact that you're getting that error message indicates to me that Arduino is not compiling the latest code from #11
You are correct. Sorry, my fault (too tired). The build was grabbing the old library. Even so, with the new code it's not correctly reading from a "proper DMX controller". Here's what I get running the code (zeros in all channels):
@EdwardDeaver For reference, if it helps, here's the complete implementation of my library, which is reading correctly from the controller:
dmx.h
#pragma once
#include<HardwareSerial.h>
#defineDMX_MAX_CHANNEL512
#defineDMX_BAUD250000
#defineDMX_PROTOCOLSERIAL_8N2
#defineDMX_START_DELAY88// usec
#defineDMX_TIMEOUT25// msec
#defineDMX_RX_PIN16
#defineDMX_TX_PIN17
#defineDMX_EN_PIN4
#defineDMX_DEFAULT_UART2classDMX {
public:DMX();
DMX(int uart, int rx_pin, int tx_pin, int en_pin);
~DMX();
intupdate();
uint8_tread(int channel);
private:
HardwareSerial uart;
int rx_pin;
int tx_pin;
int en_pin;
uint8_t channel[DMX_MAX_CHANNEL+1] = {};
};
dmx.cpp
#include<Arduino.h>
#include<HardwareSerial.h>
#include<dmx.h>DMX::DMX(int uart_number, int rx, int tx, int en) :
uart(uart_number), rx_pin(rx), tx_pin(tx), en_pin(en) {
}
DMX::DMX() : DMX(DMX_DEFAULT_UART, DMX_RX_PIN, DMX_TX_PIN, DMX_EN_PIN) {
uart.setRxBufferSize(DMX_MAX_CHANNEL+1);
pinMode(en_pin, OUTPUT);
pinMode(rx_pin, INPUT);
}
DMX::~DMX() {
}
intDMX::update() {
uart.begin(DMX_BAUD, SERIAL_8N2, rx_pin, tx_pin);
uart.setTimeout(DMX_TIMEOUT);
digitalWrite(en_pin, LOW);
bool good_start = false;
while (!good_start) {
// Wait while RX is HIGH (idle)while (digitalRead(rx_pin) == HIGH)
;
// We've detected RX became low, start counting timeunsignedlong t1 = micros();
// Now the signal needs to be low for at least 88 usecwhile (true) {
// If the signal becomes high before 88usec, it was a false start, if it continues low after that, it's a good startif (digitalRead(rx_pin) == HIGH) {
break;
}
unsignedlong t2 = micros();
if (t2-t1 >= DMX_START_DELAY) {
good_start = true;
break;
}
}
}
// Ok, we have a good start with RX still low. Let's continue to monitor until it becomes HIGHwhile (digitalRead(rx_pin) == LOW)
;
// Ok, RX is now HIGH, we can activate the UART for the rest of the decoding
uart.flush(false);
// Read at most the 512+1 channels within the available timeout (at most 25msec)int channelsRead = uart.readBytes(channel, DMX_MAX_CHANNEL);
uart.end();
// Sanity check. Channel zero always needs to be zero.if (channel[0] != 0x00) {
return -1;
}
// All okreturn channelsRead;
}
uint8_tDMX::read(int channel_num) {
return channel[channel_num];
}
Darn, that's no good! Glad you have an actual DMX controller to test with though, that's helpful!
I wonder if it's a synchronization issue, and the first message is just getting missed or something. Are you just reading once? Are you able to get data if you keep reading in a loop?
So, I got fed up of trying to hack this library together and basically just rewrote the whole thing (see #12). It should be more platform agnostic (only tested with our ESP32 boards so far), and should be more robust (there could be some edge cases I've not considered). I've updated the first couple examples to demonstrate basic usage; it's fairly similar, but there are some bigger differences.
@pjpmarques Since you have an actual DMX controller, could you please test out #12? Should be able to use Example 2 with some modifications:
Change enPin to 4 for the ESP32 Thing Plus C
Change numChannels to 192
Read all 192 channels instead of just channel 1
The new library also allows you to copy the channels into an array with readBytes() if that's easier
@raypp2, @EdwardDeaver, and @romkey, I'd also appreciate if any of you have time to take a look and let me know if #12 seems better! In order to use the ESP32-S2 Thing Plus, you'll need to modify Examples 1 and 2 with the following (all before setup():
Change the dmxSerial definition to use UART 1 instead of 2
Hi @sfe-SparkFro, sorry for the delay. I've tried the new library and I'm getting the correct data from the DMX controller. Kudos for the change.
Nonetheless, I'm always getting this warning message in the beginning:
[ 32][E][HardwareSerial.cpp:554] setPins(): setPins() shall be called after begin() - nothing done
Here's an example of the complete output that shows the message and the modified example 2, reading in loop all the 192 channels being sent by the controller.
voidloop()
{
// Wait until data has been receivedwhile(dmx.dataAvailable() == false)
{
// Update must be called to update received data
dmx.update();
}
// Data has been received, read out all channelsuint8_t data[192];
dmx.readBytes(data, 192, 1);
for (int i=0; i<192; i++) {
if (i%32 == 0) {
Serial.printf("\n(%3d) ", i+1);
}
Serial.printf("%3d ", data[i]);
}
Serial.printf("\n");
delay(5000);
}
Hmm, I'm not receiving the same error on my end, but looks like I need to adjust where the UART pins are set. I'll fix that and clean up some other things, I think I can cut a new v2.0.0 release some time next week.
Stay tuned, and thanks again for your help in testing!
Activity
romkey commentedon Sep 15, 2023
U2TXD_OUT_IDXisn't defined on the ESP32 S2 because it only has two UARTS. Vanilla (original) ESP32 and ESP32-S3 CPUs both have three UARTs.raypp2 commentedon Sep 21, 2023
I'm having the same issue trying to use a SparkFun Thing Plus - ESP32-S2 WROOM with a SparkFun ESP32 Thing Plus DMX to LED Shield. In my case, I'm only trying to use the device to send and receive DMX commands. I am not controlling an LED fixture.
Have you found any workaround for this or does this issue mean that this library isn't compatible with the S2?
romkey commentedon Sep 21, 2023
The library as it's written is not going to build for the S2. Either Sparkfun needs to update it or you need to make a copy and edit it to use
U1TXD_OUT_IDX. I'm not sure if that's the only change needed to make it build and run correctly with an S2.raypp2 commentedon Sep 21, 2023
Thanks John. I did quickly try updating the
U2TXD_OUT_IDXvalue in the SparkFunDMX.cpp to bothU0TXD_OUT_IDXandU1TXD_OUT_IDXbut unfortunately the solution wasn't that simple for my situation. It does compile but I suspect that changing the pin would cause it to no longer work on the DMX shield.I tested this on both the S2 and also tried loading the alternate UARTs onto a tested & working SparkFun Thing Plus original but that broke the DMX. It's not worth me testing different pinning right now because just using another S1 board is easier.
If anyone at SparkFun reads this and this is truly a compatibility issue, it would be helpful to put a notice on the DMX Shield and S2's product pages that they will not be compatible. The product page currently shows this text, which would be inaccurate if this bug is hardware based:
brhoff720 commentedon Sep 22, 2023
Fix ESP32 compatibility issues
sfe-SparkFro commentedon Sep 29, 2023
Hi folks!
I've created #11 that I think fixes compatibility with the ESP32-S2, as well as our USB-C version of the ESP32 Thing Plus (the pinout is slightly different).
I've not had a chance to test it. @raypp2 or @EdwardDeaver any chance you're able to try it out and let me know how it goes? If all is well, I can merge the pull request and publish a new release. Thanks!
pjpmarques commentedon Sep 30, 2023
Hi,
I've tried this patch with the ESP32 Thing Plus, USB-C version, and unfortunately it's not working for me.
It may be another issue (since the only thing I have is the DMX shield and the board), but I suspect there's still a compatibility issue involved.
sfe-SparkFro commentedon Oct 2, 2023
Thank you for testing! Sorry that it didn't fix it, I'll dig a bit deeper and try to resolve the problem once I have some hardware to play with, and time to play with it 🕐
pjpmarques commentedon Oct 2, 2023
Fyi -- Using the correct pins which are in the patch (Pin 4 - Enable, Pin 16 - RX, Pin 17 - TX), I got the board to work using the ESP32 Thing Plus, USB-C version, but not using the provided library. I've implemented the correct timings for detecting the start of data and the UART#2 to read the data packets. Thus, without going into "debugging mode" on the Sparkfun library, it seems to me that the problem is in the timings/timers/interrupts being used.
Snippet of my code (ugly, I know, but I was just trying to debug this):
sfe-SparkFro commentedon Oct 2, 2023
Thanks for the code, that's helpful!
I've got some hardware and tinkered with it a bit today testing with Example 1 and 2. There was an issue with the timer here:
SparkFunDMX/src/SparkFunDMX.cpp
Line 70 in f8d1fdd
Makes me wonder, did this ever work? Far as I can tell, the
divideralways needed to be at least 2 in the ESP-IDF, right? Idk. This library needs a serious overhaul, though I don't have time for that unfortunately.I've pushed some commits to #11 that fix this, and some synchronization issues, and another spot where the UART number needed to be changed for the S2. I've got it working on my end with the ESP32 Thing Plus, ESP32 Thing Plus (USB-C), and ESP32-S2 Thing Plus.
@pjpmarques You mind testing it again quickly for me? Just want to make sure I've not broken anything 😉 If all is well, I'll merge it in.
pjpmarques commentedon Oct 2, 2023
I've tried the new code and it's not working for me. Not sure why, since it seems to be because of the time as you said. I've using the library as this (connected to a proper DMX512 show controller with 192 channels). The test code is as follows:
When the program starts, I get a timer error, saying it's not in range. Even though your code is setting it to 2.
And I've checked, your code is setting the divisor to 2:
Paulo
sfe-SparkFro commentedon Oct 2, 2023
Thanks Paulo, I appreciate your time on this!
Hmm, that's odd. Could you please double check that you've correctly grabbed the code from #11? Do you happen to have 2 copies of this library downloaded? Also please try restarting Arduino. The fact that you're getting that error message indicates to me that Arduino is not compiling the latest code from #11
pjpmarques commentedon Oct 2, 2023
Hi,
You are correct. Sorry, my fault (too tired). The build was grabbing the old library. Even so, with the new code it's not correctly reading from a "proper DMX controller". Here's what I get running the code (zeros in all channels):
While I should be getting something like this:
I have the ESP32 connected to a "MKP-DMX192" board. Photo in attachment.
pjpmarques commentedon Oct 2, 2023
@EdwardDeaver For reference, if it helps, here's the complete implementation of my library, which is reading correctly from the controller:
dmx.h
dmx.cpp
sfe-SparkFro commentedon Oct 3, 2023
Darn, that's no good! Glad you have an actual DMX controller to test with though, that's helpful!
I wonder if it's a synchronization issue, and the first message is just getting missed or something. Are you just reading once? Are you able to get data if you keep reading in a loop?
sfe-SparkFro commentedon Oct 3, 2023
So, I got fed up of trying to hack this library together and basically just rewrote the whole thing (see #12). It should be more platform agnostic (only tested with our ESP32 boards so far), and should be more robust (there could be some edge cases I've not considered). I've updated the first couple examples to demonstrate basic usage; it's fairly similar, but there are some bigger differences.
@pjpmarques Since you have an actual DMX controller, could you please test out #12? Should be able to use Example 2 with some modifications:
enPinto 4 for the ESP32 Thing Plus CnumChannelsto 192readBytes()if that's easier@raypp2, @EdwardDeaver, and @romkey, I'd also appreciate if any of you have time to take a look and let me know if #12 seems better! In order to use the ESP32-S2 Thing Plus, you'll need to modify Examples 1 and 2 with the following (all before
setup():dmxSerialdefinition to use UART 1 instead of 2rxPinto 33txPinto 34enPinto 3Thank you all!
pjpmarques commentedon Oct 5, 2023
Hi @sfe-SparkFro, sorry for the delay. I've tried the new library and I'm getting the correct data from the DMX controller. Kudos for the change.
Nonetheless, I'm always getting this warning message in the beginning:
Here's an example of the complete output that shows the message and the modified example 2, reading in loop all the 192 channels being sent by the controller.
Modified code for reference:
sfe-SparkFro commentedon Oct 5, 2023
Woo! Glad to hear it's working for you!
Hmm, I'm not receiving the same error on my end, but looks like I need to adjust where the UART pins are set. I'll fix that and clean up some other things, I think I can cut a new v2.0.0 release some time next week.
Stay tuned, and thanks again for your help in testing!
sfe-SparkFro commentedon Oct 12, 2023
FYI just made a v2.0.0 release. If you find any problems with it, please open a new issue. Thank you all for your help!
raypp2 commentedon Nov 4, 2023
Thanks for your hard work on this @sfe-SparkFro !
I don't have time to implement the new version right now into my code & test with the S2, but it's at the top of my roadmap. Here's the project I'm using this for:
https://github.com/raypp2/Apollo-Dmx-Bridge
lichtdefekte commentedon Mar 13, 2024
@raypp2 a Problem seems to persist on my Setup similar to yours (Thing Plus Wroom USB-C / SparkfunDMX).
I opened a diskussion on Arduino Forum:
https://forum.arduino.cc/t/sparkfun-dmx-to-led-shield-mit-esp32-thing-plus-c/1233050/2