• This repository has been archived on 27/Oct/2022
  • Stars
    star
    333
  • Rank 122,281 (Top 3 %)
  • Language
    C
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Aliyun Iotkit-embedded, support esp32 & esp8266.

ESP 设备对接阿里云指南

目录

0.介绍

乐鑫是高集成度芯片的设计专家,专注于设计简单灵活、易于制造和部署的解决方案。乐鑫研发和设计 IoT 业内集成度高、性能稳定、功耗低的无线系统级芯片,乐鑫的模组产品集成了自主研发的系统级芯片,因此具备强大的 Wi-Fi 和蓝牙功能,以及出色的射频性能。

阿里云物联网套件是阿里云专门为物联网领域的开发人员推出的,其目的是帮助开发者搭建安全性能强大的数据通道,方便终端(如传感器、执行器、嵌入式设备或智能家电等等)和云端的双向通信。全球多节点部署让海量设备全球范围都可以安全低延时接入阿里云IoT Hub,安全上提供多重防护保障设备云端安全,性能上能够支撑亿级设备长连接,百万消息并发。物联网套件还提供了一站式托管服务,数据从采集到计算到存储,用户无需购买服务器部署分布式架构,用户通过规则引擎只需在web上配置规则即可实现采集+计算+存储等全栈服务。总而言之,基于物联网套件提供的服务,物联网开发者可以快速搭建稳定可靠的物联网平台。

1.目的

本文基于 linux 环境,介绍 ESP 设备对接阿里云平台的具体流程,供读者参考。当前只维护 smart_lightsolo 示例,这两个示例包含了另外三个示例的功能,建议直接选择这两个示例 demo。

2.硬件准备

  • linux 环境
    用来编译 & 烧写 & 运行等操作的必须环境。

windows 用户可安装虚拟机,在虚拟机中安装 linux。

  • ESP 设备
    ESP 设备包括 ESP芯片ESP模组ESP开发板等。

  • USB 线
    连接 PC 和 ESP 设备,用来烧写/下载程序,查看 log 等。

3.阿里云平台准备

根据阿里官方文档,在阿里云平台创建产品,创建设备,同时自动产生 product key, product secert, device name, device secret
product key, product secert, device name, device secret 将在 6.2.3 节用到。

4.环境搭建

如果您熟悉 ESP 开发环境,可以很顺利理解下面步骤; 如果您不熟悉某个部分,比如编译,烧录,需要您结合官方的相关文档来理解。如您需阅读 ESP-IDF 编程指南文档等。

4.1 编译器环境搭建

  • ESP8266 平台: 根据官方链接Get toolchain,获取 toolchain
  • ESP32 & ESP32S2 平台:根据官方链接工具链的设置,下载 toolchain

toolchain 设置参考 ESP-IDF 编程指南

4.2 烧录工具/下载工具获取

  • ESP8266 平台:烧录工具位于 ESP8266_RTOS_SDK./components/esptool_py/esptool/esptool.py
  • ESP32 & ESP32S2 平台:烧录工具位于 esp-idf./components/esptool_py/esptool/esptool.py

esptool 功能参考:

$ ./components/esptool_py/esptool/esptool.py --help

5.SDK 准备

Espressif SDK 下载好后:
ESP-IDF: 请切换到 v4.2 分支: git checkout v4.2 如果需要使用 ESP32S2 模组,请切换到 v4.2 版本: git checkout v4.2 ESP8266_RTOS_SDK: 请切换到 v3.3 分支: git checkout v3.3

6.编译 & 烧写 & 运行

6.1 编译

6.1.1 导出编译器

参考 工具链的设置

6.1.2 编译 demo 示例

由于 esp32 和 esp8266 将会采用不同的 sdkconfig.defaults 和对应的 partitions.csv,在对应的 make 命令中加入了对应的芯片选项,如 chip=esp32 或 chip=esp8266。

当 chip=esp32 时将默认使用 sdkconfig_esp32.defaults 以及 partitions_esp32.csv。

当 chip=esp8266 时将默认使用 sdkconfig_esp8266.defaults 以及 partitions_esp8266.csv。

当使用 esp32s2 时,将默认使用 sdkconfig.defaults ,sdkconfig.defaults.esp32s2 以及 partitions_esp32s2.csv,编译方式与 8266 & 32 都不一样,需要使用 cmake 进行编译。

以上需要特别注意。

在 esp-aliyun 目录下执行:

cd examples/solutions/smart_light
make chip=esp32 defconfig
make menuconfig

如果需要编译esp32s2版本, 请按照如下步骤编译:

执行如下命令,以 solo 示例为例,目前只支持 solo 和 smart_light 示例。

cd examples/solo/example_solo
idf.py set-target esp32s2
idf.py menuconfig

p1

  • 配置烧写串口
  • 配置 WIFI_SSID, WIFI_PASSWORD

如果需要编译esp32s3版本, 当前只支持 master 版本。请按照如下步骤编译:

执行如下命令,以 solo 示例为例,目前只支持 solo 和 smart_light 示例。

cd examples/solo/example_solo
idf.py set-target esp32s3
idf.py menuconfig

2.生成最终 bin

make -j8

使用 esp32s2/esp32s3 生成 bin

idf.py build

6.2 擦除 & 编译烧写 & 下载固件 & 查看 log

将 USB 线连接好 ESP 设备和 PC,确保烧写端口正确。

6.2.1[可选] 擦除 flash

make erase_flash

注:无需每次擦除,擦除后需要重做 6.2.3。

6.2.2 烧录程序

make flash

使用 esp32s2/esp32s3 擦除 flash

idf.py -p (PORT) erase_flash

6.2.3 烧录三元组信息

参考 量产说明 文档烧录三元组 NVS 分区。

6.2.4 运行

make monitor

如将 ESP8266 拨至运行状态,即可看到如下 log: log 显示了 ESP8266 基于 TLS 建立了与阿里云的安全连接通路,接着通过 MQTT 协议订阅和发布消息,同时在阿里云控制台上,也能看到 ESP8266 推送的 MQTT 消息。

p2

p3

p4

也可执行 make flash monitor 来编译烧写和查看 log。

More Repositories

1

esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
C
12,517
star
2

arduino-esp32

Arduino core for the ESP32
C++
12,308
star
3

esptool

Espressif SoC serial bootloader utility
Python
5,311
star
4

ESP8266_RTOS_SDK

Latest ESP8266 SDK based on FreeRTOS, esp-idf style.
C
3,232
star
5

esp-iot-solution

Espressif IoT Library. IoT Device Drivers, Documentations And Solutions.
C
1,751
star
6

esp-who

Face detection and recognition framework
C
1,594
star
7

esp-adf

Espressif Audio Development Framework
C
1,395
star
8

esp32-camera

C
1,259
star
9

vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
TypeScript
944
star
10

ESP8266_NONOS_SDK

ESP8266 nonOS SDK
C
911
star
11

esp-at

AT application for ESP32/ESP32-C2/ESP32-C3/ESP32-C6/ESP8266
C
769
star
12

esp-mdf

Espressif Mesh Development Framework, limited maintain, recommend to use https://github.com/espressif/esp-mesh-lite
C
757
star
13

ESP8266_MP3_DECODER

A demo that should be run with ESP8266 Non-OS SDK
C
739
star
14

esp-drone

Mini Drone/Quadcopter Firmware for ESP32 and ESP32-S Series SoCs.
C
658
star
15

esp-box

The ESP-BOX is a new generation AIoT development platform released by Espressif Systems.
HTML
612
star
16

esp-apple-homekit-adk

This is a port for Apple's Open Source HomeKit ADK
C
598
star
17

esp-csi

Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection
C
592
star
18

kicad-libraries

KiCad libraries for Espressif chips and modules
Python
580
star
19

esp-mqtt

ESP32 mqtt component
C
577
star
20

esp-matter

Espressif's SDK for Matter
C++
546
star
21

esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
C
539
star
22

esp-homekit-sdk

C
518
star
23

esp-skainet

Espressif intelligent voice assistant
C
500
star
24

ESP8266_AT

This project is not maintained, please use https://github.com/espressif/esp-at.
C
472
star
25

esp32-nesemu

Proof-of-concept NES emulator for the ESP32
C
471
star
26

esp-sr

Speech recognition
C
462
star
27

rust-esp32-example

Example of Rust integration into an ESP-IDF project, for ESP32 series of chips
Rust
421
star
28

esp-rainmaker

ESP RainMaker Agent for firmware development
C
415
star
29

esp-now

A connectionless Wi-Fi communication protocol
C
402
star
30

esp-dsp

DSP library for ESP-IDF
C
401
star
31

esp-dl

Espressif deep-learning library for AIoT applications
C++
369
star
32

openocd-esp32

OpenOCD branch with ESP32 JTAG support
C
334
star
33

esp-idf-template

Template application for https://github.com/espressif/esp-idf
Makefile
323
star
34

esp-serial-flasher

Library for flashing Espressif SoCs from other MCUs.
C++
321
star
35

idf-eclipse-plugin

Espressif-IDE (based on Eclipse CDT) for ESP-IDF CMake based projects 4.x and above
Java
289
star
36

esp-dev-kits

Docs, Schematics, Factory Firmwares for ESP Development Kits
C
287
star
37

esp-va-sdk

Espressif's Voice Assistant SDK: Alexa, Google Voice Assistant, Google DialogFlow
C
273
star
38

esp-tflite-micro

TensorFlow Lite Micro for Espressif Chipsets
C++
271
star
39

esp-usb-bridge

USB to UART&JTAG bridge, implemented on ESP32-S2 or ESP32-S3
C
271
star
40

esp-aws-iot

AWS IoT SDK for ESP32 based chipsets
C
247
star
41

esptool-js

Javascript implementation of flasher tool for Espressif chips, running in web browser using WebSerial.
TypeScript
241
star
42

ESP31_RTOS_SDK

ESP31B SDK based on FreeRTOS. For ESP32 please see http://github.com/espressif/esp-idf
HTML
189
star
43

esp-idf-provisioning-android

Android Provisioning application for ESP-IDF Unified provisioning
Java
184
star
44

esp-azure

SDK to connect ESP8266 and ESP32 to Microsoft Azure IoT services
C
174
star
45

esp-jumpstart

Jumpstart from concept to production
C
167
star
46

esp-gdbstub

C
157
star
47

esp-protocols

Collection of ESP-IDF components related to networking protocols
C
156
star
48

esp32-wifi-lib

ESP32 WiFi stack precompiled libraries
Shell
153
star
49

esp32-doom

A proof-of-concept port of PrBoom to the ESP32. Needs psram hardware.
C++
151
star
50

esp-google-iot

Google Cloud IoT SDK as an ESP-IDF Component
C
144
star
51

esp-bsp

Board support components for Espressif development boards
C
141
star
52

esp8266-rtos-sample-code

C
131
star
53

esp-iot-bridge

A smart bridge to make both ESP and the other MCU or smart device can access the Internet.
C
129
star
54

esp-idf-provisioning-ios

Swift
125
star
55

idf-extra-components

Additional components for ESP-IDF, maintained by Espressif
C
122
star
56

esp32-arduino-lib-builder

C
120
star
57

esp-nn

Optimised Neural Network functions for Espressif chipsets
Assembly
103
star
58

esp-zigbee-sdk

Espressif Zigbee SDK
C
99
star
59

idf-installer

ESP IDF Windows Installer
Inno Setup
92
star
60

esp-insights

ESP Insights: A remote diagnostics/observability framework for connected devices
C
91
star
61

esp-rainmaker-android

ESP RainMaker Android app sources
Java
85
star
62

esp-thread-br

Espressif Thread Border Router SDK
C
82
star
63

esp-mesh-lite

A lite version Wi-Fi Mesh, each node can access the network over the IP layer.
C
79
star
64

book-esp32c3-iot-projects

《ESP32-C3 物联网工程开发实战》配套代码
Swift
77
star
65

esp-lwip

Fork of lwIP (https://savannah.nongnu.org/projects/lwip/) with ESP-IDF specific patches
C
77
star
66

esp-ali-smartliving

阿里云生活物联网平台 & 天猫精灵 IoT 开放平台
C
75
star
67

usb-pids

Customer-allocated USB PIDs under the Espressif VID
Shell
75
star
68

pytest-embedded

A pytest plugin that designed for embedded testing
Python
74
star
69

esp32-bt-lib

ESP32 Bluetooth stack (below HCI layer) precompiled libraries
67
star
70

esp-modbus

ESP-Modbus - the officially suppported library for Modbus protocol (serial RS485 + TCP over WiFi or Ethernet).
C
67
star
71

esp8266-nonos-sample-code

C
65
star
72

esp-qcloud

基于 ESP-IDF 原生开发接入腾讯 IoT Explorer,支持 ESP32/ESP32S2,快速实现腾讯连连控制。
C
65
star
73

esp32c3-direct-boot-example

Example of ESP32-C3 (rev. 3 and later) "direct boot" feature.
CMake
64
star
74

esp-idf-cxx

C++ wrapper classes for ESP-IDF components.
C++
63
star
75

esp-wasmachine

The Machine which can run WASM applications.
C
50
star
76

freertos-gdb

Python module for operating with freeRTOS kernel objects in GDB
Python
48
star
77

svd

SVD files for Espressif devices
47
star
78

binutils-esp32ulp

Binutils fork with support for the ESP32 ULP co-processor
C
46
star
79

esp-moonlight

C
44
star
80

xtensa-isa-doc

TeX
42
star
81

esp-privilege-separation

Espressif Privilege Separation Framework
C
41
star
82

esp-rainmaker-ios

ESP RainMaker iOS app sources
Swift
41
star
83

openocd-on-esp32

OpenOCD port running on ESP32-S3 microcontrollers
C
40
star
84

esp-adf-libs

C
38
star
85

idf-component-manager

Tool for installing ESP-IDF components
Python
37
star
86

ESP8266_RTOS_ALINK_DEMO

Alink 1.0 早期版本
Assembly
36
star
87

esp-wolfssl

WolfSSL port for ESP-IDF & ESP8266_RTOS_SDK
C
35
star
88

esp-joylink

Demo project for JD joylink, support esp32 & esp8266.
C
34
star
89

esp31-smsemu

C
34
star
90

esp8266-alink-v1.0

alink v1.0
C
32
star
91

esp-faq

Python
31
star
92

esp-launchpad

Configurable Browser-based Image Flasher
CSS
31
star
93

esp32-alink-demo

Demo project for alink, include embed and SDS
C
30
star
94

esp32-iotivity

Guide you to make your ESP32 support OCF/OIC.
C
29
star
95

newlib-esp32

Version of newlib used in ESP32 ROM and ESP-IDF
C
29
star
96

esp8266-alink-sds

Demo project for alink SDS
C
27
star
97

esp-wdf

Espressif WASM Development Framework.
C
27
star
98

idf-env

idf-env tool helps set up and manage ESP-IDF installations
Rust
25
star
99

esp-cryptoauthlib

Release only fork of https://github.com/MicrochipTech/cryptoauthlib
C
23
star
100

esp-wireless-drivers-3rdparty

Wi-Fi and BT drivers packaged for integration into 3rd party repositories. Work in progress.
C
22
star