当前位置:   article > 正文

EPS32+Platform+Arduino 跑马灯

EPS32+Platform+Arduino 跑马灯

软硬件平台

硬件使用ESP32 D0WQ6,是在淘宝上购买的一个核心功能板,用做simplFOC的核心控制板。

软件平台使用ArduinoArduino-ESP32有详细介绍ESP32针对arduino平台做的library和API接口

IDE软件采用PlatformIO,主要因为这个IDE比Arduino IDE的编译速度快很多。Arduino IDE简单易用,但是编译上传实在太慢,忍无可忍才找到了PlatforIO来替换

环境搭建

platformIO整个环境的搭建和使用已经有很多文章了,可以参考VSCode + PlatformIO + STM32/ESP32 ARDUINO。这里主要记录下测试跑马灯时的问题。具体程序可以看下节跑马灯程序及配置。

新建工程后,首次编译没有问题,首次点击 upload 提示Tool Manager: Installing platformio/tool-mkspiffs @ ~2.230.0,这里需要安装一系列的upload工具套件,必须关闭网络加速/代理,否则会一直停在这里,超时后会报错:终端将被任务重用 按任意键关闭。
在这里插入图片描述
我的环境需要安装的套件:

Installing platformio/tool-mkspiffs @ ~2.230.0
Installing platformio/tool-mklittlefs @ ~1.203.0
Installing platformio/tool-mkfatfs @ ~2.0.0
  • 1
  • 2
  • 3

跑马灯程序及配置

跑马灯程序代码如下:

#include <Arduino.h>

#define LED 22
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED as an output.
  pinMode(LED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                       // wait for a second
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

配置文件platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

upload_port = COM10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

如下图点击上传后,platformio会进行编译,上传,过程提示如下
在这里插入图片描述

 *  正在执行任务: C:\Users\49196\.platformio\penv\Scripts\platformio.exe run --target upload --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.0.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20003.220626 (2.0.3)
 - tool-esptoolpy @ 1.30300.0 (3.3.0)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Linking .pio\build\esp32dev\firmware.elf
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.9% (used 16148 bytes from 327680 bytes)
Flash: [==        ]  16.2% (used 212701 bytes from 1310720 bytes)
Building .pio\build\esp32dev\firmware.bin
esptool.py v3.3
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: COM10
Uploading .pio\build\esp32dev\firmware.bin
esptool.py v3.3
Serial port COM10
Connecting.....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 78:21:84:79:43:2c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00044fff...
Compressed 17088 bytes to 11848...
Writing at 0x00001000... (100 %)
Wrote 17088 bytes (11848 compressed) at 0x00001000 in 0.5 seconds (effective 286.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 586.7 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 656.9 kbit/s)...
Hash of data verified.
Compressed 213088 bytes to 115386...
Writing at 0x00010000... (12 %)
Writing at 0x0001dcac... (25 %)
Writing at 0x0002334b... (37 %)
Writing at 0x000285ed... (50 %)
Writing at 0x0002e68a... (62 %)
Writing at 0x00038862... (75 %)
Writing at 0x0003e351... (87 %)
Writing at 0x00043c6c... (100 %)
Wrote 213088 bytes (115386 compressed) at 0x00010000 in 2.9 seconds (effective 592.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
================================================= [SUCCESS] Took 14.34 seconds =================================================
 *  终端将被任务重用,按任意键关闭。 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86

看到[SUCCESS] 提示,耗时14.34 seconds。下载运行成功

参考

  1. 使用VScode开发ESP32,PlatformIO开发ESP32
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号