Html data exchange help

Joined
Dec 27, 2019
Messages
2
Reaction score
0
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);
Serial.println(adc);
server.send(200, "text/plane",adc); //sends data to server
}

And
HTML.file
<script>
setInterval(function() {
GetADC();
}, 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
}
};
xhttp.open("GET", "/getADC", true);
xhttp.send();
}

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!!!!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top