Page 361 - Tasarım Beceri Atölyeleri Öğretmen El Kitabı
P. 361
sensors.begin();
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
server.beginWebSocket(“thermometer”);
Serial.print(“WebSocket server address : “);
Serial.println(Phpoc.localIP());
}
void loop() {
// when the client sends the first byte, say hello:
PhpocClient client = server.available();
if (client) {
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
String txtMsg = String(temp) + “\r\n”;
char buf[txtMsg.length()];
txtMsg.toCharArray(buf, txtMsg.length());
server.write(buf, txtMsg.length());
delay(300);
}
}
353