Hi,
I’m getting a really annoying message from Arduino IDE. What is strange in my case is that this error appears continuously without any criteria even if the function is already declared.
Details :
• esp8266 + WIFI.
• Windows 10 x64
• Blynk server
• Blynk_Release_v0.6.1
My sketch code is down here:
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
//#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
char ssidblynk[] = "*=* dP *=*";
char passblynk[] = "";
#define ECHOPIN 12 //Echo to pin D6
#define TRIGPIN 14 //Trig to pin D5
float duration,distance ;
int Ep=0;
BlynkTimer timer;
int functionCall = 0; // SimpleTimer used to stop and start a function
WidgetLCD lcd(V2);
WidgetLED ledcode(V0);
WidgetLED ledtype(V3);
WidgetLED ledep(V8);
Ticker blinker;
void changeState() {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
int currentMenu;
int MenuIndexID;
BLYNK_WRITE(V1)
{
MenuIndexID=param.asInt();
if (currentMenu==0)
{
timer.disable(functionCall);
Serial.println("Regulation");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Which one");
if (MenuIndexID==1)
{
ledcode.on();
Serial.println("V2003");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "V2003");
Blynk.setProperty(V1,"labels","Shear L","Shear U", "Shear T","Back");
currentMenu=1;
Blynk.virtualWrite(V1,1);
}
else if (MenuIndexID==2)
{
ledcode.on();
Serial.println("E8");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "E8");
Blynk.setProperty(V1,"labels","Shear L -Not yet-","Shear U -Not yet-","Shear L -Not yet-", "Back");
currentMenu=2;
Blynk.virtualWrite(V1,1); // Select the first menu item
}
else if (MenuIndexID==3)
{
ledcode.on();
Serial.println("A97");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "A97");
Blynk.setProperty(V1,"labels","Shear L -Not yet-","Shear U -Not yet-","Shear L -Not yet-", "Back");
currentMenu=3;
Blynk.virtualWrite(V1,1); // Select the first menu item
}
else {
}
}
if (currentMenu==1)
{
Serial.println("V2003");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "V2003");
ledcode.on();
if (MenuIndexID==1)
{
ledtype.on();
functionCall=1;
digitalWrite(LED_BUILTIN,HIGH);
Serial.println("Shear L In use");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Shear: Forme L");
timer.setTimeout(2000L,[](){lcd.print(0, 0, "Enter: ");}); //
functionCall=timer.setInterval(50, sendUptime);
}
else if (MenuIndexID==2)
{
ledtype.on();
functionCall=1;
digitalWrite(LED_BUILTIN,HIGH);
Serial.println("Shear U In use");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Shear: Forme L");
timer.setTimeout(2000L,[](){lcd.print(0, 0, "Enter: ");});
functionCall=timer.setInterval(50, sendUptime);
}
else if (MenuIndexID==3)
{
ledtype.on();
functionCall=1;
digitalWrite(LED_BUILTIN,HIGH);
Serial.println("Shear U In use");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Shear: Forme L");
timer.setTimeout(2000L,[](){lcd.print(0, 0, "Enter: ");}); //
functionCall=timer.setInterval(50, sendUptime);
}
}
else if (MenuIndexID==4) // Back
{
Serial.println("Back");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Back");
timer.disable(functionCall);
set_Menu0_labels();
}
else {
}
}
if (currentMenu==2)
{
Serial.println("E8");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "E8");
if (MenuIndexID==1)
{
Serial.println("Shear L In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear L In use-Not yet-");
blinker.attach(0.5, changeState); //Use <strong>attach_ms</strong> if you need time in ms
}
else if (MenuIndexID==2)
{
Serial.println("Shear U In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear U In use-Not yet-");
blinker.attach(1, changeState); //Use <strong>attach_ms</strong> if you need time in ms
}
else if (MenuIndexID==3)
{
Serial.println("Shear T In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear T In use-Not yet-");
blinker.attach_ms(3, changeState); //Use <strong>attach_ms</strong> if you need time in ms
}
else if (MenuIndexID==4) // Back
{
Serial.println("Back");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Back");
timer.disable(functionCall); //Disable timer
set_Menu0_labels();
}
}
if (currentMenu==3)
{
Serial.println("A97");
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "A97");
if (MenuIndexID==1)
{
Serial.println("Shear L A97 In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear L A97 In use-Not yet-");
}
else if (MenuIndexID==2)
{
Serial.println("Shear U A97 In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear U A97 In use-Not yet-");
}
else if (MenuIndexID==3)
{
Serial.println("Shear T A97 In use-Not yet-");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 1, "Shear T A97 In use-Not yet-");
}
else if (MenuIndexID==4) // Back
{
Serial.println("Back");
//lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Back");
timer.disable(functionCall); //Disable timer
set_Menu0_labels();
}
}
else {
}
}
void set_Menu0_labels()
{
// Set the menu back to it's Menu 0 defaults
// Doing this means that you only need to edit/define the Menu 0 labels on one location within the cdode
Blynk.setProperty(V1,"labels","V2003","E8","A97");
currentMenu=0;
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(0, 0, "Regulation");
Blynk.virtualWrite(V1,5); // Select the first menu item
timer.disable(functionCall); //Disable timer
Blynk.virtualWrite(V5,0);
Blynk.virtualWrite(V7,0);
Blynk.virtualWrite(V4,0);
EpShear=0;
ledcode.off();
ledtype.off();
ledep.off();
}
BLYNK_WRITE(V6)
{
EpShear = param.asInt(); // assigning incoming value from pin V1 to a variable
lcd.print(0,1,EpShear);
lcd.print(3,1,"Cm");
Serial.println(EpShear);
}
BLYNK_CONNECTED()
{
// This code runs when the ESP first connects to Blynk, or after a re-conection
// Call the function to set the menu to it's "Menu 0" defaults
set_Menu0_labels();
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
Blynk.begin(auth, ssidblynk, passblynk);
}
void sendUptime() {
if (EpShear!=0)
{
ledep.on();
lcd.print(0, 1, "Show:");
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
duration = pulseIn(ECHOPIN, HIGH); //
distance= (duration*0.035)/2+EpShear; //
double distanceTwoDic=distance; //
double Error=distance*0.1/60; //
Blynk.virtualWrite(V5, distanceTwoDic); //
Blynk.virtualWrite(V4, distanceTwoDic);
Blynk.virtualWrite(V7, distanceTwoDic);
Blynk.virtualWrite(V9,Error); //
if (distance>=30)
{
Serial.println(distanceTwoDic);
lcd.print(0,0, " !!!!! ");
Blynk.setProperty(V2,"color","#D3435C");
Blynk.virtualWrite(V2,1); //Update the pin
}
else
{
lcd.print(0,0, " BON ");
Blynk.setProperty(V2,"color","#23C48E");
Blynk.virtualWrite(V2,1);
Serial.println(distanceTwoDic);
}
}
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
Also, the error is attached down here:
C:\Users\mus76\Documents\Arduino\Menu_New_file_Backup\Menu_New_file_Backup.ino: In function 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)':
Menu_New_file_Backup:100:42: error: 'sendUptime' was not declared in this scope
functionCall=timer.setInterval(50, sendUptime);
^
Menu_New_file_Backup:111:42: error: 'sendUptime' was not declared in this scope
functionCall=timer.setInterval(50, sendUptime);
^
Menu_New_file_Backup:122:42: error: 'sendUptime' was not declared in this scope
functionCall=timer.setInterval(50, sendUptime);
^
Menu_New_file_Backup:131:24: error: 'set_Menu0_labels' was not declared in this scope
set_Menu0_labels();
^
C:\Users\mus76\Documents\Arduino\Menu_New_file_Backup\Menu_New_file_Backup.ino: At global scope:
Menu_New_file_Backup:139:3: error: expected unqualified-id before 'if'
if (currentMenu==2)
^
Multiple libraries were found for "Ticker.h"
Used: C:\Users\mus76\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\Ticker
Not used: C:\Program Files (x86)\Arduino\libraries\Ticker
exit status 1
'sendUptime' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Something weird here. If I remove the second if condition, the sketch compiles properly even if the function named ‘sendUptime’ that it keeps referring to, already exists in the first if condition.
Any suggestions?