Using a slider to control a servo works fine, except the position of the slider is in the browser slow in updating.
The error message I receive in the VS terminal is: “ERROR: Too many messages queued”.
It looks like the Websocket software is not fast enough to follow the movement of the slider.
Does anyone know how to solve this?
A modified 4_4 Multiple Web_Pages example I have used.
How can I send main.cpp and data files, in case you want to check?
In Arduino IDE I made a simialr program with 4 sliders for servo’s and 4 schwitchs on 1 webpage.
This worked much better. I did notice that if I keep the mouse button pressed during moving the slider and release it at the desired position, it worked nicely.
But for a good feel moving a servo one would like to move the slider and the servo moves at the same pace, unilyou release the mouse button.
Hi.
To share your code use a link to github gist or pastebin.
What event are you using on the slider? onmousemove, ounmousedown, or other?
Regards,
Sara
I did use the example code:
<p class=”switch_slider”>
<input type=”range” onchange=”updateSliderPWM(this)” id=”slider1″ min=”0″ max=”100″ step=”1″ value =”0″ class=”slider”>
<output class=”bubble”></output>
</p>
When I add onmousemove=”updateSliderPWM(this)” this makes no difference in behaviour.
Looking for a solution I found some code here: https://css-tricks.com/value-bubbles-for-range-inputs/
Below the slider I get now a number that changes real time when I move the slider.
Now I try to find a way to use this number to pass to the ESP32. But htlm, css, javescript is quite new to me so that is quite a puzzle.
(Where can I find info hwo to use the picture, code inserts functions.)
I made an extension of example 2_4 extending it from 1 to 4 sliders. This extended page I added in example 4_4 Multiple webpages. However using the temperature and humidity reading sometimes interfere in slider oparatiron, so I removed this sensor pages. The sliders werk OK, except of the error message “ERROR: Too many messages queued”. Another example using Arduino IDE very similar worked well, except the positon was passed to the servo after releasing the silder. WHat I found was that in this example in the HTML code was used <input type=”range” onchange=updateSliderPWM(this)”…. >. In the 2_4 eample was used <input type=”range” oninput=updateSliderPWM(this)”…. >, this last wat results in immediate update of the value and the servo moves as you move the slider withour releasing it. However the browser does not update fast enough and you get an error message and the slider pin (thumb) moves irrigular if you move fast. If you move slow it behaves better, probably less data/sec. Maybe using Serial.println(..) if new data are available slows down the messaging but that will no make the slider faster. If anyone konws a way that the slider thumb if updated faster I would like to know.
Hi.
If the slider moves too fast and sends requests in all values that will crash the ESP32 because “too many requests”.
Have you tried increasing the step of the slider, so it doesn’t send soo many requests between values?
Regards,
Sara
For the multiple slider page I used an example from you of ESP32_MUltiple_Slider_Webserver.
In there was in the script.js this code:
function onMessage(event) {
console.log(event.data);
var myObj = JSON.parse(event.data);
var keys = Object.keys(myObj);
for (var i = 0; i < keys.length; i++){
var key = keys[i];
document.getElementById(key).innerHTML = myObj[key];
document.getElementById(“slider”+ (i+1).toString()).value = myObj[key];
}
}
If I change that into (code of example 2_4_Output_Slider_PWM_Websockets)
function onMessage(event) {
console.log(event.data);
}
The 4 sliders on 1 webpage work perfectly. No error mesages any more.
This subject can be closed.