Exit status 1 Error

I have an issue with my code. When I compile my code, I receive a "Exit status 1" error. May someone please tell me where I'm going wrong. My code is...

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>
#include <ThingsBoard.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 99
#endif

#define THINGSBOARD_ENABLE_PROGRAM 0
#define THINGSBOARD_ENABLE_PSRAM 0
#define THINGSBOARD_ENABLE_DYNAMIC 1

constexpt char WIFI_SSID[]="iPhone (3)";
constexpt char WIFI_PASSWORD[]="qwertyui";
constexpt char TOKEN[]="TKm4MA82jKZKBRDidGIX";
constexpt char THINGSBOARD_SERVER[]="demo.thingsboard.io";
constexpt unit16_t THINGSBOArD_PORT=1883U;
constexpt unit32_t MAX_MESSAGE_SIZE=256U;
constexpt unit32_t SERIAL_DEBUG_BAUD 115200U;
constexpr int16_t telemetrySendInterval = 2000U;
uint32_t previousDataSend;

WiFiClient wifiClient;
ThingsBoard tb(wifiClient, MAX_MESSAGE_SIZE);

int MQ2=A0;//(A0)
int GAS;
int Latitude;
int Longitude;
int Speed;
int Altitude;

TinyGPSPlus gps;
SoftwareSerial GPS(2,0);//Blue(D4),purple(D3)

void InitWiFi() {
Serial.println("Connecting to AP ...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to AP");
}

const bool reconnect() {
// Check to ensure we aren't connected yet
const wl_status_t status = WiFi.status();
if (status == WL_CONNECTED) {
return true;
}
InitWiFi();
return true;
}

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
GPS.begin(9600);
Serial.begin(115200);
InitWiFi();
pinMode(MQ2,INPUT);
}

void loop() {
if (!reconnect()) {
subscribed = false;
return;
}

if (!tb.connected()) {
subscribed = false;
Serial.print("Connecting to: ");
Serial.print(THINGSBOARD_SERVER);
Serial.print(" with token ");
Serial.println(TOKEN);
if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
Serial.println("Failed to connect");
return;
}
GPS.listen();
while (GPS.available() > 0) {
gps.encode(GPS.read());
if (gps.location.isUpdated()) {
Serial.print("Longitude=");
Serial.println(gps.location.lng(), 6);
Serial.print("Latitude=");
Serial.println(gps.location.lat(), 6);
Serial.print("Speed=");
Serial.println(gps.speed.kmph());
Serial.print("Altitude in meters=");
Serial.println(gps.altitude.meters());

  GAS= analogRead(MQ2);
  Serial.print("Gas=");
  Serial.println(GAS);




  Serial.println("\t");
  delay(1000);


  tb.sendTelemetryInt("Gas",GAS);
  tb.sendTelemetryInt("Longitude",gps.location.lng());
  tb.sendTelemetryInt("Latitude",gps.location.lat());
  tb.sendTelemetryInt("Speed",gps.speed.kmph());
  tb.sendTelemetryInt("Altitude",gps.altitude.meters());
}

}

Nothing else?
Just that?

I just resolved that error. I am currently stuck with this error code now.

C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:14: warning: "THINGSBOARD_ENABLE_DYNAMIC" redefined
14 | #define THINGSBOARD_ENABLE_DYNAMIC 1
|
In file included from c:\Users\srick\Documents\Arduino\libraries\ThingsBoard\src/Constants.h:15,
from c:\Users\srick\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:21,
from C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:4:
c:\Users\srick\Documents\Arduino\libraries\ThingsBoard\src/Configuration.h:52: note: this is the location of the previous definition
52 | # define THINGSBOARD_ENABLE_DYNAMIC 0
|
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:22:38: error: expected initializer before numeric constant
22 | constexpr uint32_t SERIAL_DEBUG_BAUD 115200U;
| ^~~~~~~
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino: In function 'void loop()':
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:71:5: error: 'subscribed' was not declared in this scope
71 | subscribed = false;
| ^~~~~~~~~~
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:76:5: error: 'subscribed' was not declared in this scope
76 | subscribed = false;
| ^~~~~~~~~~
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:81:48: error: 'THINGSBOARD_PORT' was not declared in this scope; did you mean 'THINGSBOArD_PORT'?
81 | if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
| ^~~~~~~~~~~~~~~~
| THINGSBOArD_PORT
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:113:1: error: expected '}' at end of input
113 | }
| ^
C:\Users\srick\Documents\Arduino\final2PLZWORK\final2PLZWORK.ino:69:13: note: to match this '{'
69 | void loop() {
| ^

I used this website (How to connect NodeMCU V2 to ThingsBoard? | ThingsBoard Community Edition) to generate this code and i don't understand why I received this error.

#define THINGSBOARD_ENABLE_DYNAMIC 1

This constant is already defined as a 0 in the Thingsboard header file. The compiler complains when you try to give something two different definitions.
If you look in the folder where that library is, you'll find a SRC subfolder. Inside that is a file configuation.h, and that constant is defined in there on line 52

constexpt unit32_t SERIAL_DEBUG_BAUD 115200U;

I believe you are missing an equal sign between the variable name and the value.

subscribed = false;

You are using this variable, but you have not told the compiler what type of variable it is. You always need to define a variable before you can use it.

constexpt unit16_t THINGSBOArD_PORT=1883U;

There appears to be a typo in the variable name where you defined it. C is case sensitive, so THINGSBOARD_PORT, ThingsBoard_Port and THINGSBOArD_PORT are three different variable names to the compiler.

For the last error, you have a mismatched number of { and } braces in the loop function.
When writing your code, it helps to indent the code by at least four spaces every time you open a {, and reduce the indent level every time you use a } to close a block of code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.