0
votes

I want to make a simple project using ESP8266 and led strip ws2812, and I want to control it from web page. Is it possible to get variables from page index ? Right now I have only simple code to turn on/off it. After enter:

http://192.168.0.17/off

leds turns off.

else if (readString.indexOf("off") != -1) {
//turn off leds

I want to update my code and I am trying to get RGB values. for example, is it possible to get RED, GREEN, BLUE values from index like this?

    http://192.168.0.17/150RED_0GREEN_150BLUE

// here i want to get variables like: 
    int RED_val = 150;
    int GREEN_val = 0;
    int BLUE_val = 150;

To make my led strip pink, and other colors.

3
This needs a lot more information. What is the code for the server with the route to /off? Use that template for /red and /greenVincent Rodomista

3 Answers

0
votes

The right way would be to use POST instead of GET (url), since you're 'updating data on the server'.

But when using a GET (via url) you could use parameters:

http://192.168.0.17/setcolor?r=10&g=20&b=30

And then just read those values into variables.

0
votes

If you really want to dig into that working with WS2812 and ESP8266 start with one of the examples that use the FastLed library.
WS2812 and ESP8266 - A good starting point is this repo
Learn about setting up webservers what is the difference between GET, POST, PUT, DELETE, ...
and eventually you will end up digging into HTML, CSS and vanilla javascript while trying to improve your C/C++ skills for the Arduino/ESP world.

0
votes

I think that I have found solution - ESP8266WebServer. For example, right now after calling 'setcolor'(check it below) I can input parameters using url. And it looks like : 192.168.0.17/setcolor?pixel_num=1&red=255&blue=0&green=0 for red color on LED number 1 (2nd one on the strip)

server.on("/setcolor", setPix);


void setPix(){
  String n = server.arg("pixel_num");  
  String r = server.arg("red");
  String g = server.arg("green");
  String b = server.arg("blue");
  strip.setPixelColor(n.toInt(),r.toInt(),g.toInt(),b.toInt());}

Thank you for help.