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