NO SUCH FILE OR DIRECTORY in Adruino IDE with ThingSpeak library
Ältere Kommentare anzeigen
I have a project subject in University with database in ThingSpeak, I show code below like this with board ESP32. When I run with board ESP32 or ESP8266, the code announce me a error like "ThingSpeak.h: no such file or directory", although I install Thingspeak library before that. So, I need to do what to config that code. Can anyone help me? Thanks for responding or reading my problem. T.T
Error announce me inn Output:
fatal error: ThingSpeak.h: No such file or directory
compilation terminated.
My code:
#include <WiFi.h>
//#include <WiFiClient.h>
#include "ThingSpeak.h"
#define WIFI_SSID "Tang 1 Tro 198_2.4G"
#define WIFI_PASSWORD ""
#define SECRET_CH_ID 2108004
#define SECRET_WRITE_APIKEY "xxxxxxxxxxxxxxxx" // replace XYZ with your channel write API Key
#define A 35 // define MQ2 analog pin
#define D 14 // define MQ2 digital pin
#define LED 25
WiFiClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
int Digital_value, Analog_value;
unsigned long dataMillis = 0;
void setup() {
Serial.begin(9600);
pinMode(A, INPUT);
pinMode(D, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
ThingSpeak.begin(client);
}
void loop() {
Analog_value = analogRead(A);
Digital_value = digitalRead(D);
Serial.printf("Analog value: %d\n", Analog_value);
Serial.printf("Digital value: %d\n", Digital_value);
ThingSpeak.setField(1, Analog_value);
ThingSpeak.setField(2, !Digital_value);
if (millis() - dataMillis > 20000) {
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if (x == 200) {
Serial.println("Channel update successful.");
}
else {
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
dataMillis = millis();
}
if (!Digital_value) {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
}
}
4 Kommentare
Luca Ferro
am 18 Apr. 2023
check if ThingSpeak.h is in matlab path
Walter Roberson
am 18 Apr. 2023
The MATLAB path is not used to search for .h files. There are some default directories to search (determined by international standards), and then there are directories that are added to the search path by the project setup, such as by using the -I (capital letter eye) option to mex .
Christopher Stapels
am 18 Apr. 2023
I assume you are programming in Arduino IDE? Make sure you have installed the appropriate board in boards manager, and then try removing and then reinstalling the ThingSpeak library. Occasionally I have found missing library problems related to selection of the wrong board type.
Shivashankar
am 18 Mär. 2025
Verschoben: Christopher Stapels
am 18 Mär. 2025
Compilation error: Thingspeak.h: No such file or directory
Antworten (0)
Communitys
Weitere Antworten in ThingSpeak Community
Kategorien
Mehr zu C Shared Library Integration finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!