What's wrong with the signs? I have reviewed the program many times

The error is here:
expected unqualified-id before '{' token

Program:

#include<Arduino.h>
#include<WiFi.h>
#include<Firebase_ESP_Client.h>

//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"

#define WIFI_SSID " My ssid "
#define WIFI_PASSWORD " My password"
#define API_KEY "AIzaSyAnwoF810DeaZfK17a6CKxq-R4z0TKO0XM"
#define DATABASE_URL " https://kontrollere-to-led-default-rtdb.europe-west1.firebasedatabase.app"

#define LED1_PIN 12
#define LED2_PIN 14
#define LDR_PIN 36
#define PWMChannel 0
const int freq = 5000;
const int resolution = 8;

FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

unsigned long sendDataPrevMillis = 0;
bool signupOK = false;
int ldrData = 0;
float voltage = 0.0;
int pmwValue = 0;
bool ledstatus = false;

void setup() {

pinMode(LED2_PIN, OUTPUT);
ledcSetup(PWMChannel, freq, resolution);
ledcAttachPin(LED1_PIN, PWMChannel);

Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}

Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();

config.api_key = API_KEY;
config.database_url = DATABASE_URL;
if (Firebase.signUp(&config, &auth, "", "")) {
Serial.println("signUp OK");
signupOK = true;
} else {

Serial.printf("%s\n", config.signer.signupError.message.c_str());

}

config.token_status_callback = tokenStatusCallback;
Firebase.begin(&config, &auth);
Firebase.reconnectWiFi(true);
}

void loop(); {

if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 5000 || sendDATAPrevMillis == 0)) {
sentDataPrevMillis = millis();
//--------------------------Store data to a RTDB -----
ldrData = analogRead(LDR_PIN);
voltage = (float)analogReadMilliVolts(LDR_PIN) / 1000;
if (Firebase.RTDB.setInt(&fbdo, "Sensor/ldr_data", ldrData)) {
Serial.println();
Serial.print(ldrData);
Serial.print(" - successfully saved to:" + fbdo.dataPath());
Serial.print(" (" + fbdo.dataType() + ")");
} else {
Serial.print("FAILED:" + fbdo.errorReason());
}
if (Firebase.RTDB.setFloat (&fbdo, "Sensor/voltage",voltage)) {
Serial.print(voltage));
Serial.print(" - succesfully saved to:" + fbdo.dataPath());
Serial.println("(" + fbdo.dataType() + ")");
} else {
Serial.println ("FAILED: " + fbdo.errorReason());
}
// ------------------------------- READ from a RTDB to control devices attached to the ESP32

if (Firebase.RTDB.getInt(&fbdo, "LED/analog")) {

  if (fbdo.dataType() == "int") {
    pwmValue = fbdo.intData();
    Serial.println("Successful Read from" + fbdo.dataPath() + ":" + pwmValue + "(" + fbdo.dataType() + ")");
    ledcWrite(PWMchannel, pwmValue);
  }
} else {
  Serial.println("FAILED:" + fbdo.errorReason());
}

if (Firebase.RTDB.getBool(&fbdo, "LED/digital")); {
  if (fbdo.dataType() == "boolean") {
    ledStatus = fbdo.boolData();
    Serial.println("Successful Read from RTDB" + fbdo.dataPath() + ":" + ledStatus + "(" + fbdo.dataType() + ")");
    digitalWrite(LED2_PIN, ledStatus);
  }
} else {
  Serial.println("FAILED:" + fbdo.errorReason());
}

}
}

code compiled without error for me

could you post the complete error msg which will say which line the error is on?

1 Like

in loop =

void loop() {

also

sendDataPrevMillis

There are a lot of errors, when editing the code becomes unbearable, you can try this sketch))

#include<Arduino.h>
#include<WiFi.h>
#include<Firebase_ESP_Client.h> //https://github.com/mobizt/Firebase-ESP-Client

//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"

#define WIFI_SSID "Open"
#define WIFI_PASSWORD "12345678"
#define API_KEY "AIzaSyAnwoF810DeaZfK17a6CKxq-R4z0TKO0XM"
#define DATABASE_URL " https://kontrollere-to-led-default-rtdb.europe-west1.firebasedatabase.app"

#define LED1_PIN 12
#define LED2_PIN 14
#define LDR_PIN 36

#define PWMChannel 0

const int freq = 5000;
const int resolution = 8;

FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

unsigned long sendDataPrevMillis = 0;
bool signupOK = false;
int ldrData = 0;
float voltage = 0.0;
int pwmValue = 0;
bool ledStatus = false;


void setup() {
  pinMode(LED2_PIN, OUTPUT);
  ledcSetup( PWMChannel, freq, resolution);
  ledcAttachPin(LED1_PIN, PWMChannel);

  Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi ..");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }

  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  config.api_key = API_KEY;
  config.database_url = DATABASE_URL;
  if (Firebase.signUp(&config, &auth, "", "")) {
    Serial.println("signUp OK");
    signupOK = true;
  } else {

    Serial.printf("%s\n", config.signer.signupError.message.c_str());
  }

  config.token_status_callback = tokenStatusCallback;
  Firebase.begin(&config, &auth);
  Firebase.reconnectWiFi(true);
}

void loop() {

  if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 5000 || sendDataPrevMillis == 0)) {
    sendDataPrevMillis = millis();
    //--------------------------Store data to a RTDB -----
    ldrData = analogRead(LDR_PIN);
    voltage = (float)analogReadMilliVolts(LDR_PIN) / 1000;
    if (Firebase.RTDB.setInt(&fbdo, "Sensor/ldr_data", ldrData)) {
      Serial.println();
      Serial.print(ldrData);
      Serial.print(" - successfully saved to:" + fbdo.dataPath());
      Serial.print(" (" + fbdo.dataType() + ")");
    } else {
      Serial.print("FAILED:" + fbdo.errorReason());
    }
    if (Firebase.RTDB.setFloat (&fbdo, "Sensor/voltage", voltage)) {
      Serial.print(voltage);
      Serial.print(" - succesfully saved to:" + fbdo.dataPath());
      Serial.println("(" + fbdo.dataType() + ")");
    } else {
      Serial.println ("FAILED: " + fbdo.errorReason());
    }
    // ------------------------------- READ from a RTDB to control devices attached to the ESP32

    if (Firebase.RTDB.getInt(&fbdo, "LED/analog")) {

      if (fbdo.dataType() == "int") {
        pwmValue = fbdo.intData();
        Serial.println("Successful Read from" + fbdo.dataPath() + ":" + pwmValue + "(" + fbdo.dataType() + ")");
        ledcWrite(PWMChannel, pwmValue);
      }
    } else {
      Serial.println("FAILED:" + fbdo.errorReason());
    }

    if (Firebase.RTDB.getBool(&fbdo, "LED/digital")) {
      if (fbdo.dataType() == "boolean") {
        ledStatus = fbdo.boolData();
        Serial.println("Successful Read from RTDB" + fbdo.dataPath() + ":" + ledStatus + "(" + fbdo.dataType() + ")");
        digitalWrite(LED2_PIN, ledStatus);
      }
    } else {
      Serial.println("FAILED:" + fbdo.errorReason());
    }
  }
}


The error is the superfluous semi-colon above. It turns the line into a function prototype NOT a function definition.

1 Like

Hi,
read " How to get the best out of this forum"
and correct post using </> for code.

Thanks for the answer. And I've been wearing glasses, I have deleted (;), but then unfortunately new errors appeared.

Yet you are keeping the errors a secret? Do you not understand that the error message contains ALL the information needed to know precisely what, and where, the error is?

POST your current code. POST the ENTIRE error message. We dont have crystal balls...

Please use code tags when posting code.

Hi, @013hjs1423
Welcome to the forum.

To add code please click this link;

What version IDE are you using?
What OS.
What model Arduino controller are you using?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

A simple step is to address the very first error that the compiler throws at you, and not worry too much about the ones lower down. Sometimes, that works miracles.
Then, systematically continue on with the now new first error, etc.

Code!

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