我无法连接arduino ESP与Thinkspeak 8266 01

59视图(30天)
0。在命令= >失败
0。在命令= > + CWMODE = 1失败
0。在+ CWJAP =命令= >“背包”、“名称”失败
0。在命令= > + CIPMUX = 1失败
0。在+ CIPSTART =命令= > 0,“TCP”、“api.thingspeak.com”, 80年
#包括< SoftwareSerial.h >
#定义的处方2
#定义TX3
/ /#定义的处方19
/ /#定义TX18
字符串美联社=“背包”;/ /美联社的名字
字符串通过= "名称";/ /美联社密码
字符串API = " FNFJ7KDHJK4F3IU2 ";/ /写API关键
字符串主机= " api.thingspeak.com ";
字符串端口= " 80 ";
字符串场= "随机";
intcountTrueCommand;
intcountTimeCommand;
布尔发现= false;
intvalSensor = 1;
SoftwareSerialTX esp8266 (RX);
无效设置()
{
Serial.begin (9600);
esp8266.begin (115200);
sendCommand (“在”5,“OK”);
sendCommand (“在+ CWMODE = 1”5,“OK”);
sendCommand (“在+ CWJAP = \”“+ AP +”\”,\”“+ +”\”“,20岁,“OK”);
}
无效循环()
{
valSensor = getSensorData ();
字符串getData =“api_key = /更新?”+ API +“&”+场+“=”+字符串(valSensor);
sendCommand (“在+ CIPMUX = 1”5,“OK”);
sendCommand (“在+ CIPSTART = 0, \”TCP \”,\”“+主机+”\”、“+港口15“OK”);
sendCommand (“在+ CIPSEND = 0,”+字符串(getData.length () + 4), 4,“>”);
esp8266.println (getData);延迟(1500);countTrueCommand + +;
sendCommand (“在+ CIPCLOSE = 0”5,“OK”);
}
intgetSensorData ()
{
返回随机(1000);/ /替换为自己的传感器代码
}
无效sendCommand (String命令,int maxTime, char readReplay [])
{
并同时countTrueCommand);
并同时”。在命令= > ");
并同时(命令);
并同时”“);
(countTimeCommand < (maxTime * 1))
{
esp8266.println(命令);/ / + cipsend
如果(esp8266.find (readReplay)) / / ok
{
发现= true;
打破;
}
countTimeCommand + +;
}
如果(发现= = true)
{
“OYI”);
countTrueCommand + +;
countTimeCommand = 0;
}
如果(发现= = false)
{
“失败”);
countTrueCommand = 0;
countTimeCommand = 0;
}
发现= false;
}

答案(4)

维诺德
维诺德 2020年1月29日
你考虑过使用这里的图书馆: https://github.com/mathworks/thingspeak-arduino
我的建议是开始的例子是图书馆的一部分。例如: https://github.com/mathworks/thingspeak-arduino/tree/master/examples/ESP8266
2的评论

登录置评。



一汗
一汗 2022年5月17日
连接的Tx销esp8266 arduino的Rx销和Rx销esp8266 arduino Tx销

Dharmaseelan Karthigesu
Dharmaseelan Karthigesu 2022年11月7日
22:55:26.930 - > 0。在命令= > + CIPMUX = 1失败
22:55:31.955 - > 0。在+ CIPSTART =命令= > 0,“TCP”,“api.thingspeak.com”, 80失败
22:55:47.064 - > 0。在+ CIPSEND =命令= > 0,60失败
22:55:52.566 - > 1。在命令= > + CIPCLOSE = 0失败
为什么thingspeak没有数据?
# include < SoftwareSerial.h >
# include < dht11.h >
#定义RX 2
#定义TX 3
#定义dht_apin 11 / /模拟销传感器连接
dht11 dhtObject;
字符串美联社=“佛法”;/ /美联社的名字
字符串传递=“03049494”;/ /美联社密码
字符串API =“K4OY2DV8KSEB5QVP”;/ /写API键
字符串主机= " api.thingspeak.com ";
字符串端口= " 80 ";
int countTrueCommand;
int countTimeCommand;
布尔发现= false;
int valSensor = 1;
SoftwareSerial esp8266 (RX, TX);
无效的设置(){
Serial.begin (9600);
esp8266.begin (115200);
sendCommand(“在”5“OK”);
sendCommand (“+ CWMODE = 1”5“OK”);
sendCommand(“在+ CWJAP = \ " + AP +“\”, \““+ +”\”, 20岁的“OK”);
}
无效循环(){
字符串getData = " /更新吗?api_key = " + API + " field1 = " + getTemperatureValue () +”field2 = " + getHumidityValue ();
sendCommand (“+ CIPMUX = 1”5“OK”);
sendCommand(“在+ CIPSTART = 0, \“TCP \”, \“+主机+“\”、“+端口,15日“OK”);
sendCommand (+ CIPSEND = 0, +字符串(getData.length () + 4), 4,“>”);
esp8266.println (getData);延迟(1500);countTrueCommand + +;
sendCommand (“+ CIPCLOSE = 0”5“OK”);
}
字符串getTemperatureValue () {
dhtObject.read (dht_apin);
并同时" Temperature(C)= ");
int temp = dhtObject.temperature;
以(临时);
延迟(50);
返回字符串(临时);
}
字符串getHumidityValue () {
dhtObject.read (dht_apin);
并同时" Humidity in %= ");
int湿度= dhtObject.humidity;
以(湿度);
延迟(50);
返回字符串(湿度);
}
空白sendCommand (String命令,int maxTime, char readReplay []) {
并同时countTrueCommand);
并同时”。在命令= > ");
并同时(命令);
并同时”“);
而(countTimeCommand < (maxTime * 1))
{
esp8266.println(命令);/ / + cipsend
如果(esp8266.find (readReplay)) / /好吧
{
发现= true;
打破;
}
countTimeCommand + +;
}
如果发现= = true)
{
以“OYI”);
countTrueCommand + +;
countTimeCommand = 0;
}
如果发现= = false)
{
以“失败”);
countTrueCommand = 0;
countTimeCommand = 0;
}
发现= false;
}

社区

更多的答案ThingSpeak社区

类别

找到更多的在行为数据帮助中心文件交换

社区寻宝

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

开始狩猎!