首页 文章

Arduino以太网

提问于
浏览
0

我想将传感器收集的数据发送到我用Java创建的Web服务器 .

例如,我想发送一个简单的整数 1 ,例如当传感器的温度超过阈值时作为第一次测试,但我不知道如何 . 我设法做了其他事情,我的意思是将Arduino作为服务器,并通过键入我分配给董事会的IP地址从浏览器中查看这些结果,但我真正感兴趣的是发送数据而不是看到它们 . 我怎么做?一个小例子是什么?

我已经尝试过EthernetClient类,但我不能做我想要的:(

2 回答

  • 0

    只需发送GET . 例如, www.yourwebsite.com/arduinoreader.php?sensor=on .

  • 1

    有's a good example on the Arduino website that shows exactly how to do this. Essentially you' ll调用 client.connect("www.xxx.xxx", 80) ,其中 clientEthernetClient 类的对象,然后使用 client.println() 发送GET请求 . 您实际上将自己发送HTTP标头和数据,但此页面将向您展示如何在“代码”部分中执行此操作:https://www.arduino.cc/en/Tutorial/WebClient .

    在该示例中,您可以使用以下内容替换 client.println("GET /search?q=arduino HTTP/1.1");

    client.print("GET /api?temp=");
    client.print(TEMP_VALUE);
    client.println(" HTTP/1.1");
    

相关问题