sending 512 rgb pixels to ESP 32 as a ZIGZAG strip of two 256 leds. RESOLVED
Hello,
I have an offset with datas received in ESP32
Below I want to control one strip of 256 leds.
Here I send 768 datas (RGB) + 1 datas ( "the row" where pixels will be controlled)

Here what I receive into the Esp32

As we can see, I receive several time r,g ,b and after there is an offset with datas.
I tested to send less datas, but it doesn't change the bug.
When these bugs are fixed, I would like to send with row 0 the R,G,B data to leds 0 to 255 and with row 1 to leds 256 to 512. (when there are two lines at [jit.noise 3 char 256 2])
Thanks a lot for your help !
Here the Arduino code
#include <WiFi.h>
#include <WiFiUdp.h>
#include "esp_wifi.h"
WiFiUDP Udp;
const unsigned int localPort = 8009; // UDP Port
IPAddress local_IP(192, 168, 0, 9);
IPAddress gateway(10, 10, 10, 1);
IPAddress subnet(255, 255, 0, 0);
#define LED_BUILTIN 16
#define BUILTIN_LED LED_BUILTIN
#include <FastLED.h>
#define NUM_LEDS 256
#define PIN_CONTROLLING_STRIP 23
CRGB leds[NUM_LEDS];
uint8_t buffer[769];
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA); esp_wifi_set_ps(WIFI_PS_NONE); WiFi.config(local_IP, gateway, subnet);Udp.begin(localPort);
WiFi.begin("SFR-d078", "DEDW3VPARYGZ");// SSID & password
Serial.println("IP address: ");Serial.println(WiFi.localIP()); Serial.print("Local port: ");Serial.println(localPort);
FastLED.addLeds<NEOPIXEL, PIN_CONTROLLING_STRIP>(leds, NUM_LEDS); FastLED.setBrightness(180);
for (int i = 0; i <= NUM_LEDS; i++) {leds[i] = CRGB(0, 0, 0); // turn off all
FastLED.show();}
}
void loop() {Udp.parsePacket(); if(Udp.read(buffer, 769) > 0) {showit();Serial.println();}}
void showit(){int row = buffer[768]; Serial.print("row "); Serial.println(row);
for (int j = 0; j < 768; j++) {int pix = (j/3); // 768/3=256 led.
int r = (buffer[pix]); int g = (buffer[pix+1]); int b = (buffer[pix+2]);
Serial.print ("r "); Serial.print (r); Serial.print ( " g "); Serial.print (g); Serial.print (" b "); Serial.print (b);}
}
I am not using Arduino 2, so can't help you with that.
beside that, zl.len shows only 256 because ????

In same patch you use this

In arduino,
IP 192.168.0.9
gateway 10.10 10. 1 ??? doesn't fit.
if you want to print all 768 ints to check if you received them,
then print them in one go without any letters.
If all ok, remove that print stuff and control the leds.
I have fixed bugs at the end of Arduino code!!
for (int j = 0; j < 768; j++) {int pix = (j/3); // 768/3=256 led.
int r = (buffer[pix]); int g = (buffer[pix+1]); int b = (buffer[pix+2]);
I change theses lines with
for (int j = 0; j < 256; j++) {
r = (buffer[j*3]); g = (buffer[j*3+1]); b = (buffer[j*3+2]);
It works very well !!!
Now, when there are twos line in jit.noise, I have to send the row 0 to the led 0 to 256 and the row 1 to 256 to 512.
How could I change my Arduino code ? if row ==0 do something? if row== 1 do something ?
18:23:08.006 -> row 0
18:23:08.006 -> r 216 g 135 b 247 r 242 g 129 b ...
18:23:08.358 -> row 1
18:23:08.358 -> r 148 g 207 b 168 r 109 g 97 b ....
First data sfrom Max are going in row 1. Last datas are going to row 0
Everything works! Thanks for your help ;)
But maybe Arduino code could be better ?!
How can we transform RGB datas to unint8 color?
Is there a different library (not FastLed) to control led ?
Below, how I send twice 256 led from 512 RGB pixels arranged as a zigzag

Here Arduino code for ESP 32
#include <WiFi.h>
#include <WiFiUdp.h>
#include "esp_wifi.h"
char ssid[] = "MERCUSYS_RE_13CF";
char pass[] = "Poiuytreza8@";
WiFiUDP Udp;
const unsigned int localPort = 8009; // UDP Port
IPAddress local_IP(192, 168, 0, 9);
IPAddress gateway(10, 10, 10, 1);
IPAddress subnet(255, 255, 0, 0);
#define LED_BUILTIN 16
#define BUILTIN_LED LED_BUILTIN
#include <FastLED.h>
#define NUM_LEDS 512
#define PIN_CONTROLLING_STRIP 23
CRGB leds[NUM_LEDS];
char buffer[769];
int row;
int r, g, b;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA); esp_wifi_set_ps(WIFI_PS_NONE); WiFi.config(local_IP, gateway, subnet);Udp.begin(localPort);
//WiFi.begin("SFR-d078", "DEDW3VPARYGZ");// SSID & password
WiFi.begin("MERCUSYS_RE_13CF", "Poiuytreza8@");
Serial.println("IP address: ");Serial.println(WiFi.localIP()); Serial.print("Local port: ");Serial.println(localPort);
FastLED.addLeds<NEOPIXEL, PIN_CONTROLLING_STRIP>(leds, NUM_LEDS); FastLED.setBrightness(180);
for (int i = 0; i <= NUM_LEDS; i++) {leds[i] = CRGB(0, 0, NUM_LEDS-(i+1)); // turn off all
FastLED.show();}
}
void loop() {Udp.parsePacket(); if(Udp.read(buffer, 769) > 0) {showit();Serial.println();}}
void showit(){row = buffer[768]; Serial.print("row "); Serial.println(row);
if (row==0){
for (int j = 0; j < 256; j++) { //256 led.
r = (buffer[j*3]); g = (buffer[j*3+1]); b = (buffer[j*3+2]);
leds[j] = CRGB(r, g, b);
FastLED.show();}
}
if (row==1){
for (int j = 0; j < 256; j++) { //256 led.
r = (buffer[j*3]); g = (buffer[j*3+1]); b = (buffer[j*3+2]);
leds[j+256] = CRGB(r, g, b);
FastLED.show();}
}
}
I can't give you answers to arduino 2 or higher and whatever libs.
fastled used to work fine in older arduino.
"How can we transform RGB datas to unint8 color?"
I don't understand that question.
You allready send r g b as 8bit numbers, or ?
I don't know if reducing arduino code to this would bring any improvement
#include <WiFi.h>
#include <WiFiUdp.h>
#include "esp_wifi.h"
WiFiUDP Udp;
const unsigned int localPort = 8009;
IPAddress local_IP(192, 168, 0, 9);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 0, 0);
#include <FastLED.h>
#define NUM_LEDS 512
#define PIN_CONTROLLING_STRIP 23
CRGB leds[NUM_LEDS];
uint8_t buffer[769];
void setup() {
WiFi.mode(WIFI_STA); esp_wifi_set_ps(WIFI_PS_NONE); WiFi.config(local_IP, gateway, subnet);
WiFi.begin("SFR-d078", "DEDW3VPARYGZ"); Udp.begin(localPort); // SSID & password
FastLED.addLeds<NEOPIXEL, PIN_CONTROLLING_STRIP>(leds, NUM_LEDS); FastLED.setBrightness(180);
for (int i = 0; i <= NUM_LEDS; i++) {leds[i] = CRGB(0, 0, 0); // turn off all
FastLED.show();}
}
void loop() {Udp.parsePacket();
if(Udp.read(buffer, 769) > 0) {int row = buffer[768];
for (int j = 0; j < 256; j++) {int pix = (j*3 + row*256);
int r = (buffer[pix]); int g = (buffer[pix+1]); int b = (buffer[pix+2]);
leds[j + row*256] = CRGB(r, g, b); FastLED.show();}
}}
Hi,
Thank you for the code.
I have a last question. In order to send the minimum amount of data possible, I would like to convert the data from cells that come from [jit.matrix] directly to hexdecimal. How can I do this?
sprintf %02X for single int
now depends if you want to iter that all or
sprintf %02X%02X%02X
depends how you want to parse that in arduino.
Ok. Thanks again.
To control the library fasted directly with hexadecimal (no need to convert to rgb in Esp32), I have to convert in Max/Msp rgb to uint16 then to hexadecimal. So to control 256 led, i have 256 hexadecimal.

I will receive in Esp 32 data like this
2 22 42 62 81 99 B9 D9 D9 BA 9A 82 62 42 22 2 2 22 42 62 82 9A BA DA
So, i think i will send these datas directly with OSC [Udpsender] or with [sadam.upSender] , then in the Esp32, i will have to split hexadecimal data. I will have to assign every separated data with a space to a LED. I hope you 'll can help to process these hexadecimal data in Arduino.
Maybe you should start from other side,
Learn how to control the LED stripes in arduino,
and decide what color mode to use.
then decide about sending values from max
and what fits best your choice of ESP32 wireless.
Otherwise you will allways ask for help here
or elsewhere.
I simply have no time to teach you all that.
look at few of past threads rotating allways the same problemtic:
compare the difference between raw RGB888 bytes using sadam
and whatever else sent by udpsend.
how many bytes really need to travel?
there is actually no need to hex whatever.
you can send RGB565 uint16 as 2 8bit numbers and convert that to RGB888
in arduino.
which would reduce sent bytes by 1/3 .

Hi,
I would like to control one strip of 256 or 512 or 768 or 1024 leds as fast as possible?
I checked the library FastLed we can control led directly with Hexadecimal but we can't use directly int 8 or int 16. Otherwise we have to convert int to rgb in Esp 32.
I think sending and receiving hexadecimal will be faster than sending unit 16 and convert it to r,g,b in Esp32.
I like the manner to send one line of 256 datas, then one line of 256 ... until a fourth.
I manage to convert data as RGB 565 but I get lost by the arrangement of the data to make a zigzag, as my strip is. I have divided / 3 [zl.group] and [zl.slice] but it's not good.
I worked with chat gpt, and I can receive block of 127 hexadecimal. So I don't know if receiving two blocks of R, G, B datas is not faster than receiving 4 blocks of Hexadecimal datas
So I let the code here, to find it later, when I will mange to change the MAX/msp patch into RGB 565 then Hexa.
For the moment, your last Arduino code posted on JUN 18, 2025 AT 7:47 AM, is totally good!!
Thank u!
#include <WiFi.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <FastLED.h>
#define NUM_LEDS 512
#define PIN_CONTROLLING_STRIP 23
CRGB leds[NUM_LEDS];
// WiFi config
const char* ssid = "MERCUSYS_RE_13CF";
const char* password = "Poiuytreza8@";
// OSC config
WiFiUDP Udp;
const unsigned int localPort = 8009;
IPAddress local_IP(192, 168, 0, 9);
IPAddress gateway(10, 10, 10, 1);
IPAddress subnet(255, 255, 0, 0);
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.config(local_IP, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connecté !");
Serial.println(WiFi.localIP());
Udp.begin(localPort);
Serial.printf("OSC en écoute sur le port %d\n", localPort);
FastLED.addLeds<NEOPIXEL, PIN_CONTROLLING_STRIP>(leds, NUM_LEDS);
FastLED.setBrightness(180);
FastLED.clear();
FastLED.show();
}
void loop() {
OSCMessage msg;
int size = Udp.parsePacket();
if (size > 0) {
while (size--) {
msg.fill(Udp.read());
}
if (!msg.hasError()) {
msg.route("/leds/0", handleLEDRange0);
msg.route("/leds/128", handleLEDRange128);
msg.route("/leds/256", handleLEDRange256);
msg.route("/leds/384", handleLEDRange384);
}
}
}
// Fonctions pour chaque tranche de 128 LEDs
void updateLEDRange(OSCMessage &msg, int addrOffset, int startIndex) {
int count = min(msg.size(), 128);
for (int i = 0; i < count; i++) {
if (!msg.isInt(i)) continue;
uint32_t color = msg.getInt(i) & 0xFFFFFF;
int ledIndex = startIndex + i;
if (ledIndex < NUM_LEDS) {
leds[ledIndex] = color;
// check if r,g,b match with Hexadecimal
uint8_t r = (color >> 16) & 0xFF;
uint8_t g = (color >> 8) & 0xFF;
uint8_t b = color & 0xFF;
Serial.printf("LED %03d → #%02X%02X%02X\n", ledIndex, r, g, b);
}
}
FastLED.show();
}
void handleLEDRange0(OSCMessage &msg, int addrOffset) { updateLEDRange(msg, addrOffset, 0); }
void handleLEDRange128(OSCMessage &msg, int addrOffset) { updateLEDRange(msg, addrOffset, 128); }
void handleLEDRange256(OSCMessage &msg, int addrOffset) { updateLEDRange(msg, addrOffset, 256); }
void handleLEDRange384(OSCMessage &msg, int addrOffset) { updateLEDRange(msg, addrOffset, 384); }