• 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

ESP32 bad slider reading

Q&A Forum › Category: ESP32 › ESP32 bad slider reading
0 Vote Up Vote Down
paulfjujo asked 1 year ago

hello, i try to combine 5 charts + 4 gauges + 1 slider to adjust a PWM value I cant get the slider value ..error messages given in console one from index.html , the other from Script.js i don’t know where to search the issue…

slider problemo

index.html side :
Led Bleue (15)
PWM 15 :
%

script.js side:

function getCurrentValue1() {
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(‘pwmSlider1’).value = this.responseText
document.getElementById(‘textSliderValue1’).innerHTML = this.responseText
}
}
xhr.open(‘GET’, ‘/currentValue1’, true)
xhr.send()
}

function updateSliderPWM() {
var sliderValue1 = document.getElementById(‘pwmSlider1’).value
document.getElementById(‘textSliderValue1’).innerHTML = sliderValue1
console.log(‘update sliderValue1 : ‘)
console.log(sliderValue1)
// websocket.send(‘1s’ + sliderValue1.toString())
websocket.send(‘1s’ + sliderValue1)
}

Question Tags: slider
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
Is this the complete javascript code?
Can you share the complete code?
From that error code, it seems that websocket was not defined previously…
Regards,
Sara
 

0 Vote Up Vote Down
paulfjujo answered 1 year ago

hello Sara,
Thank’s for  your answer.
all into this link , wich describe the project and program sources *.ino, *.js 
projet ESP32
 

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Please share a link to GitHub.
Regards,
Sara

0 Vote Up Vote Down
paulfjujo answered 1 year ago

hello,
i opened a github here:  link   
schematics, and zip file of the project

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
You have this function to initialize websockets, but it is never called:

function onload(event) {
initWebSocket()
getCurrentValue1()
}

Change this:

window.addEventListener('load', getReadings)

to the following, so that the onload function is called at startup.
 

window.addEventListener('load', onload)

Then, if you also want to get readings, you need to add the getReadings function to the onload function too:
 

function onload(event) {
initWebSocket()
getReadings()
getCurrentValue1()
}

Regards,
Sara

0 Vote Up Vote Down
paulfjujo answered 1 year ago

hello Sarah,
Thank’ a lot
it is working fine now
i can get back the Slider value to drive my PWM Output…

 

so,can be marked as solved

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.