• Okay, so I've opted for the "net" module instead as a socket server. It's much, much, much faster! I can easily do 50ms now without issues.

    var esp8266 = require("ESP8266");
    
    function onInit() {
      var ssid = "SSID";
      var wifiOpts = {
        password: "PASSWORD"
      };
      var wifi = require("Wifi");
      wifi.connect(ssid, wifiOpts, function(err) {
        console.log("connected? err=", err, "info=", wifi.getIP());
        require("net").connect({host: "192.168.1.209", port: 8001}, function(socket) {
          console.log("Connected");
    
          var arr = "";
          socket.on("data", function(data) {
            arr += data;
            if(arr.slice(-2) == "]]") {
              data = JSON.parse(arr);
              esp8266.neopixelWrite(NodeMCU.D2, data);
              arr = "";
            }
          });
        });
      });
    }
    
    save();
    

    I had to hack it up a bit, because I send so many characters. I saw that the socket.on("data") got hit way too many times. Apparently it either receives or sends in chunks of ~260 characters, so I simply add those to a string, check if the last two characters are ]] (meaning my 2D array is complete) and then JSON.parse() it.

    Works amazingly fast!

About