IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> VSCode搭建Arduino环境编译ESP8266工程 -> 正文阅读

[开发工具]VSCode搭建Arduino环境编译ESP8266工程

一、安装VS Code

官网https://code.visualstudio.com/,直接下载安装即可。

二、安装Arduino IDE

官网https://www.arduino.cc/en/software
嫌官网慢的也可以到别的地方下载 https://www.arduino.cn/thread-5838-1-1.html

三、在Arduino IDE 中安装ESP8266 支持包

参考https://blog.csdn.net/weixin_42298881/article/details/112575889

image-20210503233729672

填入 http://arduino.esp8266.com/stable/package_esp8266com_index.json

打开开发板管理器找到ESP8266的包开始安装:

image-20210503233846759

经常会出现下载失败的情况,换热点多试几次就好了,实在不行可以自行百度解决方法。

四、在VS Code 中安装Arduino 拓展组件

image-20210509162650308

image-20210509163004221

五、配置Arduino 环境

1.修改setting.json,加入两行代码,解决未定义标识符报错问题:

image-20210503224830190

image-20210503224859679

    "C_Cpp.intelliSenseEngineFallback": "Disabled",
    "C_Cpp.intelliSenseEngine": "Tag Parser",

2.找到vscode的arduino拓展的安装目录,找到util.js这个文件并打开:

C:\Users\JustDooiT\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.2\out\src\common\util.js

将205 行处的如下代码注释掉,解决输出乱码问题:

image-20210503230730473

3.到这里环境基本上已经配好了,可以开始写代码啦!在自己的工程目录下新建一个.ino文件,然后编写自己的代码。

image-20210509163518896

4.代码写好之后,以ESP8266 NodeMCU 为例,我将开发板连接到电脑上后,首先要选择开发板型号和端口号,选完之后点击右上角按钮进行验证,验证无误后就可以进行烧录了。

image-20210509154130991

image-20210509164109837

image-20210509164523791

一般来说,选择开发板型号并进行验证完之后会为我们自动生成一个.vscode文件夹:

image-20210509154723618

image-20210509155555223

里面有两个文件,arduino.json 和c_cpp_properties.json。其中arduino.json 包含一些关于开发板的配置信息,在验证完程序后会为我们自动修改;c_cpp_properties.json 用于配置编译器环境的,包括启动器代号、位数、编译选项、启动设置、编译模式、头文件路径等,这个文件比较重要,但一般不用我们管。如果没有自动生成该文件,可通过以下方法手动生成或者直接把别人的这个文件夹复制过来:

(1)创建c_cpp_properties.json 文件:

按Ctrl+Shift+P调出控制窗口,输入edit或者configuration,选择"C/Cpp:Edit Configurations",然后就在.vscode文件夹下生成了c_cpp_properties.json文件。

(2)根据具体情况修改c_cpp_properties.json 文件:

查看ESP8266支持包的路径:

image-20210503223220467

image-20210503223834281

根据自己的头文件目录修改c_cpp_properties.json:

image-20210503223431358

image-20210503224601123

下面贴出我选择ESP8266 NodeMCU 后生成的c_cpp_properties.json 文件,大家可以参考格式自行修改。

{
    "version": 4,
    "configurations": [
        {
            "name": "Win32",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe",
            "compilerArgs": [],
            "intelliSenseMode": "windows-msvc-x64",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "forcedInclude": [],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ]
        },
        {
            "name": "Arduino",
            "compilerPath": "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\bin\\xtensa-lx106-elf-g++",
            "compilerArgs": [
                "-U__STRICT_ANSI__",
                "-w",
                "-mlongcalls",
                "-mtext-section-literals",
                "-fno-rtti",
                "-falign-functions=4",
                "-std=gnu++11"
            ],
            "intelliSenseMode": "gcc-x64",
            "includePath": [
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\tools\\sdk\\include",
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\tools\\sdk\\lwip2\\include",
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\tools\\sdk\\libc\\xtensa-lx106-elf\\include",
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\cores\\esp8266",
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\variants\\nodemcu",
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\libraries\\ESP8266WiFi\\src",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include\\c++\\4.8.2",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include\\c++\\4.8.2\\xtensa-lx106-elf",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include\\c++\\4.8.2\\backward",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\lib\\gcc\\xtensa-lx106-elf\\4.8.2\\include",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\lib\\gcc\\xtensa-lx106-elf\\4.8.2\\include-fixed",
                "c:\\users\\justdooit\\appdata\\local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506\\xtensa-lx106-elf\\include"
            ],
            "forcedInclude": [
                "C:\\Users\\JustDooiT\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\cores\\esp8266\\Arduino.h"
            ],
            "cStandard": "c11",
            "cppStandard": "c++11",
            "defines": [
                "__ets__",
                "ICACHE_FLASH",
                "NONOSDK22x_190703=1",
                "F_CPU=80000000L",
                "LWIP_OPEN_SRC",
                "TCP_MSS=536",
                "LWIP_FEATURES=1",
                "LWIP_IPV6=0",
                "ARDUINO=10813",
                "ARDUINO_ESP8266_NODEMCU",
                "ARDUINO_ARCH_ESP8266",
                "ARDUINO_BOARD=\"ESP8266_NODEMCU\"",
                "LED_BUILTIN=2",
                "FLASHMODE_DIO",
                "ESP8266",
                "__DBL_MIN_EXP__=(-1021)",
                "__UINT_LEAST16_MAX__=65535",
                "__ATOMIC_ACQUIRE=2",
                "__FLT_MIN__=1.1754943508222875e-38F",
                "__UINT_LEAST8_TYPE__=unsigned char",
                "__INTMAX_C(c)=c ## LL",
                "__CHAR_BIT__=8",
                "__UINT8_MAX__=255",
                "__WINT_MAX__=4294967295U",
                "__ORDER_LITTLE_ENDIAN__=1234",
                "__SIZE_MAX__=4294967295U",
                "__WCHAR_MAX__=65535",
                "__DBL_DENORM_MIN__=double(4.9406564584124654e-324L)",
                "__GCC_ATOMIC_CHAR_LOCK_FREE=1",
                "__FLT_EVAL_METHOD__=0",
                "__GCC_ATOMIC_CHAR32_T_LOCK_FREE=1",
                "__UINT_FAST64_MAX__=18446744073709551615ULL",
                "__SIG_ATOMIC_TYPE__=int",
                "__DBL_MIN_10_EXP__=(-307)",
                "__FINITE_MATH_ONLY__=0",
                "__GNUC_PATCHLEVEL__=2",
                "__UINT_FAST8_MAX__=4294967295U",
                "__DEC64_MAX_EXP__=385",
                "__INT8_C(c)=c",
                "__UINT_LEAST64_MAX__=18446744073709551615ULL",
                "__SHRT_MAX__=32767",
                "__LDBL_MAX__=1.7976931348623157e+308L",
                "__UINT_LEAST8_MAX__=255",
                "__GCC_ATOMIC_BOOL_LOCK_FREE=1",
                "__UINTMAX_TYPE__=long long unsigned int",
                "__DEC32_EPSILON__=1E-6DF",
                "__CHAR_UNSIGNED__=1",
                "__UINT32_MAX__=4294967295UL",
                "__LDBL_MAX_EXP__=1024",
                "__WINT_MIN__=0U",
                "__SCHAR_MAX__=127",
                "__WCHAR_MIN__=0",
                "__INT64_C(c)=c ## LL",
                "__DBL_DIG__=15",
                "__GCC_ATOMIC_POINTER_LOCK_FREE=1",
                "__XTENSA_CALL0_ABI__=1",
                "__SIZEOF_INT__=4",
                "__SIZEOF_POINTER__=4",
                "__GCC_ATOMIC_CHAR16_T_LOCK_FREE=1",
                "__USER_LABEL_PREFIX__",
                "__STDC_HOSTED__=1",
                "__LDBL_HAS_INFINITY__=1",
                "__XTENSA_EL__=1",
                "__FLT_EPSILON__=1.1920928955078125e-7F",
                "__GXX_WEAK__=1",
                "__LDBL_MIN__=2.2250738585072014e-308L",
                "__DEC32_MAX__=9.999999E96DF",
                "__INT32_MAX__=2147483647L",
                "__SIZEOF_LONG__=4",
                "__UINT16_C(c)=c",
                "__DECIMAL_DIG__=17",
                "__LDBL_HAS_QUIET_NAN__=1",
                "__GNUC__=4",
                "__GXX_RTTI=1",
                "__FLT_HAS_DENORM__=1",
                "__SIZEOF_LONG_DOUBLE__=8",
                "__BIGGEST_ALIGNMENT__=16",
                "__DBL_MAX__=double(1.7976931348623157e+308L)",
                "__INT_FAST32_MAX__=2147483647",
                "__DBL_HAS_INFINITY__=1",
                "__INT64_MAX__=9223372036854775807LL",
                "__DEC32_MIN_EXP__=(-94)",
                "__INT_FAST16_TYPE__=int",
                "__LDBL_HAS_DENORM__=1",
                "__cplusplus=199711L",
                "__DEC128_MAX__=9.999999999999999999999999999999999E6144DL",
                "__INT_LEAST32_MAX__=2147483647L",
                "__DEC32_MIN__=1E-95DF",
                "__DEPRECATED=1",
                "__DBL_MAX_EXP__=1024",
                "__DEC128_EPSILON__=1E-33DL",
                "__PTRDIFF_MAX__=2147483647",
                "__GNUG__=4",
                "__LONG_LONG_MAX__=9223372036854775807LL",
                "__SIZEOF_SIZE_T__=4",
                "__SIZEOF_WINT_T__=4",
                "__GXX_ABI_VERSION=1002",
                "__FLT_MIN_EXP__=(-125)",
                "__INT_FAST64_TYPE__=long long int",
                "__DBL_MIN__=double(2.2250738585072014e-308L)",
                "__FLT_MIN_10_EXP__=(-37)",
                "__DEC128_MIN__=1E-6143DL",
                "__REGISTER_PREFIX__",
                "__UINT16_MAX__=65535",
                "__DBL_HAS_DENORM__=1",
                "__UINT8_TYPE__=unsigned char",
                "__NO_INLINE__=1",
                "__FLT_MANT_DIG__=24",
                "__VERSION__=\"4.8.2\"",
                "__UINT64_C(c)=c ## ULL",
                "__XTENSA_SOFT_FLOAT__=1",
                "__GCC_ATOMIC_INT_LOCK_FREE=1",
                "__FLOAT_WORD_ORDER__=__ORDER_LITTLE_ENDIAN__",
                "__INT32_C(c)=c ## L",
                "__DEC64_EPSILON__=1E-15DD",
                "__ORDER_PDP_ENDIAN__=3412",
                "__DEC128_MIN_EXP__=(-6142)",
                "__INT_FAST32_TYPE__=int",
                "__UINT_LEAST16_TYPE__=short unsigned int",
                "__INT16_MAX__=32767",
                "__SIZE_TYPE__=unsigned int",
                "__UINT64_MAX__=18446744073709551615ULL",
                "__INT8_TYPE__=signed char",
                "__ELF__=1",
                "__xtensa__=1",
                "__FLT_RADIX__=2",
                "__INT_LEAST16_TYPE__=short int",
                "__LDBL_EPSILON__=2.2204460492503131e-16L",
                "__UINTMAX_C(c)=c ## ULL",
                "__SIG_ATOMIC_MAX__=2147483647",
                "__GCC_ATOMIC_WCHAR_T_LOCK_FREE=1",
                "__SIZEOF_PTRDIFF_T__=4",
                "__DEC32_SUBNORMAL_MIN__=0.000001E-95DF",
                "__INT_FAST16_MAX__=2147483647",
                "__UINT_FAST32_MAX__=4294967295U",
                "__UINT_LEAST64_TYPE__=long long unsigned int",
                "__FLT_HAS_QUIET_NAN__=1",
                "__FLT_MAX_10_EXP__=38",
                "__LONG_MAX__=2147483647L",
                "__DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL",
                "__FLT_HAS_INFINITY__=1",
                "__UINT_FAST16_TYPE__=unsigned int",
                "__DEC64_MAX__=9.999999999999999E384DD",
                "__CHAR16_TYPE__=short unsigned int",
                "__PRAGMA_REDEFINE_EXTNAME=1",
                "__INT_LEAST16_MAX__=32767",
                "__DEC64_MANT_DIG__=16",
                "__UINT_LEAST32_MAX__=4294967295UL",
                "__GCC_ATOMIC_LONG_LOCK_FREE=1",
                "__INT_LEAST64_TYPE__=long long int",
                "__INT16_TYPE__=short int",
                "__INT_LEAST8_TYPE__=signed char",
                "__DEC32_MAX_EXP__=97",
                "__INT_FAST8_MAX__=2147483647",
                "__INTPTR_MAX__=2147483647",
                "__EXCEPTIONS=1",
                "__LDBL_MANT_DIG__=53",
                "__DBL_HAS_QUIET_NAN__=1",
                "__SIG_ATOMIC_MIN__=(-__SIG_ATOMIC_MAX__ - 1)",
                "__INTPTR_TYPE__=int",
                "__UINT16_TYPE__=short unsigned int",
                "__WCHAR_TYPE__=short unsigned int",
                "__SIZEOF_FLOAT__=4",
                "__UINTPTR_MAX__=4294967295U",
                "__DEC64_MIN_EXP__=(-382)",
                "__INT_FAST64_MAX__=9223372036854775807LL",
                "__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1",
                "__FLT_DIG__=6",
                "__UINT_FAST64_TYPE__=long long unsigned int",
                "__INT_MAX__=2147483647",
                "__INT64_TYPE__=long long int",
                "__FLT_MAX_EXP__=128",
                "__DBL_MANT_DIG__=53",
                "__INT_LEAST64_MAX__=9223372036854775807LL",
                "__DEC64_MIN__=1E-383DD",
                "__WINT_TYPE__=unsigned int",
                "__UINT_LEAST32_TYPE__=long unsigned int",
                "__SIZEOF_SHORT__=2",
                "__LDBL_MIN_EXP__=(-1021)",
                "__INT_LEAST8_MAX__=127",
                "__WCHAR_UNSIGNED__=1",
                "__LDBL_MAX_10_EXP__=308",
                "__ATOMIC_RELAXED=0",
                "__DBL_EPSILON__=double(2.2204460492503131e-16L)",
                "__UINT8_C(c)=c",
                "__INT_LEAST32_TYPE__=long int",
                "__SIZEOF_WCHAR_T__=2",
                "__UINT64_TYPE__=long long unsigned int",
                "__INT_FAST8_TYPE__=int",
                "__DBL_DECIMAL_DIG__=17",
                "__DEC_EVAL_METHOD__=2",
                "__XTENSA__=1",
                "__ORDER_BIG_ENDIAN__=4321",
                "__UINT32_C(c)=c ## UL",
                "__INTMAX_MAX__=9223372036854775807LL",
                "__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__",
                "__FLT_DENORM_MIN__=1.4012984643248171e-45F",
                "__INT8_MAX__=127",
                "__UINT_FAST32_TYPE__=unsigned int",
                "__CHAR32_TYPE__=long unsigned int",
                "__FLT_MAX__=3.4028234663852886e+38F",
                "__INT32_TYPE__=long int",
                "__SIZEOF_DOUBLE__=8",
                "__INTMAX_TYPE__=long long int",
                "__DEC128_MAX_EXP__=6145",
                "__ATOMIC_CONSUME=1",
                "__GNUC_MINOR__=8",
                "__UINTMAX_MAX__=18446744073709551615ULL",
                "__DEC32_MANT_DIG__=7",
                "__DBL_MAX_10_EXP__=308",
                "__LDBL_DENORM_MIN__=4.9406564584124654e-324L",
                "__INT16_C(c)=c",
                "__STDC__=1",
                "__PTRDIFF_TYPE__=int",
                "__ATOMIC_SEQ_CST=5",
                "__UINT32_TYPE__=long unsigned int",
                "__UINTPTR_TYPE__=unsigned int",
                "__DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD",
                "__DEC128_MANT_DIG__=34",
                "__LDBL_MIN_10_EXP__=(-307)",
                "__SIZEOF_LONG_LONG__=8",
                "__GCC_ATOMIC_LLONG_LOCK_FREE=1",
                "__LDBL_DIG__=15",
                "__FLT_DECIMAL_DIG__=9",
                "__UINT_FAST16_MAX__=4294967295U",
                "__GNUC_GNU_INLINE__=1",
                "__GCC_ATOMIC_SHORT_LOCK_FREE=1",
                "__UINT_FAST8_TYPE__=unsigned int",
                "__ATOMIC_ACQ_REL=4",
                "__ATOMIC_RELEASE=3",
                "USBCON"
            ]
        }
    ]
}
  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-10-07 14:01:24  更:2021-10-07 14:02:31 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/16 1:16:53-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码