ESP8266_IoT_SDK_Programming Guide_v0.9.1
- 格式:pdf
- 大小:1.16 MB
- 文档页数:64
⼀,ESP8266下载和刷固件(基于Lua脚本语⾔)⽤⾃⼰的⼩板测试......安排上呢⼀, ESP8266下载和刷固件(Lua开发----体验⼀下lua开发的魅⼒所在)⼆, 控制⼀个灯亮灭三, TCP服务器四, TCP客户端五, UDP六, ⽂件操作(保存数据到8266内部)七, 外设操作(SPI,ADC)⼋, 再说......先看下载⾃⼰的固件填写好⾃⼰的的邮箱地址,然后选择好⾃⼰需要的功能,⼀会编译好的固件就会发到您的邮箱地址我下载的我⼀开始⽤的QQ邮箱,不过后来不知道怎么的我的qq邮箱不可以了,,,,所以就⽤的⾃⼰的新浪邮箱然后就会出现下⾯的界⾯,,等着哈对了还有Lua开发的API⽂档邮件发过来啦烧写固件的软件⽆论哪⼀个软件,模块的接线都⼀样现在烧写固件参考⽂章..对了亲们可能⽤的这种的GPIO0 默认是⼯作模式(不接线)。
如果接了低电平就是下载模式(给模块刷固件!!)所以接低电平。
CH_PD接⾼电平,其余除了TX,RX外可以不接线..其实在模块上电的时候如果GPIO0是低电平那么模块就⼯作在等待刷固件模式,,,在模块上电的时候如果GPIO0是⾼电平那么模块就⼯作在正常⼯作模式,由于没有按键什么的,所以可以先接好线再上电再看这⼀款后来补充-----关于选择内存⼤⼩问题,不同的型号内存⼤⼩不⼀样可以看也可以从我的百度云⾥⾯下按下key2然后断电上电,或者按key3复位⼀下,,,然后松开key2就可以了好了现在看⽤第⼆个软件刷固件选择固件给⼤家各种模块的Flash⼤⼩的表让模块处于更新固件模式,,就是Gpio0接低电平,,然后复位⼀下好了对了可能出现这呢是串⼝模块和WIFI模块通信不稳定导致的,,,⾃⼰⽤ch340就出现过这种情况,,,,但是⽤pl2303就没有出现过,,,,对于这种情况,我感觉第⼀有条件可以换⼀个串⼝模块,⽐如pl2303,或者CP2102等等...再者呢可以选择好的杜邦线,,尽量短......不过呢,,⽤pl2303下载好以后,,⽤ch340也可以了...............对了也可以尝试把这⾥改⼩⼀点感觉只要不通信那么多数据,,也能减少出错的机会说⼀下这个软件还有⼀个⽤途就是把bin⽂件合成⼀个bin⽂件现在可以打开串⼝调试助⼿看⼀下也可能显⽰正在格式化⽂件系统,,,那么就等⼀会等它格式完⽂件系统我们写lua⽤这个软件不要害怕新语⾔哈,,,使⽤使⽤就知道了....很好⽤,和c语⾔很接近,功能却很强哈,,其实咱们哈也⽤不到多少,,,,咱们是使⽤的8266的API。
文件编号Document No.ESP-00-2-007-03文件名称Document Name产品/工艺变更通知Product/Process Change Notice(PCN)文件版本Document Version1.1保存期限Retention Period3年3 yearsESP8266 系列芯片技术文档变更ESP8266 Series Chip Product Technical Document ChangePCN编号PCN No.PCN-02-20190716提出日期Issue Date of PCN2019/7/16产品名称Product Name ESP8266EXESP8285变更日期Proposed Date of Change2019/8/1封装类型/尺寸Package Type/Size QFN 5X5首次出货日期Proposed Date of FirstShipmentNA客户批准/Customer Consent: 需要批准/Approval Required通知,无需批准/Notification, Approval Not Required变更等级/Classification of Change: 主要变更/Major 轻微变更/Minor变更原因/Reason for Change:ESP8266 系列产品技术文档中有关产品在Deep-sleep 模式下的GPIO hold 功能描述有误,故进行相关内容的修改。
The description of GPIO hold function of ESP8266 series of products working in the Deep-sleep mode in the technical documents of ESP8266 series of products is incorrect, so the relevant content needs to be modified.变更描述/Description of Change:删除ESP8266 系列产品的技术文档中有关产品在Deep-sleep 模式下的GPIO hold 功能的描述。
[ ] INTERNAL [ ] PUBLIC版本信息Wi-Fi联盟成员标志归Wi-Fi联盟所有。
文中提到的所有商标名称、商标和注册商标均属其各自所有者的财产,特此声明。
版权归© 2014 乐鑫信息技术有限公司所有。
保留所有权利。
目录版本信息 (2)目录 (3)1.前言 (4)2.虚拟机 (5)2.1.虚拟机软件 (5)2.2.虚拟电脑 (5)2.2.1.镜像 (5)2.2.2.导入 (5)2.2.3.网络 (8)2.2.4.共享文件夹 (8)2.2.5.界面 (10)3.开发工具 (11)3.1.编译器 (11)3.2.串口工具 (13)B转串口 (13)3.2.2.SecureCRT (14)3.3.下载工具 (14)3.3.1.XTCOM_UTIL (14)3.3.2.ESP_FLASH_DOWNLOAD (17)Assist (18)3.5.Postman (18)3.6.Tomcat (18)4.SDK软件包 (19)4.1.介绍 (19)4.2.目录结构 (19)4.3.编译及烧录方法 (20)4.3.1.不支持云端升级 (20)4.3.2.支持云端升级 (21)1.前言本文主要介绍基于ESP8266物联网模块的SDK相关使用方法,包括虚拟机安装设置、开发工具使用以及SDK软件包架构等。
2.虚拟机基于ESP8266物联网模块进行二次开发所需的相关开发工具已安装到虚拟机中,用户只需安装虚拟机软件,并导入虚拟电脑,即可进行开发。
2.1. 虚拟机软件虚拟机采用VirtualBox,下载地址为:https:///wiki/Downloads选择相应平台下载安装。
2.2. 虚拟电脑2.2.1. 镜像虚拟电脑镜像采用开放式虚拟化格式(*.ova),文件为ESP_IOT_SDK.ova,可以被其他虚拟机软件导入使用。
2.2.2. 导入VirtualBox默认情况,会将虚拟电脑导入系统盘,随着虚拟电脑的使用,会占用非常大的空间,建议设置虚拟电脑位置到非系统盘。
esp8266 教程ESP8266教程:连接WiFi网络步骤一:准备工作1.1 确保你已经具备以下物品:- ESP8266模块- 电脑- USB转串口模块- 杜邦线1.2 安装USB驱动程序在使用ESP8266之前,我们需要先安装USB转串口模块所需的驱动程序。
根据你所使用的转接模块型号,下载并安装相应的驱动程序。
步骤二:连接硬件2.1 将ESP8266与USB转串口模块连接起来。
使用杜邦线将ESP8266的VCC引脚连接到USB转串口模块的VCC引脚,将GND引脚连接到GND引脚,将TX引脚连接到RX引脚,将RX引脚连接到TX引脚。
2.2 将USB转串口模块连接到电脑的USB接口上。
步骤三:编写代码3.1 打开Arduino IDE,新建一个代码文件。
3.2 导入ESP8266库在Arduino IDE中,点击"工具"->"管理库",搜索并安装ESP8266库。
3.3 编写代码接下来,我们开始编写代码。
以下是一个简单的示例,用于连接WiFi网络。
```cpp#include <ESP8266WiFi.h>const char* ssid = "YourWiFiNetworkName";const char* password = "YourWiFiNetworkPassword";void setup() {Serial.begin(115200);WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(1000);Serial.println("Connecting to WiFi...");}Serial.println("Connected to WiFi!");}void loop() {// 这里可以添加你的代码逻辑}```备注:将"YourWiFiNetworkName"替换成你的WiFi网络名称,将"YourWiFiNetworkPassword"替换成你的WiFi网络密码。
ESP8266用户手册ESP8266是一种广泛使用的无线模块,由Espressif Systems开发,被广泛使用于物联网和嵌入式设备的应用。
ESP8266的设计目标是为IoT应用提供连接便捷、底层可编程性和低成本的方案,它采用了Tensilica的L106 Diamond系列的32位大小端MCU。
由于其强大的功能和易于使用性,ESP8266已经成为了DIY电子爱好者的最爱。
本文将详细介绍ESP8266用户手册,以帮助新手更好地使用该模块。
1. 硬件介绍ESP8266是一款集成了Wi-Fi的芯片,它与主控芯片之间通过串行通信进行交互。
ESP8266的主体尺寸为16mm x 24mm,并且它的引脚和结构都是十分紧凑的。
ESP8266通常工作在3.3V的电压下,但是如果需要与5V的主控芯片进行通信,就需要进行电平转换。
2. 软件介绍在软件方面,ESP8266支持多种开发平台和语言。
目前,ESP8266最受欢迎的开发平台是Arduino IDE,用户可以通过该平台进行快速的开发工作。
此外,ESP8266也支持其他语言和开发平台,例如Python、Lua等。
3. WiFi模式ESP8266支持三种WiFi模式: STA模式、AP模式和STA+AP 模式。
STA模式是指将ESP8266作为一个WiFi的客户端连接到一个现有的WiFi网络,AP模式是指将ESP8266作为一个WiFi热点使其它设备可以连接到它,STA+AP模式是指将ESP8266同时作为WiFi客户端和WiFi热点。
4. AT指令ESP8266可以通过AT指令进行控制。
当我们要将ESP8266作为单片机处理时,我们可以使用AT指令来控制它的各种功能。
AT指令通常以“AT”开头,其后跟着具体的指令。
例如,AT+GMR是一个用来获取ESP8266固件版本信息的指令。
5. 固件升级在使用ESP8266过程中,我们可能需要升级不同版本的固件以获取新的功能和修复BUG。
安信可ESP8266模块使用指导ESP8266是一款低成本、低功耗的Wi-Fi模块,具有强大的处理能力和丰富的接口选项。
在这篇使用指导中,将向您介绍如何使用安信可ESP8266模块进行Wi-Fi通信。
1.硬件准备首先,您需要准备以下硬件设备:-安信可ESP8266模块-电脑或单片机开发板-USB转串口模块(用于连接ESP8266模块和电脑)2.硬件连接将ESP8266模块与USB转串口模块进行连接。
请确保连接正确,例如将ESP8266的VCC引脚连接到3.3V电源,GND引脚连接到地线,TX引脚连接到USB转串口的RX引脚,RX引脚连接到TX引脚。
3.软件准备在开始编程之前,您需要安装以下软件:- Arduino IDE(用于编写和上传代码)- ESP8266 Arduino核心库(用于支持ESP8266模块)安装完成后,打开Arduino IDE并选择适用于ESP8266的开发板。
4.编写代码以下是一个简单的示例代码,用于将ESP8266连接到Wi-Fi网络并发送HTTP请求:```Arduino#include <ESP8266WiFi.h>const char* ssid = "你的Wi-Fi名称";const char* password = "你的Wi-Fi密码";void setudelay(10);WiFi.begin(ssid, password);while (WiFi.status( != WL_CONNECTED)delay(500);Serial.print(".");}Serial.println("");Serial.println("Wi-Fi连接成功");Serial.println("发送HTTP请求...");WiFiClient client;client.println("GET /api/data HTTP/1.1");client.println("Connection: close");client.println(;}void loo//其他代码...```5.上传和运行代码将ESP8266模块连接到电脑,并在Arduino IDE中选择正确的串口和开发板。
关于系统的升级问题:三种办法升级:我们免费送烧写好的固件IC,或者等8月18日升级软件和原厂协商放出后,客户自己升级。
或者有FLASH烧写器的(淘宝有便宜的),请下载我们公布的AT自己更新固件。
ESP8266的AT指令在逐步更加趋近完美,但是这要一个过程,因此任何产品没有绝对的完美,只有相对的完美。
您每次拿到的货都是当时最完美的!至于以后出更完美的请自己做好心理平衡工作,乐鑫软件在更新,我们硬件在几次改进后也接近完美。
无论软件和硬件我们都提供更新服务,但是利润微薄,我们可以免费送您最新的烧写好固件FLASH去评测,但是邮费请自己出一下。
从8月10日起所售出的模块把升级使能接口留出来了,客户可以方便的去升级固件。
升级所需要的工具软件因为是了鑫原厂的受控文件,在和他们协商如何放出来给大家,请稍作等待,月底或者下个月中旬有V1.0版本放出,在9月底接近于完美。
试想一下:为了等待完美版的出现,您会愿意再等待一个半月再入手吗?99%的人都会选择先入手体验一下这款产品。
等产品完美时候,立马投入生产。
因为本模块设计出来不是用来玩的,是用来设计产品并投入市场的!没有人会为了十几一二十块钱的东西,等2个月再去体验。
我们随时都可以跟客户换你想要的东西!哪怕你用的多旧都可以换新的,但是来回邮费请自理。
公司不是很大,我们能做到的极限服务就这些了!安信可所做的是:让大家迅速体验目前市面上最有前途的东西,给大家提供另外一条路可以走。
系统工作模式:MTDO GPIO2 GPIO0 用来确定系统的运行模式1 X X 系统工作在SDIO 模式,可以用外部MCU驱动内部WIFI(不常用)0 1 1 系统从外部FLASH启动0 1 0 系统自动进入升级状态,等待串口下载命令的到来13脚14脚15脚这三个脚位所在芯片的编号。
AT指令固件乐鑫原厂更新过两次,2014年8月16日前为最初版本系统输入AT+GMR 回车后,显示系统版本为01000800(第一版本)经过一个月更新,系统更加稳定可靠,并且功能相对完善。
Espressif IoT SDK:Programming GuideStatus ReleasedCurrent version V0.9.1Author Fei YuCompletion Date 2014.9.23Reviewer Jiangang Wu Completion Date 2014.9.23[ ] CONFIDENTIAL[ ] INTERNAL[ ] PUBLICVersion InfoDate Version Author Comments/Changes 2013.12.25 0.1 Jiangang Wu Draft2013.12.25 0.1.1Han Liu Revise Json APIs2014.1.15 0.2 Jiangang Wu Revise some APIs2014.1.29 0.3 Han Liu Add client/server APIs2014.3.20 0.4 Jiangang Wu/ Han Liu 1.Add UART APIs;2.Add i2c master APIs;3.Revise client/server APIs;4.Add secure espconn APIs;5.Add upgrade APIs2014.4.17 0.5 Jiangang Wu/ Han Liu 1.Revise espconn APIs;2.Add gpio APIs instruction;3.Add some other instructions;2014.5.14 0.6 Jiangang Wu Add some APIs2014.6.18 0.7 Jiangang Wu 1.Add dns APIs;2.Revise save-param APIs;3.Add task APIs;4.Add API to get connected station’sinfo when ESP8266 in softAP mode;5. Add API to get free heap size.6.Others2014.7.10 0.8 Fei Yu 1.Add OTA APIs;2.Add API to ON/OFF printf;3.Add wifi_station_get_connect_status4.Add TCP Server(SSL) APIs2014.8.13 0.9 Fei Yu 1.Revise espconn APIs;2.Add sniffer APIs;3.Add system_get_chip_id;4.Add APIs to read/ write mac&ip;2014.9.23 0.9.1 Fei Yu1、Add system_deep_sleep;2、Revise APIs to read/write flash;3、Add APIs for AP_CHE4、Revise UDP APIsDisclaimer and Copyright NoticeInformation in this document, including URL references, is subject to change without notice.THIS DOCUMENT IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. All liability, including liability for infringement of any proprietary rights, relating to use of information in this document is disclaimed. No licenses express or implied, by estoppel or otherwise, to any intellectual property rights are granted herein.The Wi-Fi Alliance Member Logo is a trademark of the Wi-Fi Alliance.All trade names, trademarks and registered trademarks mentioned in this document are property of their respective owners, and are hereby acknowledged.Copyright ©2013 Espressif Systems Inc. All rights reserved.Table of ContentsVersion Info (2)Table of Contents (4)1.Foreword (8)2.Overview (9)3.Application Programming Interface (APIs) (10)3.1.Timer (10)3.1.1.os_timer_arm (10)3.1.2.os_timer_disarm (10)3.1.3.os_timer_setfn (11)3.2.System APIs (11)3.2.1.system_restore (11)3.2.2.system_restart (11)3.2.3.system_get_chip_id (12)3.2.4.system_deep_sleep (12)3.2.5.system_upgrade_userbin_check (12)3.2.6.system_upgrade_start (13)3.2.7.system_upgrade_reboot (13)3.2.8.system_set_os_print (13)3.2.9.system_timer_reinit (14)3.2.10.system_print_meminfo (14)3.2.11.system_get_free_heap_size (15)3.2.12.system_os_task (15)3.2.13.system_os_post (16)3.2.14.spi_flash_erase_sector (17)3.2.15.spi_flash_write (17)3.2.16.spi_flash_read (18)3.2.17.wifi_get_opmode (18)3.2.18.wifi_set_opmode (19)3.2.19.wifi_station_get_config (19)3.2.20.wifi_station_set_config (20)3.2.21.wifi_station_connect (20)3.2.22.wifi_station_disconnect (21)3.2.23.wifi_station_get_connect_status (21)3.2.24.wifi_station_scan (22)3.2.25.scan_done_cb_t (22)3.2.26.wifi_station_ap_number_set (23)3.2.27.wifi_station_ap_change (23)3.2.28.wifi_station_get_current_ap_id (23)3.2.29.wifi_softap_get_config (24)3.2.30.wifi_softap_set_config (24)3.2.31.wifi_softap_get_station_info (24)3.2.32.wifi_softap_free_station_info (25)3.2.33.wifi_get_ip_info (26)3.2.34.wifi_set_ip_info (26)3.2.35.wifi_set_macaddr (27)3.2.36.wifi_get_macaddr (28)3.2.37.wifi_status_led_install (28)3.2.38.wifi_promiscuous_enable (29)3.2.39.wifi_set_promiscuous_rx_cb (29)3.2.40.wifi_get_channel (30)3.2.41.wifi_set_channel (30)3.3.Espconn APIs (30)3.3.1.General APIs (31)3.3.1.1.espconn_gethostbyname (31)3.3.1.2.espconn_port (32)3.3.1.3.espconn_regist_sentcb (32)3.3.1.4.espconn_regist_recvcb (33)3.3.1.5.espconn_sent_callback (33)3.3.1.6.espconn_recv_callback (33)3.3.1.7.espconn_sent (34)3.3.2.TCP APIs (34)3.3.2.1.espconn_accept (34)3.3.2.2.espconn_secure_accept (35)3.3.2.3.espconn_regist_time (35)3.3.2.4.espconn_get_connection_info (36)3.3.2.5.espconn_connect (36)3.3.2.6.espconn_connect_callback (36)3.3.2.7.espconn_disconnect (37)3.3.2.8.espconn_regist_connectcb (37)3.3.2.9.espconn_regist_reconcb (38)3.3.2.10.espconn_regist_disconcb (38)3.3.2.11.espconn_secure_connect (39)3.3.2.12.espconn_secure_sent (39)3.3.2.13.espconn_secure_disconnect (39)3.3.3.UDP APIs (40)3.3.3.1.espconn_create (40)3.3.3.2.espconn_delete (40)3.4.json APIs (41)3.4.1.jsonparse_setup (41)3.4.2.jsonparse_next (41)3.4.3.jsonparse_copy_value (41)3.4.4.jsonparse_get_value_as_int (42)3.4.5.jsonparse_get_value_as_long (42)3.4.6.jsonparse_get_len (42)3.4.7.jsonparse_get_value_as_type (43)3.4.8.jsonparse_strcmp_value (43)3.4.9.jsontree_set_up (43)3.4.10.jsontree_reset (44)3.4.11.jsontree_path_name (44)3.4.12.jsontree_write_int (44)3.4.13.jsontree_write_int_array (45)3.4.14.jsontree_write_string (45)3.4.15.jsontree_print_next (46)3.4.16.jsontree_find_next (46)4.Structure definition (47)4.1.Timer (47)4.2.Wifi parameters (47)4.2.1.station parameters (47)4.2.2.softap parameters (47)4.2.3.scan parameters (48)4.3.json related structure (48)4.3.1.json structure (48)4.3.2.json macro definition (50)4.4.espconn parameters (51)4.4.1callback function (51)4.4.2espconn (51)5.Driver (54)5.1.GPIO APIs (54)5.1.1.PIN setting macro (54)5.1.2.gpio_output_set (54)5.1.3.GPIO input and output macro (55)5.1.4.GPIO interrupt (55)5.1.5.gpio_pin_intr_state_set (56)5.1.6.GPIO interrupt handler (56)5.2.UART APIs (56)5.2.1.uart_init (57)5.2.2.uart0_tx_buffer (57)5.2.3.uart0_rx_intr_handler (58)5.3.i2c master APIs (58)5.3.1.i2c_master_gpio_init (58)5.3.2.i2c_master_init (58)5.3.3.i2c_master_start (59)5.3.4.i2c_master_stop (59)5.3.5.i2c_master_setAck (59)5.3.6.i2c_master_getAck (60)5.3.7.i2c_master_readByte (60)5.3.8.i2c_master_writeByte (60)5.4.pwm (61)5.4.1.pwm_init (61)5.4.2.pwm_start (61)5.4.3.pwm_set_duty (61)5.4.4.pwm_set_freq (62)5.4.5.pwm_get_duty (62)5.4.6.pwm_get_freq (62)6.Appendix (63)A.ESPCONN Programming (63)A.1.TCP Client Mode (63)A.1.1.Instructions (63)A.1.2.Steps (63)A.2.TCP Server Mode (64)A.2.1.Instructions (64)A.2.2.Steps (64)1.ForewordThe SDK based on ESP8266 IoT platform offers users an easy, fast and efficient way to develop IoT devices.The programming guide provides overview of the SDK as well as details on the API. It is written for embedded software developers to help them program on ESP8266 IoT platform.2.OverviewThe SDK provides a set of interfaces for data receive and transmit functions over the Wi-Fi and TCP/IP layer so programmers can focus on application development on the high level. Users can easily make use of the corresponding interfaces to realize data receive and transmit.All networking functions on the ESP8266 IoT platform are realized in the library, and are not transparent to users. Instead, users can initialize the interface in user_main.cvoid usre_init(void) is the default method provided. Users can add functions like firmware initialization, network parameters setting, and timer initialization in the interface.The SDK provides an API to handle json, and users can also use self-defined data types to handle the them.3.Application Programming Interface (APIs) 3.1. TimerLocate in “\esp_iot_sdk\include\osapi.h”3.1.1. os_timer_armFunction: arm timerPrototype:void os_timer_arm(ETSTimer *ptimer, uint32_t milliseconds, boolrepeat_flag) Input parameters:ETSTimer*ptimer——Timer structureuint32_t milliseconds——Timing, Unit: milisecondboolrepeat_flag——Whether to repeat the timingReturn:null3.1.2. os_timer_disarmFunction: Disarm timerPrototype:void os_timer_disarm (ETSTimer *ptimer)Input parameters:ETSTimer*ptimer——Timer structureReturn:null3.1.3. os_timer_setfnFunction: Set timer callback functionPrototype:void os_timer_setfn (ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) Input parameters:ETSTimer*ptimer——Timer structureTESTimerFunc*pfunction——timer callback functionvoid*parg——callback function parameterReturn:null3.2. System APIsLocate in “\esp_iot_sdk \include\user_interface.h”。