Spis treści

ESP32

Pinout

Podstawowy kod

#include "Arduino.h"
 
#define BUILT_LED 2
 
 
void setup()
{
  Serial.begin(115200);
 
  pinMode(BUILT_LED, OUTPUT);
  digitalWrite(BUILT_LED, LOW);
 
}
 
void loop()
{
 
  vTaskDelay(pdMS_TO_TICKS(10));
}



platformio.ini

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200



Dane konfiguracyjne

Umieszczenie danych konfiguracyjnych w osobnym pliku:
config.h

#ifndef CONFIG_H
#define CONFIG_H
 
#include <Arduino.h>
 
const String DEVICE_ID = "00";
 
const char* WIFI_SSID = "ssid";
const char* WIFI_PASSWORD = "password";
 
const String API_URL = "http://127.0.0.1:8000";
const String API_USERNAME = "username";
const String API_PASSWORD = "password";
 
#endif


A we właściwym pliku wystarczy zaimportować plik konfiguracyjny:

#include <Arduino.h>
#include "config.h"
 
...
 
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);