Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino 带DHT11的ESP8266_Arduino_Esp8266 - Fatal编程技术网

Arduino 带DHT11的ESP8266

Arduino 带DHT11的ESP8266,arduino,esp8266,Arduino,Esp8266,我正试图让ESP8266-01与我的DHT11传感器一起工作,并将数据发布到Thingspeak 为了将我的代码上传到ESP8266,我使用了FTDI232型号的TTL-To-USB,并选择了3.3v输出 在第一次尝试中,我能够从esp示例上传“闪烁”示例,然后尝试用传感器上传代码,但没有成功,在上传草图时出现错误和错误 我试图上传的代码如下: Arduino:1.6.12 (Windows 7), Tarjeta:"Generic ESP8266 Module, 80 MHz, 40MHz,

我正试图让ESP8266-01与我的DHT11传感器一起工作,并将数据发布到Thingspeak

为了将我的代码上传到ESP8266,我使用了FTDI232型号的TTL-To-USB,并选择了3.3v输出

在第一次尝试中,我能够从esp示例上传“闪烁”示例,然后尝试用传感器上传代码,但没有成功,在上传草图时出现错误和错误

我试图上传的代码如下:

Arduino:1.6.12 (Windows 7), Tarjeta:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 512000, 512K (64K SPIFFS), ck, Disabled, None"

El Sketch usa 233,113 bytes (53%) del espacio de almacenamiento de programa. El máximo es 434,160 bytes.
Las variables Globales usan 32,432 bytes (39%) de la memoria dinámica, dejando 49,488 bytes para las variables locales. El máximo es 81,920 bytes.
Uploading 237264 bytes from C:\Users\nmnerzul\AppData\Local\Temp\arduino_build_881344/humedadesp8266solo.ino.bin to flash at 0x00000000
..........warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
//www.arduinesp.com
//
//使用ESP8266在thingspeak.com上绘制DTH11数据
//2015年4月11日
//作者:Jeroen Beemster
//网站:www.arduinesp.com
#包括
#包括
//替换为您频道的thingspeak API密钥,
字符串apiKey=“EQE7GT28UMUW17CH”;
const char*ssid=“GC-Office-WLAN1”;
const char*password=“bsontkgcmxitwn30of0110110119”;
const char*server=“api.thingspeak.com”;
#定义DHTPIN 2//我们连接到的pin
DHT-DHT(DHTPIN,DHT11,15);
无线客户端;
无效设置(){
序列号开始(115200);
延迟(10);
dht.begin();
WiFi.begin(ssid,密码);
Serial.println();
Serial.println();
串行打印(“连接到”);
序列号println(ssid);
WiFi.begin(ssid,密码);
while(WiFi.status()!=WL_已连接){
延迟(500);
连续打印(“.”);
}
Serial.println(“”);
Serial.println(“WiFi连接”);
}
void循环(){
浮动h=dht.read湿度();
浮点数t=dht.readTemperature();
if(isnan(h)| | isnan(t)){
Serial.println(“从DHT传感器读取失败!”);
返回;
}
if(client.connect(server,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(“POST/update HTTP/1.1\n”);
client.print(“主机:api.thingspeak.com\n”);
client.print(“连接:关闭\n”);
client.print(“X-THINGSPEAKAPIKEY:+apiKey+”\n”);
client.print(“内容类型:application/x-www-form-urlencoded\n”);
client.print(“内容长度:”);
client.print(postStr.length());
client.print(“\n\n”);
client.print(postStr);
连续打印(“温度:”);
连续打印(t);
连续打印(“摄氏度湿度:”);
连续打印(h);
Serial.println(“%send to Thingspeak”);
}
client.stop();
Serial.println(“等待…”);
//thingspeak在更新之间需要至少15秒的延迟
延迟(60000);
}
我得到的错误信息如下:

Arduino:1.6.12 (Windows 7), Tarjeta:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 512000, 512K (64K SPIFFS), ck, Disabled, None"

El Sketch usa 233,113 bytes (53%) del espacio de almacenamiento de programa. El máximo es 434,160 bytes.
Las variables Globales usan 32,432 bytes (39%) de la memoria dinámica, dejando 49,488 bytes para las variables locales. El máximo es 81,920 bytes.
Uploading 237264 bytes from C:\Users\nmnerzul\AppData\Local\Temp\arduino_build_881344/humedadesp8266solo.ino.bin to flash at 0x00000000
..........warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
我使用的是带1A的3.3外部电源。我将此连接到ESP8266模块上电。
我在Arduino IDE中的设置如下

我尝试了以下方法:

Arduino:1.6.12 (Windows 7), Tarjeta:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 512000, 512K (64K SPIFFS), ck, Disabled, None"

El Sketch usa 233,113 bytes (53%) del espacio de almacenamiento de programa. El máximo es 434,160 bytes.
Las variables Globales usan 32,432 bytes (39%) de la memoria dinámica, dejando 49,488 bytes para las variables locales. El máximo es 81,920 bytes.
Uploading 237264 bytes from C:\Users\nmnerzul\AppData\Local\Temp\arduino_build_881344/humedadesp8266solo.ino.bin to flash at 0x00000000
..........warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
更新前重置模块,更改闪存大小(512k时为1M),更改速度(测试512000、9600、115200),我只能上传闪烁示例

希望信息足够。 谢谢你抽出时间。

此问题实际上与代码无关。硬件连接/数据同步肯定有问题

在尝试我的解决方案时,请尽量不要弄乱软件使用ESP使用建议的115200上传速度,并且如果ESP的PCB为黑色模块更可能为1M而不是512闪存大小(但此处不应测量闪存大小)

因此,我无法清楚地看到USBtoTTL和ESP01之间的连接,因此请检查您的连接是否看起来像这样:

╭────────────┬─────────────╮
│    ESP01   │   USBtoTTL  │
╞════════════╪═════════════╡
│    RX      │     TX      │
│    TX      │     RX      │
│    VCC     │     VCC     │
│    CH_PD   │     VCC     │
│    GND     │     GND     │
│    GPIO0   │     GND     │
└────────────┴─────────────┘
这样,当您打开ESP电源时,您应该只会看到嵌入式蓝色LED闪烁一次,这意味着模块现在处于闪烁模式

尝试单击ARDUINO IDE中的上载按钮,就在您看到此按钮闪烁之后

如果此步骤对您有效,请检查您的电源接地是否与USBtoTTL和您的ESP共用。

最后也是不幸的是,最可能的原因是它们之间的电线/连接质量差。
我使用了几种类型的ESP模块已有一年多了,有时在上传时仍会出现一些故障。您可以做的任何事情都是尝试不同的USB电缆,并减少试验板上的连接数量。我建议购买/DIY一个USBtoTTL->ESP01适配器,安装在实心原型板上,带有短焊接导线


如果这没有帮助,请向我提供信息,如果这是您唯一的错误类型,或者可能有时在上载或其他方面失败。

和接线?我只是添加了接线感谢电话上的编辑、西班牙语自动更正器。您仍然能成功上载闪烁示意图吗?如果是这样的话,那就不是线路问题了。确保您的ESP已复位,GPIO-0在通电前已接地。我在5次尝试中上载了2次闪烁示意图,但在5次尝试中未能上载湿度示意图