我的项目图不显示我的频道

7视图(30天)
Bibhanshu
Bibhanshu 2023年1月8日
#包括<二氢睾酮。h > / /包括图书馆对于dht
#包括< ESP8266WiFi.h >
字符串apiKey = " xxxxxxxxxxxxxxxx ";/ /输入写从ThingSpeak API密匙
常量char *名称=“名称”;/ /替换为你的无线网络名称和wpa2的关键
常量char *通过=“@pwd”;
常量char *服务器= " api.thingspeak.com ";
#定义DHTPIN0/ /销dht11连接的地方
二氢睾酮dht (DHTPIN DHT11);
WiFiClient客户端;
无效设置()
{
Serial.begin (115200);
延迟(10);
dht.begin ();
“连接”);
以(ssid);
WiFi。开始(ssid,通过);
(WiFi.status () ! = WL_CONNECTED)
{
延迟(500);
并同时“。”);
}
”“);
“无线网络连接”);
}
无效循环()
{
浮动h = dht.readHumidity ();
浮动t = dht.readTemperature ();
如果(isnan (h) | | isnan (t))
{
“未能从DHT传感器读取!”);
返回;
}
如果(client.connect(服务器,80))/ /“184.106.153.149”api.thingspeak.com
{
字符串postStr = apiKey;
postStr + =" field1 = ";
postStr + =字符串(t);
postStr + =" field2 = ";
postStr + =字符串(h);
postStr + =“\ r \ n \ r \ n”;
client.print (“发布/更新HTTP / 1.1 \ n”);
client.print (主持人:api.thingspeak.com \ n”);
client.print (“连接:紧密\ n”);
client.print (”X-THINGSPEAKAPIKEY:“+ apiKey +“\ n”);
client.print (“内容类型:应用程序/ x-www-form-urlencoded \ n”);
client.print (内容长度”:“);
client.print (postStr.length ());
client.print (“\ n \ n”);
client.print (postStr);
并同时温度:“);
并同时(t);
并同时度、湿度:“);
并同时(h);
“%。发送到Thingspeak。”);
}
client.stop ();
“等……”);
/ / thingspeak需求最低15秒之间的延迟更新
延迟(1000);
}

答案(1)

克里斯托弗Stapels
克里斯托弗Stapels 2023年1月25日
编辑:克里斯托弗Stapels 2023年1月25日
我们推荐使用 ThingSpeak图书馆arduino和ESP 。它会为你照顾很多问题。
首先,不过我会尝试更新你的频道在浏览器地址栏,要确保你有正确的语法。你可以得到正确的格式的API密钥选项卡上你的频道。之后,然后回到传感器coe(希望结合ThingSpeak库),但输出价值观串行监控以确保正确读取的值。

类别

找到更多的在写数据通道帮助中心文件交换

标签

s manbetx 845

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!