• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Error compiling for board NodeMCU-32S

Q&A Forum › Category: ESP32 › Error compiling for board NodeMCU-32S
0 Vote Up Vote Down
GARLAND asked 5 years ago

I am now getting this error with almost all of my sketches, but it started with the attached sketch.  Please understand that the sketch worked until four months ago.  There was a power outage and the sketch would not restart.  The boards ( there is a transmitter and a receiver) located at a remote location.

The complete error code is:

Build options changed, rebuilding all
core/core.a(main.cpp.o):(.literal._Z8loopTaskPv+0x4): undefined reference to `loop()'
core/core.a(main.cpp.o): In function `loopTask(void*)':
/home/gar/.arduino15/packages/esp32/hardware/esp32/1.0.3/cores/esp32/main.cpp:17: undefined reference to `loop()'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "WiFiClient.h"
Used: /home/gar/.arduino15/packages/esp32/hardware/esp32/1.0.3/libraries/WiFi
Not used: /home/gar/arduino/libraries/WiFi
exit status 1
Error compiling for board NodeMCU-32S.

Please advise something to try.  I have tried to remove parts of the program such as #include <EspMQTTClient.h>.  This seemed to work one time only, but never again.

Garland

Question Tags: [code] /* This sketch, PIR cloudMQTT XMIT
4 Answers
1 Vote Up Vote Down
Best Answer
Rui Santos Staff answered 5 years ago

Can you tell me exactly which code are you trying to upload? Is everything up to date?

0 Vote Up Vote Down
SDBURTON answered 5 years ago

I experienced similar messages when I had multiple versions of Arduino installed with different library sets. There may be a way to limit where the compiler searches and loads libraries from, but I opted to remove all except for my most current Arduino setup to keep it simple and avoid library confusion. (Hope this helps…)

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
That is probably happening because you don’t have a loop() in your code.
Verify that you have a loop() function in your code.
Regards,
Sara

0 Vote Up Vote Down
GARLAND answered 5 years ago

SDBURTON – Thanks for the suggestion. I tried what you suggested, but I still have the problem. It did help with other sketches though and I thank you for that.

Sara – My code has a loop() function so, unfortunately, that did not work. Thanks for the suggestion.

Rui – Below is my sketch. I am using a MODEMCU ESP-32S board, my “Boards” and my “Libraries” are all up to date. I am using Arduino-1.8.12.

Thanks everyone for your suggestions and your help.

Garland

[code]
/*
This sketch,PIR cloudMQTT XMIT, is designed to send a signal via RF when a PIR senses a person.

Created 15 Jun 2019
by Garland Sparks
This code is in the public domain.

*/

// Loading the required libraries
#include
#include
#include

// Define PIM pin
#define Pin17 17

// esp32 connects to your router
EspMQTTClient client();
const char* ssid = “dd-wrt”; //”PGC”;
const char* password = “******”; //”*******”;

// Connect to the cloudMQTT
const char* mqttServer = “m16.cloudmqtt.com”;
const int mqttPort = 12202;
const char* mqttUser = “32xmit”; //This receiver module
const char* mqttPassword = “*********”; // Password
//”32xmitUser”, // Client name
//12202 // MQTT port

void setup() {
delay(10);
Serial.println();
Serial.begin(115200);
Serial.print(“Connecting to “);
Serial.println(ssid);
WiFi.begin(“ssid”, “password”);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
randomSeed(micros());
Serial.println(“”);
Serial.println(“WiFi connected”);
Serial.println(“IP address: “);
Serial.println(WiFi.localIP());
}

void reconnect() {
// Loop until we’re reconnected
if ( WiFi.status() != WL_CONNECTED) {
while (WiFi.begin(“ssid”, “password”) != WL_CONNECTED) {
// unsuccessful, retry in 4 seconds
Serial.print(“failed … “);
delay(4000);
Serial.print(“retrying … “);
}
}
}
/*while (!client.connected()) {
Serial.print(“Attempting MQTT connection…”);
// Create a random client ID
String clientId = “ESP32Client-“;
clientId += String(random(0xffff), HEX);
// Attempt to connect

if (client.connect(clientId_str(),MQTT_USER,MQTT_PASSWORD)) {
Serial.println(“Connected”);
WiFi.begin(“ssid”, “password”);
digitalWrite(0, LOW);
digitalWrite(2, HIGH);
} else {
*/

void callback(char* topic, byte *payload, unsigned int length) {
Serial.println(“——-new message from broker—–“);
Serial.print(“channel:”);
Serial.println(topic);
Serial.print(“data:”);
Serial.write(payload, length);
Serial.println();
}

client.enableHTTPWebUpdater();

//Define that Pin17 is an input
pinMode(Pin17, INPUT);
}

//Establish that there is a connection with cloudMQTT
void onConnectionEstablished(){
client.publish(“esptest”,”hello”);
Serial.println(“Contact is established”);
}

void Action(){
char* messageTemp = “2”;
delay(3*1000);
//Read the value of Pin17 Output
int PinVal=digitalRead(Pin17);

Serial.print(“Pin ‘In’ Value =”);
Serial.println(PinVal);

//The following is the logic that tells the receiver to do something
if(PinVal == 1){
messageTemp = “1”;
client.publish(“esptest”, “1”);
Serial.print(“Message to Send “);
Serial.println(PinVal);
digitalWrite(Pin17,HIGH);
}else{
//read value of Pin17 input;
PinVal=digitalRead(Pin17);
if(PinVal== 0){
messageTemp=”0”;
client.publish(“esptest”, “0”);
Serial.print(“Message= “);
Serial.println(PinVal);
digitalWrite(Pin17, LOW);
}
}
}

void loop(){
client.loop();
Action();
delay(3000);
}
*/
[/code]

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.