Arduino_Scuola
Published © CC BY-SA

YunServer: Sensor Values To HTML Page

Send sensor values to a web page using YunServer.

IntermediateProtip19 minutes13,122
YunServer: Sensor Values To HTML Page

Things used in this project

Hardware components

Arduino Yun
Arduino Yun
×1
Micro SD card 2GB with SD adaptor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Arduino Code

Arduino
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h> 
YunServer server;

void setup() {
  Bridge.begin();
  server.listenOnLocalhost();
  server.begin();
}
void loop() {
  YunClient client = server.accept();
  if (client) {
    String command = client.readString();
    command.trim();
    if (command == "temperature") {
      int val = analogRead(A1);
      client.print(val);
    }
    client.stop();
  }
  delay(50);
}

Credits

matlo

Posted by Arduino_Scuola

Comments