SENSORS.HTM пример моей странички с комментариями
Код: Выделить всё
<script>
function start() {
document.getElementById("hider-2").style.display = "none";
logoRotator();
getDashData();
getValue();
}
var hideInfo1 = false;
var hideInfo2 = true;
function showHide1() {
if (hideInfo1) {document.getElementById("hider-1").style.display = "block"; hideInfo1 = false;}
else {document.getElementById("hider-1").style.display = "none"; hideInfo1 = true;}
}
function showHide2() {
if (hideInfo2) {document.getElementById("hider-2").style.display = "block"; hideInfo2 = false;}
else {document.getElementById("hider-2").style.display = "none"; hideInfo2 = true;}
}
var ghvalue = ["tempDHT", "humDHT", "indexDHT", "tempBMP", "pressBMP"];
function getValue() {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseXML != null) {
// net activ
insertTick(30, bufferCpuLoad2);
for (var i = 0; i < ghvalue.length; i++) {
try {
var temp = this.responseXML.getElementsByTagName(ghvalue[i])[0].childNodes[0].nodeValue;
} catch (err) {
temp = "-1";
}
try {
document.getElementById(ghvalue[i]).innerHTML = temp;
} catch (err) { }
}
}
} //if (this.responseXML != null)
} // if (this.status == 200)
} // if (this.readyState == 4)
request.open("GET", "request_climate" + randomNoCache(), true);
request.send(null);
setTimeout('getValue()', 3000);
}
%# // scripts.js (mode one)
</script>
на Arduino добавить отправку данных на запрос (в моем случает "GET", "request_climate")
Код: Выделить всё
else if (StrContains(HTTP_req, "request_climate")) {sendXmlAnswer(cl); responseClimate(cl);}
Код: Выделить всё
void responseClimate(EthernetClient cl) {
String s = tagXmlVersion();
s += openInputs();
s += makeTag("hum_gr", "", String(hum_gr));
s += makeTag("humDHT", "", String(dht1h));
s += makeTag("tempDHT", "", String(dht1t));
s += makeTag("indexDHT", "", String(dht1hic));
s += makeTag("pressBMP", "", String(bmp180press));
s += makeTag("tempBMP", "", String(bmp180temp));
s += closeInputs();
cl.println(s);
}