Html data exchange help

Discussion in 'HTML and CSS' started by Xtech007, Jan 2, 2020.

  1. Xtech007


    Dec 27, 2019
    Likes Received:
    Hi all !!
    I need help.
    This project uses a Nodemcu (esp8266 WiFi)
    HTML, CSS, and JavaScript.

    This is what the project does:
    A potentiometer is attached to the Nodemcu adc port, when pot is moved the needle on a gauge moves according to the reading.

    The html is also served from within the Nodemcu.
    In the ino. File the function looks like this:
    void handleADC(){
    int a = analogRead(A0);
    a = map(a,0,1023,0,100);
    String adc = String(a);
    server.send(200, "text/plane",adc); //sends data to server

    setInterval(function() {
    }, 1000);

    function GetADC() {
    var xhttp = new XMLHttpRequest();
    var adc=0;
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    adc = Number(this.responseText);
    document.getElementById("demo").innerHTML = adc;
    gaugePS.value = adc; //send DATA to needle
    };"GET", "/getADC", true);

    That works great!
    But now I want to use a sensor that uses RS485
    And the sensor gives out a response of multiple bytes exp; 01 03 08 00 64 00 3E 00 0D 00 55 9C E8.

    This is where I'm stuck.
    How can I send this data to the server as a string?
    Or do each byte have to be sent individually?
    Any guidance is appreciated!!!!
    Xtech007, Jan 2, 2020
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.