I have about 150 LEDs in a strip. I want to change those colors, based on patterns I write externally (in a browser for example). I send the 2D array like this:
[[255, 255, 255], [255, 0, 0], [255, 255, 255]]
and so on from my NodeJS server running the "ws" module as a server. The ESP8266 NodeMCU then connects to the NodeJS server, and waits for it to send the RGB colors for all these LEDs.
The problem occurs when I want to send the RGB codes for all 150 LEDs at once. This takes 1000-1500 milliseconds and it simply queues them up. If I keep it running for 30-60 seconds, then disconnect my NodeJS server, it will keep changing the colors on the LED strip, because it keeps the colors in a queue (because it's too slow?) .
I am running this on a local network and here is my Espruino code:
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());
var ws = connect();
ws.on('open', function() {
console.log("Connected");
});
ws.on("message", function(msg) {
msg = JSON.parse(msg);
esp8266.neopixelWrite(NodeMCU.D2, msg);
});
});
}
function connect() {
var WebSocket = require("ws");
var host = "192.168.1.209";
return new WebSocket(host, {
path: '/',
port: 8001,
protocolVersion: 13,
origin: 'Espruino',
keepAlive: 60,
});
}
save();
Any clue what could be wrong? Is 1800 characters simply too much?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I have about 150 LEDs in a strip. I want to change those colors, based on patterns I write externally (in a browser for example). I send the 2D array like this:
and so on from my NodeJS server running the "ws" module as a server. The ESP8266 NodeMCU then connects to the NodeJS server, and waits for it to send the RGB colors for all these LEDs.
The problem occurs when I want to send the RGB codes for all 150 LEDs at once. This takes 1000-1500 milliseconds and it simply queues them up. If I keep it running for 30-60 seconds, then disconnect my NodeJS server, it will keep changing the colors on the LED strip, because it keeps the colors in a queue (because it's too slow?) .
I am running this on a local network and here is my Espruino code:
Any clue what could be wrong? Is 1800 characters simply too much?