1, Install VS Code
Official website https://code.visualstudio.com/ , download and install directly.
2, Installing the Arduino IDE
Official website https://www.arduino.cc/en/software
If the official website is too slow, you can also download it elsewhere https://www.arduino.cn/thread-5838-1-1.html
3, Install ESP8266 support package in Arduino IDE
reference resources https://blog.csdn.net/weixin_42298881/article/details/112575889
fill http://arduino.esp8266.com/stable/package_esp8266com_index.json
Open the development board manager, find the package of ESP8266 and start the installation:
There are often download failures. Just try to change the hotspot several times. It's really not possible. You can solve it by yourself.
4, Install the Arduino extension component in VS Code
5, Configuring the Arduino environment
1. Modify setting.json and add two lines of code to solve the error reporting problem of undefined identifier:
"C_Cpp.intelliSenseEngineFallback": "Disabled", "C_Cpp.intelliSenseEngine": "Tag Parser",
2. Find the arduino extended installation directory of vscode, find the util.js file and open it:
C:\Users\JustDooiT\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.2\out\src\common\util.js
Comment out the following code at line 205 to solve the problem of output garbled Code:
3. The environment here is basically ready. You can start writing code! Create a new. ino file in your project directory, and then write your own code.
4. After the code is written, take the esp8266 nodemocu as an example. After I connect the development board to the computer, I must first select the development board model and port number. After that, click the button in the upper right corner to verify. After verification, I can burn it.
Generally speaking, after selecting the development board model and verifying it, a. vscode folder will be automatically generated for us:
There are two files, Arduino. JSON and c_cpp_properties.json. arduino.json contains some configuration information about the development board, which will be automatically modified for us after verifying the program; c_cpp_properties.json is used to configure the compiler environment, including initiator code, number of bits, compilation options, startup settings, compilation mode, header file path, etc. This file is important, but we generally don't care about it. If the file is not automatically generated, you can manually generate it or directly copy someone else's folder through the following methods:
(1) Create c_cpp_properties.json file:
Press Ctrl+Shift+P to call up the control window, enter edit or configuration, select "C/Cpp:Edit Configurations", and then generate C in the. vscode folder_ cpp_ Properties.json file.
(2) Modify C as appropriate_ cpp_ Properties.json file:
View the path of ESP8266 support package:
Modify C according to your own header file directory_ cpp_ properties.json:
The C generated after I select esp8266 nodemocu is posted below_ cpp_ Properties.json file, you can refer to the format and modify it yourself.
{ "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" ] } ] }