You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
1.3 KiB
88 lines
1.3 KiB
5 years ago
|
---
|
||
|
title: ESP32 PlatformIO
|
||
|
description: ESP32 project setup
|
||
|
date: 2020-04-23
|
||
|
tags: ["esp32", "project"]
|
||
|
categories: ["tutorial"]
|
||
|
author: hendrik
|
||
|
draft: true
|
||
|
---
|
||
|
|
||
|
## Install PlatformIO
|
||
|
|
||
|
```
|
||
|
apt install platformio
|
||
|
platformio platform update
|
||
|
```
|
||
|
|
||
|
## Project setup
|
||
|
|
||
|
Choose your development board from the list. You can see all supported boards with the command `platformio boards espressif32`
|
||
|
|
||
|
Now create your new project:
|
||
|
|
||
|
```
|
||
|
cd ~/Projects/esp32/
|
||
|
mkdir new_project
|
||
|
cd new_project
|
||
|
platformio project init --board esp-wrover-kit
|
||
|
```
|
||
|
|
||
|
configuration:
|
||
|
|
||
|
platformio.ini:
|
||
|
```
|
||
|
[env:esp-wrover-kit]
|
||
|
platform = espressif32
|
||
|
board = esp-wrover-kit
|
||
|
framework = arduino
|
||
|
monitor_speed = 115200
|
||
|
```
|
||
|
|
||
|
create the main:
|
||
|
|
||
|
src/main.cpp:
|
||
|
```
|
||
|
/**
|
||
|
* Blink
|
||
|
*
|
||
|
* Turns on an LED on for one second,
|
||
|
* then off for one second, repeatedly.
|
||
|
*/
|
||
|
#include "Arduino.h"
|
||
|
|
||
|
#ifndef LED_BUILTIN
|
||
|
#define LED_BUILTIN 13
|
||
|
#endif
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
// initialize LED digital pin as an output.
|
||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
// turn the LED on (HIGH is the voltage level)
|
||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||
|
|
||
|
// wait for a second
|
||
|
delay(1000);
|
||
|
|
||
|
// turn the LED off by making the voltage LOW
|
||
|
digitalWrite(LED_BUILTIN, LOW);
|
||
|
|
||
|
// wait for a second
|
||
|
delay(1000);
|
||
|
}
|
||
|
```
|
||
|
|
||
|
now compile and upload your program
|
||
|
|
||
|
platformio run
|
||
|
platformio run --target upload
|
||
|
platformio device monitor
|
||
|
|
||
|
## Git
|
||
|
git init
|