Build PlatformIO致命构建错误:liquidcystal.h“;没有这样的文件或目录;

Build PlatformIO致命构建错误:liquidcystal.h“;没有这样的文件或目录;,build,compiler-errors,arduino,platformio,esp32,Build,Compiler Errors,Arduino,Platformio,Esp32,我对Atom/PlatformIO相当陌生,并尝试将其用于Arduino开发,作为Arduino IDE的替代品 ~z~规格~ base code used: Arduino ESP sample code "WifiBlueToothSwitch.ino" Board: ESP-WROOM-32 Additional Components: 1602A (2x16) LCD 在尝试使用LCD屏幕之前,我已通过PlatformIO在ESP模块上成功运行了其他示例代码,但是,当我尝试包含liq

我对Atom/PlatformIO相当陌生,并尝试将其用于Arduino开发,作为Arduino IDE的替代品

~z~规格~

base code used: Arduino ESP sample code "WifiBlueToothSwitch.ino"
Board: ESP-WROOM-32
Additional Components: 1602A (2x16) LCD

在尝试使用LCD屏幕之前,我已通过PlatformIO在ESP模块上成功运行了其他示例代码,但是,当我尝试包含liquidcystal.h库时,它给了我一个生成错误:

src\main.cpp:22:27: fatal error: LiquidCrystal.h: No such file or directory
compilation terminated.
*** [.pioenvs\esp32dev\src\main.o] Error 1
[ERROR] Took 3.34 seconds
到目前为止,在我搜索的几个关于这个问题的站点中,大多数指向缺少添加的“wire.h”头文件,但是即使在将其包含到程序中之后,它仍然会给我这个错误

我的建议包括:

#include <Arduino.h>
#include <WiFi.h>
#include <Wire.h>
#include <LiquidCrystal.h>

编辑2:

我已经通过Arduino IDE编译并运行了这段代码,并且可以确认它是有效的,所以问题似乎出在平台IDE上


编辑3:

按照BMelis的建议,我查看了PlatformIO.ini文件,并在其中添加了以下行:

lib_extra_dirs = C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries
这修复了liquidcystal.h的初始错误,但在生成过程中也产生了以下依赖项错误:

[11/06/17 08:52:58] Processing esp32dev (platform: espressif32; lib_extra_dirs: C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries; board: esp32dev; framework: arduino)

Verbose mode can be enabled via `-v, --verbose` option
Collected 49 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <WiFi> v1.0

|-- <Wire> v1.0
|-- <LiquidCrystal> v1.0.7
Compiling .pioenvs\esp32dev\lib\WiFi\WiFiAP.o
Compiling .pioenvs\esp32dev\lib\WiFi\WiFiGeneric.o
Compiling .pioenvs\esp32dev\lib\WiFi\WiFiMulti.o
Compiling .pioenvs\esp32dev\lib\WiFi\WiFiSTA.o

****ERROR OCCURRED****
C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiAP.cpp:40:37: fatal error: apps/dhcpserver_options.h: No such file or directory
compilation terminated.
*** [.pioenvs\esp32dev\lib\WiFi\WiFiAP.o] Error 1
 [ERROR] Took 8.13 seconds
然而,这并没有解决问题。我不知道现在该怎么办


完整代码:

#include <Arduino.h>
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Sketch shows how to switch between WiFi and BlueTooth or use both
// Button is attached between GPIO 0 and GND and modes are switched with each press

#include <WiFi.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#define STA_SSID "HIDDEN FOR SECURITY"
#define STA_PASS "HIDDEN FOR SECURITY"
#define AP_SSID  "esp32 @ my desk"
#define LED_PIN  5

//LCD variables on analog inputs, but used as digital I/O
//lcd_gnd = gnd
//lcd_vcc = +5v
//lcd_v0 = +5v & pot
const int lcd_rs = 27;
//lcd_rw = gnd
const int lcd_e = 14;
//lcd_d0 = n/a
//lcd_d1 = n/a
//lcd_d2 = n/a
//lcd_d3 = n/a
const int lcd_d4 = 32;
const int lcd_d5 = 33;
const int lcd_d6 = 25;
const int lcd_d7 = 26;
//lcd_bl1 = +5v
//lcd_bl2 = gnd
LiquidCrystal lcd(lcd_rs, lcd_e, lcd_d4, lcd_d5, lcd_d6, lcd_d7);

enum { STEP_BTON, STEP_BTOFF, STEP_STA, STEP_AP, STEP_AP_STA, STEP_OFF, STEP_BT_STA, STEP_END };

void onButton(){
  static uint32_t step = STEP_BTON;
  switch(step){
    case STEP_BTON://BT Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting BT");
      btStart();
    break;
    case STEP_BTOFF://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping BT");
      btStop();
    break;
    case STEP_STA://STA Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA");
      WiFi.begin(STA_SSID, STA_PASS);
    break;
    case STEP_AP://AP Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping STA");
      WiFi.mode(WIFI_AP);

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting AP");
      WiFi.softAP(AP_SSID);
    break;
    case STEP_AP_STA://AP+STA
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA");
      WiFi.begin(STA_SSID, STA_PASS);
    break;
    case STEP_OFF://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping WiFi");
      WiFi.mode(WIFI_OFF);
    break;
    case STEP_BT_STA://BT+STA
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA+BT");
      WiFi.begin(STA_SSID, STA_PASS);
      btStart();
    break;
    case STEP_END://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping WiFi+BT");
      WiFi.mode(WIFI_OFF);
      btStop();
    break;
    default:
    break;
  }
  if(step == STEP_END){
    step = STEP_BTON;
  } else {
    step++;
  }
  //little debounce
  delay(100);
}

void WiFiEvent(WiFiEvent_t event){
    switch(event) {
        case SYSTEM_EVENT_AP_START:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("AP Started");
            Serial.print("AP Started");
            WiFi.softAPsetHostname(AP_SSID);
            break;
        case SYSTEM_EVENT_AP_STOP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("AP Stopped");
            Serial.print("AP Stopped");
            break;
        case SYSTEM_EVENT_STA_START:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Started");
            Serial.print("STA Started");
            WiFi.setHostname(AP_SSID);
            break;
        case SYSTEM_EVENT_STA_CONNECTED:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Connected");
            Serial.print("STA Connected");
            WiFi.enableIpV6();
            break;
        case SYSTEM_EVENT_AP_STA_GOT_IP6:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA IPv6: ");
            Serial.print("STA IPv6: ");
            Serial.println(WiFi.localIPv6());
            break;
        case SYSTEM_EVENT_STA_GOT_IP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA IPv4: ");
            Serial.print("STA IPv4: ");
            lcd.setCursor(0,1);
            lcd.print(WiFi.localIP());
            Serial.print(WiFi.localIP());
            break;
        case SYSTEM_EVENT_STA_DISCONNECTED:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Disconnected");
            Serial.print("STA Disconnected");
            break;
        case SYSTEM_EVENT_STA_STOP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Stopped");
            Serial.print("STA Stopped");
            break;
        default:
            break;
    }
}

void setup() {
    lcd.begin(16, 2); //tells arduino that the LCD is a 16x2 size LCD
    lcd.clear(); //clear any previous text
    lcd.setCursor(0, 0); // set cursor to column 0 of row 0 (first row, first block)

    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW); // LED off
    Serial.begin(115200);
    pinMode(0, INPUT_PULLUP);
    WiFi.onEvent(WiFiEvent);
    Serial.print("ESP32 SDK: ");
    Serial.println(ESP.getSdkVersion());
    Serial.println("Press the button to select the next mode");
    lcd.setCursor(0, 0);
    lcd.println("Press mode btn");
}

void loop() {
    digitalWrite(LED_PIN, HIGH); // Turn on LED
    static uint8_t lastPinState = 1;
    uint8_t pinState = digitalRead(0);
    if(!pinState && lastPinState){
        onButton();
    }
    lastPinState = pinState;
}
#包括
//版权所有2015-2016 Espressif系统(上海)私人有限公司
//
//根据Apache许可证2.0版(以下简称“许可证”)获得许可;
//除非遵守许可证,否则不得使用此文件。
//您可以通过以下方式获得许可证副本:
//     http://www.apache.org/licenses/LICENSE-2.0
//
//除非适用法律要求或书面同意,软件
//根据许可证进行的分发是按“原样”进行分发的,
//无任何明示或暗示的保证或条件。
//请参阅许可证以了解管理权限和权限的特定语言
//许可证下的限制。
//示意图显示了如何在WiFi和蓝牙之间切换或同时使用两者
//按钮连接在GPIO 0和GND之间,模式随每次按下而切换
#包括
#包括
#包括
#定义STA_SSID“为安全而隐藏”
#定义STA_通行证“为安全而隐藏”
#定义AP_SSID“esp32@my desk”
#定义LED_引脚5
//模拟输入上的LCD变量,但用作数字I/O
//lcd_gnd=gnd
//lcd_vcc=+5v
//lcd_v0=+5v和电位计
const int lcd_rs=27;
//lcd_rw=gnd
const int lcd_e=14;
//lcd_d0=不适用
//lcd_d1=不适用
//lcd_d2=不适用
//lcd_d3=不适用
const int lcd_d4=32;
const int lcd_d5=33;
常数int lcd_d6=25;
const int lcd_d7=26;
//lcd_bl1=+5v
//lcd_bl2=接地
液晶液晶显示器(液晶显示器rs、液晶显示器e、液晶显示器d4、液晶显示器d5、液晶显示器d6、液晶显示器d7);
枚举{STEP_BTON、STEP_BTOFF、STEP_STA、STEP_AP、STEP_AP STA、STEP_OFF、STEP_BT STA、STEP_END};
void onButton(){
静态uint32步=步进;
开关(步骤){
案例步骤仅限http://BT
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“启动BT”);
btStart();
打破
案例步骤\ u BTOFF://全部关闭
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“停止BT”);
btStop();
打破
案例步骤_STA://STA仅限
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“启动STA”);
WiFi。开始(STA_SSID、STA_通行证);
打破
案例步骤仅适用于AP://AP
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“停止STA”);
WiFi.模式(WiFi\u AP);
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“启动AP”);
WiFi.softAP(AP_SSID);
打破
案例步骤_AP_STA://AP+STA
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“启动STA”);
WiFi。开始(STA_SSID、STA_通行证);
打破
案例步骤_OFF://全部关闭
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“停止WiFi”);
WiFi.模式(WiFi_关闭);
打破
案例步骤_BT_STA://BT+STA
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“启动STA+BT”);
WiFi。开始(STA_SSID、STA_通行证);
btStart();
打破
案例步骤_END://全部关闭
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“停止WiFi+BT”);
WiFi.模式(WiFi_关闭);
btStop();
打破
违约:
打破
}
如果(步骤==步骤结束){
步骤=步骤_BTON;
}否则{
step++;
}
//小弹跳
延迟(100);
}
无效WiFiEvent(WiFiEvent\u t事件){
开关(事件){
案例系统事件AP启动:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“AP启动”);
串行打印(“AP启动”);
WiFi.softAPsetHostname(AP_SSID);
打破
案例系统事件停止:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“AP停止”);
串行打印(“AP停止”);
打破
案例系统事件开始:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“STA启动”);
串行打印(“STA启动”);
WiFi.setHostname(AP_SSID);
打破
案例系统\事件\状态\已连接:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“STA连接”);
串行打印(“STA连接”);
WiFi.enableIpV6();
打破
案例系统事件状态IP6:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“STA IPv6:”);
串行打印(“STA IPv6:”);
Serial.println(WiFi.localIPv6());
打破
案例系统\u事件\u状态\u获得\u IP:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“STA IPv4:”);
串行打印(“STA IPv4:”);
lcd.setCursor(0,1);
lcd.print(WiFi.localIP());
Serial.print(WiFi.localIP());
打破
案例系统事件状态断开:
lcd.clear();
lcd.setCursor(0,0);
lcd.打印(“STA断开”);
串行打印(“STA断开”);
打破
案例系统事件停止:
lib_extra_dirs = C:\Program Files (x86)\Arduino\hardware\espressif\esp32\tools\sdk\include\lwip\apps
#include <Arduino.h>
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Sketch shows how to switch between WiFi and BlueTooth or use both
// Button is attached between GPIO 0 and GND and modes are switched with each press

#include <WiFi.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#define STA_SSID "HIDDEN FOR SECURITY"
#define STA_PASS "HIDDEN FOR SECURITY"
#define AP_SSID  "esp32 @ my desk"
#define LED_PIN  5

//LCD variables on analog inputs, but used as digital I/O
//lcd_gnd = gnd
//lcd_vcc = +5v
//lcd_v0 = +5v & pot
const int lcd_rs = 27;
//lcd_rw = gnd
const int lcd_e = 14;
//lcd_d0 = n/a
//lcd_d1 = n/a
//lcd_d2 = n/a
//lcd_d3 = n/a
const int lcd_d4 = 32;
const int lcd_d5 = 33;
const int lcd_d6 = 25;
const int lcd_d7 = 26;
//lcd_bl1 = +5v
//lcd_bl2 = gnd
LiquidCrystal lcd(lcd_rs, lcd_e, lcd_d4, lcd_d5, lcd_d6, lcd_d7);

enum { STEP_BTON, STEP_BTOFF, STEP_STA, STEP_AP, STEP_AP_STA, STEP_OFF, STEP_BT_STA, STEP_END };

void onButton(){
  static uint32_t step = STEP_BTON;
  switch(step){
    case STEP_BTON://BT Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting BT");
      btStart();
    break;
    case STEP_BTOFF://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping BT");
      btStop();
    break;
    case STEP_STA://STA Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA");
      WiFi.begin(STA_SSID, STA_PASS);
    break;
    case STEP_AP://AP Only
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping STA");
      WiFi.mode(WIFI_AP);

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting AP");
      WiFi.softAP(AP_SSID);
    break;
    case STEP_AP_STA://AP+STA
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA");
      WiFi.begin(STA_SSID, STA_PASS);
    break;
    case STEP_OFF://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping WiFi");
      WiFi.mode(WIFI_OFF);
    break;
    case STEP_BT_STA://BT+STA
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Starting STA+BT");
      WiFi.begin(STA_SSID, STA_PASS);
      btStart();
    break;
    case STEP_END://All Off
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Stopping WiFi+BT");
      WiFi.mode(WIFI_OFF);
      btStop();
    break;
    default:
    break;
  }
  if(step == STEP_END){
    step = STEP_BTON;
  } else {
    step++;
  }
  //little debounce
  delay(100);
}

void WiFiEvent(WiFiEvent_t event){
    switch(event) {
        case SYSTEM_EVENT_AP_START:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("AP Started");
            Serial.print("AP Started");
            WiFi.softAPsetHostname(AP_SSID);
            break;
        case SYSTEM_EVENT_AP_STOP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("AP Stopped");
            Serial.print("AP Stopped");
            break;
        case SYSTEM_EVENT_STA_START:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Started");
            Serial.print("STA Started");
            WiFi.setHostname(AP_SSID);
            break;
        case SYSTEM_EVENT_STA_CONNECTED:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Connected");
            Serial.print("STA Connected");
            WiFi.enableIpV6();
            break;
        case SYSTEM_EVENT_AP_STA_GOT_IP6:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA IPv6: ");
            Serial.print("STA IPv6: ");
            Serial.println(WiFi.localIPv6());
            break;
        case SYSTEM_EVENT_STA_GOT_IP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA IPv4: ");
            Serial.print("STA IPv4: ");
            lcd.setCursor(0,1);
            lcd.print(WiFi.localIP());
            Serial.print(WiFi.localIP());
            break;
        case SYSTEM_EVENT_STA_DISCONNECTED:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Disconnected");
            Serial.print("STA Disconnected");
            break;
        case SYSTEM_EVENT_STA_STOP:
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("STA Stopped");
            Serial.print("STA Stopped");
            break;
        default:
            break;
    }
}

void setup() {
    lcd.begin(16, 2); //tells arduino that the LCD is a 16x2 size LCD
    lcd.clear(); //clear any previous text
    lcd.setCursor(0, 0); // set cursor to column 0 of row 0 (first row, first block)

    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW); // LED off
    Serial.begin(115200);
    pinMode(0, INPUT_PULLUP);
    WiFi.onEvent(WiFiEvent);
    Serial.print("ESP32 SDK: ");
    Serial.println(ESP.getSdkVersion());
    Serial.println("Press the button to select the next mode");
    lcd.setCursor(0, 0);
    lcd.println("Press mode btn");
}

void loop() {
    digitalWrite(LED_PIN, HIGH); // Turn on LED
    static uint8_t lastPinState = 1;
    uint8_t pinState = digitalRead(0);
    if(!pinState && lastPinState){
        onButton();
    }
    lastPinState = pinState;
}
[env:lolin32]
;platform = espressif32
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
board = lolin32
framework = arduino
lib_extra_dirs = ..\libraries
lib_deps = 
  https://urltotherepo.git
pio lib install "LiquidCrystal"
[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps = LiquidCrystal@1.5.0 #<--important line