Skip to content

ESP and DMX Library #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
folny opened this issue Aug 19, 2015 · 10 comments
Closed

ESP and DMX Library #712

folny opened this issue Aug 19, 2015 · 10 comments

Comments

@folny
Copy link

folny commented Aug 19, 2015

Hi

Someone worked with libraries to transfer DMX with Arduino ESP8266 example Conceptinetics, DMXSerial or DmxSimple or know someone how I could edit this library to run under the ESP https://github.com/mathertel/DmxSerial ?.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@mc-hamster
Copy link

DMX512 is just Asynchronous serial at 250,000 baud, 8 bits, no parity and 2 stop bits. 8n1 also works on the receive (don't try it on a sender). There's a short pause between packets.

You can use any serial library capable of those specs.

  • Jm

@folny
Copy link
Author

folny commented Aug 19, 2015

Thanks for responding

Can you tell me specifically which library I could use or a project that uses such a library ?.

@mc-hamster
Copy link

The esp8266 serial library can do this. Check the arduino website for docs on how it works.

  • Jm

@folny
Copy link
Author

folny commented Aug 20, 2015

Hi

In my case I need a DMX signal to send, here is the code which I tried but it did not work properly like I could do to make it work properly ?.

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

char ssid[] = "SSID";
char pass[] = "PASS";
WiFiUDP udp;
unsigned int localPort = 5568;

#define E131_BUFFER_SIZE 638

unsigned char E131Buffer[E131_BUFFER_SIZE];

void setup()
{
Serial.begin(250000,SERIAL_8N1);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
udp.begin(localPort);
}

int checkE131Headers(unsigned char* messagein, int messagelength)
{
if ( messagein[1] == 0x10 && messagein[4] == 0x41 && messagein[12] == 0x37)
{
int ChannelCount = messagein[123] * 256 + messagein[124];
return ChannelCount -1;
}
return 0;
}

void loop()
{
int packetSize = udp.parsePacket();
if(packetSize)
{
udp.read(E131Buffer,E131_BUFFER_SIZE);

int count = checkE131Headers(E131Buffer,E131_BUFFER_SIZE); 
if ( count ) //if it comes back genuine
{
  for(int i = 4; i < E131_BUFFER_SIZE; i++) 
 {
  Serial.write(E131Buffer[i]); 
 }
 Serial.flush();
}

}
}

@Rickgg
Copy link

Rickgg commented Nov 3, 2015

Hi, I am currently working on a DMX library. I haven't been able to test it because I lack the FTDI programmer, but by logic it should work.
If you test it I would be very happy if you posted results 😄

@bfranske
Copy link

bfranske commented Jan 5, 2016

FYI I have run some basic tests on Rickgg's DMX library (which he linked to above) using a NodeMCU ESP8266-12E based board and a TI SN75176BP RS485 driver chip. The library seems to work for DMX transmission from the ESP8266 using UART1, only tested with three DMX channels for right now.

@rgr101
Copy link

rgr101 commented Feb 16, 2016

Anyone who ever tried to run DMXSimple on the ESP8266?
Afaik, this lib uses just one digital i/o in conjunction with a very simply attached SN75176
and so communication may be easier than going through the serial interface?

@bfranske
Copy link

FYI There's nothing magical about the SN75176 that makes communication easier, it's a regular serial to RS-485 transceiver. If someone is using it with a regular digital I/O that's because they're using software serial instead of hardware serial, you could do the same thing with other DMX libraries as well. A disadvantage though is that DMX is fairly timing sensitive and you're likely to get better timing from a real UART interface than from bit-banging on a digital line. As far as using just one pin, that's simply a case of creating a transmit only interface, again other libraries can do the same thing if you're only transmitting DMX and don't need to receive DMX, the chip is just hardwired into always transmit mode.

@forkineye
Copy link
Contributor

The only tricky part is getting the DMX BREAK and MAB. The ESP has native break support though so it makes it easy. Just do the following before starting your 250k 8n2 stream:

/* UART for DMX output */
#define SEROUT_UART 1

/* DMX minimum timings per E1.11 */
#define DMX_BREAK 92
#define DMX_MAB 12

...
SET_PERI_REG_MASK(UART_CONF0(SEROUT_UART), UART_TXD_BRK);
delayMicroseconds(DMX_BREAK);
CLEAR_PERI_REG_MASK(UART_CONF0(SEROUT_UART), UART_TXD_BRK);
delayMicroseconds(DMX_MAB);
...

Full implementation here - https://github.com/forkineye/ESPixelStick. You'll want to look at SerialDriver.*

@devyte
Copy link
Collaborator

devyte commented Oct 20, 2017

Closing per #3655 .

@devyte devyte closed this as completed Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants