• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Extending Build WebServers course example 4_4 with sliders

Q&A Forum › Category: ESP32 › Extending Build WebServers course example 4_4 with sliders
0 Vote Up Vote Down
Dick van de Wetering asked 3 years ago

I worked through the course “Build Web Servers”, and I want to extend the example 4.4  of Multiple Web Page, with an extra web page with a slider. Finally the slider of example 2.4 was added. However to get it realy working I get error messages like: E (25176) gpio: gpio_set_level(226): GPIO output gpio_num error
Probably this error comes from two voids in the main.cpp with the same name handleWebSocketMessage(..) used for the outputs and for the slider. This probably mixes up data, resulting in the LED’s connected to the outputs go onn/off when I move the slider, as well as the error message comes up in the Serial Monitor.
How can I pass information from outputs (switches) and sliders, without interfering?
 

Question Tags: Multiple Webs Pages, slider
2 Answers
0 Vote Up Vote Down
Dick van de Wetering answered 3 years ago

After studying a project “ESP32_Nultiple_Sliders_Web_Server, I was finally able to make the project working for 3 servo’s. The intention was to oparate 4 servo’s but maybe the traffic and memory was short a I used SD car, OLED ssd1306, 4 switches and a DHT22. After removing SD card operations, 1 servo and increasing the DHT time interval from 10 to 60 sec, the system works. 
Because I use switches and sliders, the handleWebSocketMessage had to be changed, see piece of code below.
 

// outputs and slider
void handleWebSocketMessage(void *arg, uint8_t *data, size_t len) {
  AwsFrameInfo *info = (AwsFrameInfo*)arg;
  // sliders
  if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT) {
    data[len] = 0;
    message = (char*)data;
    if (message.indexOf(“1s”) >= 0) {
      sliderValue1 = message.substring(2);
      dutyCycle1 = map(sliderValue1.toInt(), 0, 100, 0, 180);
      notifyClients(getOutputStates(),getSliderValues());
    }
    if (message.indexOf(“2s”) >= 0) {
      sliderValue2 = message.substring(2);
      dutyCycle2 = map(sliderValue2.toInt(), 0, 100, 0, 180);
      notifyClients(getOutputStates(),getSliderValues());
    }    
    if (message.indexOf(“3s”) >= 0) {
      sliderValue3 = message.substring(2);
      dutyCycle3 = map(sliderValue3.toInt(), 0, 100, 0, 180);
      notifyClients(getOutputStates(),getSliderValues());
    }
    /*
    if (message.indexOf(“4s”) >= 0) {
      sliderValue3 = message.substring(2);
      dutyCycle3 = map(sliderValue4.toInt(), 0, 100, 0, 180);
      notifyClients(getOutputStates(),getSliderValues());
    }
    */
    if (strcmp((char*)data, “getValues”) == 0) {
      notifyClients(getOutputStates(),getSliderValues());
    }

  // Outputs
    if (strcmp((char*)data, “states”) == 0) {
      notifyClients(getOutputStates(),getSliderValues());
    }
    else{
      int gpio = atoi((char*)data);
      digitalWrite(gpio, !digitalRead(gpio));
      notifyClients(getOutputStates(),getSliderValues());
    }
  }
}

 
Hopefully this is helpfull for anyone who wants to combine outputs and sliders.
This question can be closed. 

Start your code here
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great!
I’m glad you were able to solve the issue by yourself.
Thank you so much for sharing the code.
 
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.