• 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 week 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
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 week 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 week 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 5 days ago

Please share a link to GitHub.
Regards,
Sara

0 Vote Up Vote Down
paulfjujo answered 3 days ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 4 hours 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

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 eBook Released] Learn Raspberry Pi Pico/Pico W with MicroPython March 2, 2024
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook (version 2.2) September 20, 2023

You must be logged in to view this content.

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

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