Hi, I'm new here (I've never asked questions here before), So I'll just make it simple, I was compiling a program to my ESP32 and and it gave an error about arduino-builder. Here's the program I was trying to compile:
#include <WiFi.h>
#include <PubSubClient.h>
const char* ssid = "SSID";
const char* password = "PASSWORD";
const char* mqtt_server = "MQTT_BROKER_IP";
#define ANALOG_IN_PIN 35 // ESP32 pin GPIO36 (ADC0) connected to voltage sensor
#define REF_VOLTAGE 3.3
#define ADC_RESOLUTION 4096.0
#define R1 30000.0 // resistor values in voltage sensor (in ohms)
#define R2 7500.0 // resistor values in voltage sensor (in ohms)
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
void setup() {
Serial.begin(9600);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* message, unsigned int length) {
Serial.print("Message arrived on topic: ");
Serial.print(topic);
Serial.print(". Message: ");
String messageTemp;
for (int i = 0; i < length; i++) {
Serial.print((char)message[i]);
messageTemp += (char)message[i];
}
Serial.println();
// Feel free to add more if statements to control more GPIOs with MQTT
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESP8266Client")) {
Serial.println("connected");
// Subscribe
client.subscribe("esp32/voltage");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
long now = millis();
if (now - lastMsg > 5000) {
lastMsg = now;
// read the analog input
int adc_value = analogRead(ANALOG_IN_PIN);
// determine voltage at adc input
float voltage_adc = ((float)adc_value * REF_VOLTAGE) / ADC_RESOLUTION;
// calculate voltage at the sensor input
float voltage_in = voltage_adc * (R1 + R2) / R2;
char voltString[8];
dtostrf(voltage_in, 1, 2, voltString);
// print results to serial monitor to 2 decimal places
Serial.print("Measured Voltage = ");
Serial.println(voltage_in, 2);
client.publish("esp32/voltage", voltString);
}
}
And here's the nasty error:
WARNING: Category 'Sound' in library ESP_I2S is not valid. Setting to 'Uncategorized'
WARNING: Category 'Sensor' in library ESP_NOW is not valid. Setting to 'Uncategorized'
WARNING: Category 'Sound' in library ESP_SR is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library ESP Insights is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library ESP RainMaker is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library TFLite Micro is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library WiFiProv is not valid. Setting to 'Uncategorized'
panic: runtime error: index out of range [5] with length 5
goroutine 1 [running]:
arduino.cc/builder.(*includeCache).Next(...)
arduino.cc/builder/container_find_includes.go:209
arduino.cc/builder.findIncludesUntilDone(0xc000080400, 0xc000076030, {{0x52ee20, 0xc0006a41e0}, {0xc0006cdeaf, 0x6}})
arduino.cc/builder/container_find_includes.go:321 +0x119d
arduino.cc/builder.(*ContainerFindIncludes).Run(0xc0000c6180, 0xc000080400)
arduino.cc/builder/container_find_includes.go:149 +0xc25
arduino.cc/builder.runCommands(0x8, {0xc000709c58, 0x22, 0x5555555555555}, 0x10)
arduino.cc/builder/builder.go:191 +0xda
arduino.cc/builder.(*Builder).Run(0x7fffecc3a1db, 0x19)
arduino.cc/builder/builder.go:124 +0x890
arduino.cc/builder.RunBuilder(...)
arduino.cc/builder/builder.go:222
main.main()
arduino.cc/arduino-builder/main.go:338 +0x988
arduino-builder returned 2
Error compiling for board DOIT ESP32 DEVKIT V1.