How to handle compile errors thrown from M5Stack libraries in Arduino - c++

I'm currently trying to program my M5Stack with an ESP32 chip in it. I downloaded (or atleast I thought) all of the dependencies needed to upload to the board, but I can't even get my program to compile. I downloaded the ESP32 throught the board manager, I followed the M5Stack tutorial on their website and seem to be finding errors in thheir library itself. I'm not sure how to fix, below is my code and below that are the error messages im getting.
#include <M5Stack.h>
#include <Wire.h>
#define SPEAKER_PIN 25
#include "config.h"
AdafruitIO_Feed *voltage1 = io.feed("V1");
AdafruitIO_Feed *voltage2 = io.feed("V2");
AdafruitIO_Feed *curr = io.feed("Current");
void setup() {
// put your setup code here, to run once:
M5.begin(true, true, true, false);
Serial.begin(115200);
dacWrite(25,0);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(5);
// wait for serial monitor to open
while(! Serial);
Serial.print("Connecting to Adafruit IO");
// connect to io.adafruit.com
io.connect();
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
// ads.getAddr_ADS1100(ADS1100_DEFAULT_ADDRESS);
// ads.setGain(GAIN_ONE);
// ads.setMode(MODE_CONTIN);
// ads.setRate(RATE_32);
// ads.setOSMode(OSMODE_SINGLE);
// ads.begin();
}
void loop() {
io.run();
// put your main code here, to run repeatedly:
float v1 = (float)analogRead(36) / 4096 * 17.4 * 0.975;
float v2 = (float)analogRead(35) / 4096 * 17.4 * 0.975;
float current = (float)analogRead(5);
Serial.print("v1: ");
Serial.print(v1);
Serial.println("V");
Serial.print("v2: ");
Serial.print(v2);
Serial.println("V");
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setCursor(10, 10);
M5.Lcd.print("V1: ");
M5.Lcd.print(v1);
M5.Lcd.print("V");
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setCursor(10, 70);
M5.Lcd.print("V2: ");
M5.Lcd.print(v2);
M5.Lcd.print("V");
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setCursor(10, 140);
M5.Lcd.print("Current: ");
M5.Lcd.print(current);
M5.Lcd.print("A");
delay(500);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.print("V1: ");
M5.Lcd.print(v1);
M5.Lcd.print("V");
M5.Lcd.setCursor(10, 70);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.print("V2: ");
M5.Lcd.print(v2);
M5.Lcd.print("V");
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setCursor(10, 140);
M5.Lcd.print("Current: ");
M5.Lcd.print(current);
M5.Lcd.print("A");
Serial.print("sending v1-> ");
Serial.println(v1);
voltage1->save(v1);
Serial.print("sending v2-> ");
Serial.println(v2);
voltage2->save(v2);
Serial.print("sending Current-> ");
Serial.println(current);
curr->save(current);
}
Error output:
Arduino: 1.8.12 (Windows 10), Board: "M5Stack-Core-ESP32, QIO, 80MHz, Default, 921600, None"
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp: In member function 'void M5Display::drawPngUrl(const char*, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, double, uint8_t)':
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:543:3: error: 'HTTPClient' was not declared in this scope
HTTPClient http;
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:545:7: error: 'WiFi' was not declared in this scope
if (WiFi.status() != WL_CONNECTED) {
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:545:24: error: 'WL_CONNECTED' was not declared in this scope
if (WiFi.status() != WL_CONNECTED) {
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:550:3: error: 'http' was not declared in this scope
http.begin(url);
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:553:19: error: 'HTTP_CODE_OK' was not declared in this scope
if (httpCode != HTTP_CODE_OK) {
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:559:3: error: 'WiFiClient' was not declared in this scope
WiFiClient *stream = http.getStreamPtr();
^
C:\Users\graff\OneDrive\Documents\Arduino\libraries\M5Stack\src\M5Display.cpp:559:15: error: 'stream' was not declared in this scope
WiFiClient *stream = http.getStreamPtr();
^
Multiple libraries were found for "WiFi.h"
Used: C:\Users\graff\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
Not used: C:\Users\graff\OneDrive\Documents\Arduino\libraries\WiFi
Multiple libraries were found for "SD.h"
Used: C:\Users\graff\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Not used: C:\Users\graff\OneDrive\Documents\Arduino\libraries\SD
exit status 1
Error compiling for board M5Stack-Core-ESP32.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

First of all you should do what your compiler wants:
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
This gives more details and if the solution is not working edit your question and replace the compiler output with the detailed Info.Include the missinglibs manually in your program
#include <WiFi.h>
#include <SD.h>
#include <M5Stack.h>
#include <Wire.h>
and checkthe dependencies you have in
#include "config.h"
as I could not compile due to missing file

Related

Compilation Error Connecting ADS1115 with ESP8266

I'm getting this fatal error:
util/delay.h: No such file or directory
when compiling the below sketch:
#include <Wire.h>
#include <Adafruit_ADS1115.h>
Adafruit_ADS1115 ads;
void setup(void)
{
Serial.begin(115200);
ads.setGain(GAIN_ONE);
ads.begin();
}
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
Serial.print("AIN0: ");
Serial.println(adc0);
delay(1000);
}
I tried including "Arduino.h" as suggested by friends, but no use. While if I compile with "Adafruit_ADS1x15.h" instead of the above, it do upload but the ADC is not giving values.
Could anybody assist me?

How to solve conflicting declaration on the Library?

This is my code to build SHT10 reading. But I got an error message. It says that pin D1 is conflicting between Sensirion.cpp and arduino.h
#include <Sensirion.h>
#include <SensirionSHT.h>
SensirionSHT Sensor = SensirionSHT(4, 5);
long delayTime = 1;
void setup() {
Serial.begin(9600);
}
void loop() {
Sensor.tick(delayTime);
Serial.println(Sensor.getTemperature());
delay(delayTime * 1000);
}
And this is the error messages
C:\Users\ASUS\Documents\Arduino\libraries\Sensirion-master\Sensirion.cpp:52:15: error: conflicting declaration 'const float D1'
const float D1 = -40.1; // for deg C # 5V
^
In file included from C:\Users\ASUS\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:296:0,
from C:\Users\ASUS\Documents\Arduino\libraries\Sensirion-master\Sensirion.cpp:21:
C:\Users\ASUS\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\variants\nodemcu/pins_arduino.h:41:22: error: 'D1' has a previous declaration as 'const uint8_t D1'
static const uint8_t D1 = 5;
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Can't compile arduino code based on SinricPro libraries

I'm trying to compile my code based on SinricPro but I'm getting a huge error.
Libraries:
Wifi - 1.2.7
ArduinoJson - 6.12.0
SinricPro - 2.4.0
WebSockets - 2.2.0
Arduino board:
Node MCU with ESP8266MOD
The error:
Arduino: 1.8.13 (Windows Store 1.8.39.0) (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"
In file included from C:\Users\amng8\Documents\ArduinoProjects\Sinric\Sinric.ino:13:0:
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:122:5: error: 'vector' in namespace 'std' does not name a type
std::vector<SinricProDeviceInterface*> devices;
^
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'SinricProDeviceInterface* SinricProClass::getDevice(String)':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:139:23: error: 'devices' was not declared in this scope
for (auto& device : devices) {
^
In file included from C:\Users\amng8\Documents\ArduinoProjects\Sinric\Sinric.ino:13:0:
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'DeviceType& SinricProClass::add(const char*, long unsigned int)':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:211:3: error: 'devices' was not declared in this scope
devices.push_back(newDevice);
^
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::add(SinricProDeviceInterface*)':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:219:3: error: 'devices' was not declared in this scope
devices.push_back(newDevice);
^
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::add(SinricProDeviceInterface&)':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:226:3: error: 'devices' was not declared in this scope
devices.push_back(&newDevice);
^
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::handleRequest(ArduinoJson6120_000001::DynamicJsonDocument&, interface_t)':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:305:23: error: 'devices' was not declared in this scope
for (auto& device : devices) {
^
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::connect()':
C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:391:23: error: 'devices' was not declared in this scope
for (auto& device : devices) {
^
exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).
My code:
// Uncomment the following line to enable serial debug output
#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "SinricPro.h"
#include "SinricProGarageDoor.h"
#include "SinricProSwitch.h"
#define WIFI_SSID "DUMMY"
#define WIFI_PASS "DUMMY"
#define APP_KEY "DUMMY"
#define APP_SECRET "DUMMY"
#define GARAGEDOOR_ID "DUMMY"
#define SWITCH_LIGHTS_ID "DUMMY"
#define BAUD_RATE 9600
#define STATUS_LED D0
#define RELAY_1 D4
#define RELAY_2 D1
#define RELAY_3 D2
#define RELAY_4 D3
bool myPowerState = false;
bool onDoorState(const String& deviceId, bool &doorState) {
digitalWrite(RELAY_1, LOW);
delay(500);
digitalWrite(RELAY_1, HIGH);
Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
return true;
}
bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off");
myPowerState = state;
digitalWrite(RELAY_2, myPowerState?HIGH:LOW);
return true; // request handled properly
}
void setupWiFi() {
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
digitalWrite(STATUS_LED, HIGH);
delay(500);
digitalWrite(STATUS_LED, LOW);
delay(500);
}
IPAddress localIP = WiFi.localIP();
Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
digitalWrite(STATUS_LED, HIGH);
}
void setupSinricPro() {
SinricProGarageDoor &myGarageDoor = SinricPro[GARAGEDOOR_ID];
myGarageDoor.onDoorState(onDoorState);
SinricProSwitch &mySwitch = SinricPro[SWITCH_LIGHTS_ID];
mySwitch.onPowerState(onPowerState);
// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
pinMode(STATUS_LED, OUTPUT);
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_2, OUTPUT);
pinMode(RELAY_3, OUTPUT);
pinMode(RELAY_4, OUTPUT);
digitalWrite(STATUS_LED, LOW);
digitalWrite(RELAY_1, HIGH);
digitalWrite(RELAY_2, HIGH);
digitalWrite(RELAY_3, HIGH);
digitalWrite(RELAY_4, HIGH);
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
This error seems something from the SinricPro libraries and I can't seem to understand why is this error occurring.
GitHub issue

FirebaseArduino.h:20:18: fatal error: string: No such file or directory (Arduino)

I'm developing a project using FirebaseArduino library (Realtime database) on my Arduino Uno WiFi Rev2. When I ran my code, I got a mistake as following:
#include FirebaseArduino.h
#include WiFiNINA.h
Error message:
C:\Users\Documents\Arduino\libraries\firebase-arduino-USER\master\src/FirebaseArduino.h:20:18:
fatal error: string: No such file or directory
//FirebaseArduino.h lines 17 - 23
#ifndef FIREBASE_ARDUINO_H
#define FIREBASE_ARDUINO_H
#include <string> // Error
#include "Firebase.h"
#include "FirebaseObject.h"
// my code
#include <WiFiNINA.h>
#include <FirebaseArduino.h>
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PWD"
#define FIREBASE_HOST "****"
#define FIREBASE_AUTH "****"
void setup() {
//conect wifi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Firebase.begin(FIREBASE_HOST, FAREBASE_AUTH);
}
String firebaseGet(String s)
{
String x = Firebase.getString(s);
yield();
delay(100);
return x;
delay(100);
}
void loop() {
String firebaseStatus = firebaseGet("****");
if (firebaseStatus == "ON")
{
//code to happen if the status is ON
}
else if (firebaseResult == "OFF")
{
//code to happen if the status is OFF
}
}
I found some possible problems:
1 - Arduino IDE version INCOMPATIBLE -- Tried to use 1.8.5, 1.6.12 and failed;
1.6.9 doesn't have INCOMPATIBLE problem. But it still cannot run.
2 - Should install old library of firebase -- still cannot run

PlatformIO Fatal Build Error: LiquidCrystal.h "No such file or directory"

I'm fairly new to Atom / PlatformIO and tried using it for development with Arduino as an alternative to Arduino IDE.
~The Specs~
base code used: Arduino ESP sample code "WifiBlueToothSwitch.ino"
Board: ESP-WROOM-32
Additional Components: 1602A (2x16) LCD
I've successfully run other sample code on the ESP module through PlatformIO prior to attempting to use the LCD screen, however when I did attempt to include the LiquidCrystal.h library, it gives me a build error:
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
So of several of the sites I've searched about this issue so far, most point to the missing addition of the "wire.h" header file, however even after including it into the program, it still gives me this error.
My includes are as follows:
#include <Arduino.h>
#include <WiFi.h>
#include <Wire.h>
#include <LiquidCrystal.h>
So I'm not entirely sure why this problem is occurring.
How can I resolve this issue?
Edit 1:
I came across another site a moment ago that suggested attempting an update of PlatformIO via console, however this was to no avail. Everything was marked as "Up-to-date".
Documents\PlatformIO\Projects\171031-143050-esp32dev> platformio update
Updating tool-scons # 3.20501.2 [Up-to-date]
Updating tool-unity # 1.20302.1 [Up-to-date]
Updating pysite-pioplus # 0.4.2 [Up-to-date]
Updating contrib-piohome # 0.3.1 [Up-to-date]
Updating tool-pioplus # 0.10.11 [Up-to-date]
Platform Manager
================
Platform Espressif 32
--------
Updating espressif32 # 0.10.0 [Up-to-date]
Updating tool-esptoolpy # 1.20000.0 [Up-to-date]
Updating toolchain-xtensa32 # 1.50200.0 [Up-to-date]
Updating framework-arduinoespressif32 # 1.2.0 [Up-to-date]
Updating tool-espotapy # 1.0.0 [Up-to-date]
Library Manager
===============
Documents\PlatformIO\Projects\171031-143050-esp32dev>
Edit 2:
I have compiled and run this code through the Arduino IDE and can confirm that it works, so the problem seems to be with the PlatformIO IDE...
Edit 3:
After following BMelis's suggestion, I looked into the PlatformIO.ini file, and added the following line to it:
lib_extra_dirs = C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries
This fixed the initial error for the LiquidCrystal.h, However this also produced the following dependency error during build:
[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
I tried adding the directory that it was mentioning by adding a second lib_extra_dirs command in the ini file:
lib_extra_dirs = C:\Program Files (x86)\Arduino\hardware\espressif\esp32\tools\sdk\include\lwip\apps
However this did nothing to resolve the issue. I am at a loss as to what to do now...
FULL CODE:
#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;
}
In the terminal type:
pio lib install "LiquidCrystal"
For platformio, I work this way (I'm on Win10):
All my projects are in "my documents". General purpose libraries are in "my documents/libraries". Specific ones reside in the "lib" folder of the pio project.
In platformio.ini I have for example the following:
[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
for the platform you can comment out the right one (stage or release but for Arduino ESP32 "release" is quite...unstable)
put the right path in lib_extra_dirs and try to keep away from hiding all the libraries in the "Program Files" folder as it is quite unhandy to change something there if needed.
I think you need to download the LiquidCrystal package or isntall it with PlatformIO CLI. Check this: http://platformio.org/lib/show/887/LiquidCrystal/installation
Copy unzipped LiquidCrystal folder int your project's /lib folder please and try to build again.
ps: Private/3rd party libraries should be placed /lib folder.
I hit this problem as well. I believe the best solution is to add the entry to your platformio.ini file for the project and board(s). That way you don't need to add the library code to your own source tree, and this solution is resilient against 'works on my computer' as the project doesn't rely on the library being somewhere specific on your file system. Note I targeted a specific version here for maximum predictability, but you don't have to.
[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps = LiquidCrystal#1.5.0 #<--important line
I had to manually add liquidcrystal library to PlatformIO and this resolved it for me with the following steps:
Go to to PIO Home
Click on 'Libraries' below the reload home button
Search for and select liquidcrystal by arduino
Click add to project