` 1. 温湿度传感器,接arduino ;
2. arduino接入OneNet并把温湿度值通过调用OneNet的api写入到OneNet;
3. 然后写个web页面通过Api把值取出来显示。
下面是arduino的代码,很简单。 #include #include "DHT.h" #define DHTPIN A1 #define LED_PIN 13 #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); void setup() { Bridge.begin(); Console.begin(); Console.println("DHTxx test!"); dht.begin(); } void loop() { delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); float f = dht.readTemperature(true); if(isnan(h) || isnan(t) || isnan(f)) { Console.println("Failed to read from DHT sensor!"); return; } float hi = dht.computeHea tindex(f, h); digitalWrite(LED_PIN, HIGH); String cmd("curl " "--request POST " "--header "api-key: 为自己设备的API-Key="" "--header "Host: api.heclouds.com" " "--connect-time 3 " "--max-time 5 " "--data "{"datastreams":" "[{"id":"temp","datapoints":[{"value":"+ String(t) +"}]},{"id":"hum","datapoints":" "[{"value":" + String(h) + "}]}]}"" ""地址""); Process p; p.runShellCommand(cmd); while(p.running()); digitalWrite(LED_PIN, LOW); Console.print("Humidity: "); Console.print(h); Console.print(" % "); Console.print("Temperature: "); Console.print(t); Console.print(" *C "); Console.print(f); Console.print(" *F "); Console.print("Heat index: "); Console.print(hi); Console.println(" *F"); }
板子图片
监控界面
OneNET是一个物联网云平台,通过restful协议可以实现数据上传展示和消息路由等功能。 这里可以看到实时数据 open.iot.10086.cn/cmiotapp/envmonitor/viewnew?ai_id=13 里面案例可以看到实时的监测数据
`
|