Art-Net Sender/Receiver for Arduino (Ethernet, WiFi)
This is a fork of ArtNet repository with added support for Industruino.
Below is a copy of the read me from the master repo.
NOTE : BREAKING API CHANGES (v0.2.0 or later)
- Art-Net with both Ethernet and WiFi
- Support a lot of boards which can use Ethernet or WiFi
- Multiple receiver callbacks depending on universe
- Mutilple destination streaming with sender
- One-line send to desired destination
- Flexible net/subnet/universe setting
- Easy data forwarding to FastLED
- ESP32
- ESP8266
- Arduino Uno WiFi Rev2
- Arduino MKR VIDOR 4000
- Arduino MKR WiFi 1010
- Arduino MKR WiFi 1000
- Arduino Nano 33 IoT
- Almost all platforms without WiFi
This library has following Art-Net controller options. Please use them depending on the situation.
- ArtnetReveiver
- ArtnetSender
- Artnet (Integrated Sender/Receiver)
#include<Artnet.h>
ArtnetReceiver artnet;
voidcallback(constuint8_t* data, constuint16_t size) {
// you can also use pre-defined callbacks
}
voidsetup() {
// setup Ethernet/WiFi...
artnet.begin(); // waiting for Art-Net in default port// artnet.begin(net, subnet); // optionally you can set net and subnet here
artnet.subscribe(universe1, [](constuint8_t* data, constuint16_t size) {
// if Artnet packet comes to this universe(0-15), this function is called
});
artnet.subscribe(universe2, callback); // you can also use pre-defined callbacks
}
voidloop() {
artnet.parse(); // check if artnet packet has come and execute callback
}#include<Artnet.h>
ArtnetSender artnet;
voidsetup() {
// setup Ethernet/WiFi...
artnet.begin();
}
voidloop() {
// change send data as you want
artnet.send("127.0.0.1", universe15bit, data_ptr, size); // one-line send// artnet.send("127.0.0.1", net, subnet, univ, data_ptr, size); // or you can set net and subnet
artnet.streaming_data(data_ptr, size);
artnet.streaming("127.0.0.1", universe15bit); // automatically send set data in 40fps (15bit universe)// artnet.streaming("127.0.0.1", net, subnet, univ); // or you can set net and subnet here
}#include<Artnet.h>
Artnet artnet;
voidsetup()
{
// setup Ethernet/WiFi...
artnet.begin(); // send to localhost and listen to default port// artnet.begin(net, subnet); // optionally you can set net and subnet here
artnet.subscribe(universe, [&](constuint8_t* data, constuint16_t size) {
// if Artnet packet comes to this universe, this function is called
});
artnet.subscribe([&](constuint32_t univ, constuint8_t* data, constuint16_t size) {
// if Artnet packet comes, this function is called to every universe
});
}
voidloop() {
artnet.parse(); // check if artnet packet has come and execute callback// change send data as you want
artnet.send("127.0.0.1", universe15bit, data_ptr, size); // one-line send// artnet.send("127.0.0.1", net, subnet, univ, data_ptr, size); // or you can set net and subnet
artnet.streaming_data(data_ptr, size);
artnet.streaming("127.0.0.1", universe15bit); // automatically send set data in 40fps (15bit universe)// artnet.streaming("127.0.0.1", net, subnet, univ); // or you can set net and subnet here
}#include<Artnet.h>
ArtnetReceiver artnet;
// FastLED
#defineNUM_LEDS1CRGB leds[NUM_LEDS];
constuint8_tPIN_LED_DATA = 3;
voidsetup() {
// setup Ethernet/WiFi...// setup FastLED
FastLED.addLeds<NEOPIXEL, PIN_LED>(&leds, NUM_LEDS);
artnet.begin();
// if Artnet packet comes to this universe, forward them to fastled directly
artnet.forward(universe, leds, NUM_LEDS);
// this can be achieved manually as follows// artnet.subscribe(universe, [](uint8_t* data, uint16_t size)// {// // artnet data size per packet is 512 max// // so there is max 170 pixel per packet (per universe)// for (size_t pixel = 0; pixel < NUM_LEDS; ++pixel)// {// size_t idx = pixel * 3;// leds[pixel].r = data[idx + 0];// leds[pixel].g = data[idx + 1];// leds[pixel].b = data[idx + 2];// }// });
}
voidloop() {
artnet.parse(); // check if artnet packet has come and execute callback
FastLED.show();
}- You can set Net (0-127) and Sub-Net (0-15) like
artnet.begin(net, subnet) - Universe (0-15) can be set in
artnet.subscribe(universe, callback), - Callbacks are limited to 4 universes (depending on the spec of Art-Net)
artnet.begin(net, subnet); // net and subnet can be set only once
artnet.subscribe(univ1, callback1); // 4 callbacks can be set
artnet.subscribe(univ2, callback2); // these universes are reported to
artnet.subscribe(univ3, callback3); // Art-Net controller if it polls
artnet.subscribe(univ4, callback4); // Art-Net devicesartnet.send(ip, univ15bit, data, size); // use 15bit universer or
artnet.send(ip, net, subnet, univ, data, size); // net, subnet, and universeartnet.streaming_data(data, size); // set data first
artnet.streaming(ip, univ15bit); // stream to 15bit universe or
artnet.streaming(ip, net, subnet, univ); // net, subnet, and universe- This library supports
ArtPollandArtPollReply ArtPollis automatically parsed and sendsArtPollReplynet_swsub_swsw_inetc. are set automatically based on registerd callbacks- You can configure the information of
ArtPollReplyas followsvoid shortname(const String& sn)void longname(const String& ln)void nodereport(const String& nr)
// streaming packetvoidstreaming_data(constuint8_t* const data, constuint16_t size);
voidstreaming_data(constuint16_t ch, constuint8_t data);
voidstreaming(const String& ip, constuint32_t universe_);
voidstreaming(const String& ip, constuint8_t net_, constuint8_t subnet_, constuint8_t universe_);
// one-line sendervoidsend(const String& ip, constuint32_t universe_, constuint8_t* const data, constuint16_t size);
voidsend(const String& ip, constuint8_t net_, constuint8_t subnet_, constuint8_t universe_, constuint8_t* const data, constuint16_t size);
// othersvoidphysical(constuint8_t i);
uint8_tsequence() const;OpCode parse();
// subscriberstemplate <typename F> inlineautosubscribe(constuint8_t universe, F&& func);
template <typename F> inlineautosubscribe(constuint8_t universe, F* func);
template <typename F> inlineautosubscribe(F&& func);
template <typename F> inlineautosubscribe(F* func);
// for FastLEDinlinevoidforward(constuint8_t universe, CRGB* leds, constuint16_t num);
// unsubscribeinlinevoidunsubscribe(constuint8_t universe);
inlinevoidunsubscribe();
inlinevoidclear_subscribers();
// ArtPollReply informationvoidshortname(const String& sn);
voidlongname(const String& ln);
voidnodereport(const String& nr);
// othersinlineconst IPAddress& ip() const;
uint16_tport() const;
String id() const;
uint16_topcode() const;
uint16_topcode(constuint8_t* p) const;
uint16_tversion() const;
uint8_tsequence() const;
uint8_tphysical() const;
uint8_tnet() const;
uint8_tsubnet() const;
uint8_tuniverse() const;
uint16_tuniverse15bit() const;
uint16_tlength() const;
uint16_tsize() const;
uint8_t* data();
uint8_tdata(constuint16_t i) const;Some boards without enough memory (e.g. Uno, Nano, etc.) may not be able to use integrated sender/receiver because of the lack of enough memory. Please consider to use more powerful board or to use only sender OR receiver.
MIT