Skip to content
ショップ

PlatformIO settings for ESP32 MCU

Instead of the Arduino IDE, you can also use PlatformIO as the Leafony development environment. PlatformIO makes it easy to manage things like library versioning, board configuration, etc., as well as to use. You can take advantage of the powerful plug-ins for Visual Studio Code to make your development more comfortable.

PlatformIO is a plug-in for Visual Studio Code (VSCode). You need to install the following software in advance.

  1. Launch VSCode and open the Extensions tab.
  2. Enter PlatformIO IDE into the search window.
  3. Install the PlatformIO IDE.

  1. Press the PlatformIO Home button to display the PlatformIO home.
  2. Click on New Project.
  3. Name your project and select the appropriate board on Board.
  4. Open the main.cpp in the src folder and paste the following code.
#include <Arduino.h>
void setup() {
// LEDピンを出力ピンに設定
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // LEDを点灯
delay(999); // 1秒待つ
digitalWrite(LED_BUILTIN, LOW); // LEDを消灯
delay(999); // 1秒待つ
}
  1. Press the Build button to build the project.
  2. Connect Leafony to your PC.
  3. Press the Upload button to write your project to Leafony.
  4. Press the Serial Port Monitor button to display the serial monitor and show the input status of the button.
  1. Press the PlatformIO Home button to display the PlatformIO home.
  2. Open the Libraries tab.
  3. Type OPT3001 in the search window to search the library for the illuminance sensor OPT3001.
  4. ClosedCube OPT3001をクリック。
  5. Click the Add to Project button and add with Add.
  6. Open the PlatformIO.ini.
  7. Check that closedcube/ClosedCube OPT3001 @ <version> is added to the lib_deps option.
  8. If you paste the code below, you can easily set up the library environment without doing the above.
[env:pro8MHzatmega328]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino
lib_deps =
closedcube/ClosedCube OPT3001 @ ^1.1.2
adafruit/Adafruit LIS3DH@1.1.2
https://github.com/ameltech/sme-hts221-library.git
https://github.com/Leafony/TBGLib
tomozh/ST7032@0.0.0-alpha+sha.501bf64fe6
paulstoffregen/MsTimer2@^1.1
adafruit/RTClib@^1.11.2
adafruit/Adafruit Unified Sensor@^1.1.4
adafruit/Adafruit BusIO@^1.5.0

When you press the Serial Port Monitor button, the serial monitor is displayed.

For more information on how to use PlatformIO for VSCode, please refer to the official documentation.