Browse Source

platformio snippet

main
Hendrik Langer 4 years ago
parent
commit
b890ce6082
  1. BIN
      content/snippets/esp32/platformio/esp-lora-board.jpg
  2. 1
      content/snippets/esp32/platformio/index.de.md
  3. 143
      content/snippets/esp32/platformio/index.en.md
  4. 1
      content/snippets/platformio.de.md
  5. 87
      content/snippets/platformio.en.md

BIN
content/snippets/esp32/platformio/esp-lora-board.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

1
content/snippets/esp32/platformio/index.de.md

@ -0,0 +1 @@
index.en.md

143
content/snippets/esp32/platformio/index.en.md

@ -0,0 +1,143 @@
---
title: ESP32 PlatformIO
description: Microcontroller development project setup / template
date: 2020-05-03
tags: ["esp32", "project", "platformio", "microcontroller", "programming"]
categories: ["tutorial"]
author: hendrik
license: WTFPL
---
![ESP32 Lora Board](esp-lora-board.jpg)
## Install PlatformIO
```shell
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:
```shell
cd ~/Projects/esp32/
mkdir new_project
cd new_project
platformio project init --board esp-wrover-kit
```
## Configuration
#### platformio.ini:
```ini
[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
#build_flags =
# -DBOARD_HAS_PSRAM
# -mfix-esp32-psram-cache-issue
# -DCONFIG_SPIRAM_CACHE_WORKAROUND
# -DCORE_DEBUG_LEVEL=5
#
#board_build.partitions = huge_app.csv
#
#lib_deps =
# TFT_eSPI
```
## Code
#### src/main.cpp:
```c++
/**
* 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
```shell
platformio run
platformio run --target upload
platformio device monitor
```
## SPIFFS
create folder `data/`
```shell
platformio run --target uploadfs
```
## Git
#### .gitignore:
```
.pio
```
and push to your project on github or gitlab:
```shell
touch README.md
git init
git commit -m "first commit"
git remote add origin https://gitlab.com/username/new_project.git
git push -u origin master
```
## License
#### LICENSE:
```
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified copies of
this license document, and changing it is allowed as long as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
```

1
content/snippets/platformio.de.md

@ -1 +0,0 @@
platformio.en.md

87
content/snippets/platformio.en.md

@ -1,87 +0,0 @@
---
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
Loading…
Cancel
Save