Connect to websocket on ESP8266

Is it possible?
Yes it is, and mostly because of the good eye of dceejay.
So this is solved, althrough it could use some tweaking at the time.
For now, I think it would not hurt to leave it here.

I was, but still am wondering about this and maybe my fantasies is going to wild here... but maybe.

I have an ESP8266 with a RGB controller on it. Nothing fancy.
It has a webpage on it to control the RGB.


The RGB lamp works perfect with the websocket library on it.!

A websocket.js file is containing the JavaScript code
websocket_js_file
Part of the code for sending after hitting a button.
send_example

Is it possible to make something with Node-RED to control it?
A button on the dashboard to set it on or off, or maybe even change the color!?
I tryed the websocket node like this,
node-red_test1
but, sure I am doing something wrong.
I treid to follow a few examples on the web, maybe it's the language barrier, I can not find a way to set this up.
Anybody an idea what I must do?
Thanks in advance.

In your js code you have image
and in your Node-RED example you have port 1881, and your web page just shows lol05.local - so which port is that ? so one or other isn't correct.

1 Like

Good eye.
In the sketch for the ESP8266 it creates a websocket on port 81.
websocket_port

One of the many examples (don't now the link any more) it was an advice to put 18 before the used port! I was wondering myself WHY? but it could not hurt to try.
Sorry that I have left it there.
At the same time I treid it without the 18 and it just works.
Great. But stupid me that I didn't see that any more.
Thanks man.

1 Like

The main reason for not using ports below 1024 is that, on most servers, they require admin/root permission to handle the port. That is one of the reasons that Node-RED uses a port above 1024.

Doesn't apply of course on such a simplistic device as the ESP8266.

1 Like